Skip to main content
Version: 2.1

Configuration

TSCord supports different databases:

  • SQLite (by default)
  • MySQL
  • MariaDB
  • PostgreSQL
tip

By default, the template is configured to use SQLite. If your bot doesn't aim to be used on thousands of guilds with hundred of thousands of users, you should keep it.

Plus, SQLite is the only database supported by the automatic backup system.

You can configure all of this in the src/config/database.ts file.

Indeed, this file exports a a mikroOrmConfig constant, which contains a production configuration and an optional development configuration. At runtime, the good configuration is chosen thanks to the NODE_ENV environment variable. The database type should be explicitely set in the mikroOrmConfig.production.type constant as it will be used to determine which entity manager type Mikro-ORM should use internaly.

You can find here the configuration for the different types of databases:

mikroOrmConfig
{
type: 'better-sqlite', // or 'sqlite'
dbName: `${databaseConfig.path}db.sqlite`, // path to the db .sqlite file
}

Env

You surely noticed that the database connection informations are stored in the environment variables.

You can edit it in the .env file.

Example:

.env
#...

DATABASE_HOST="database"
DATABASE_PORT=3306
DATABASE_NAME="tscord_bot"
DATABASE_USER="tscord"
DATABASE_PASSWORD="tscord123"

#...