I have created a sample TypeORM project using the TypeORM CLI which has ormconfig.json by default:
{
"type": "postgres",
"host": "localhost",
"port": 5432,
"username": "postgres",
"password": "postgres",
"database": "test",
"synchronize": false,
"entities": [
"src/entity/**/*.ts"
],
"migrations": [
"database/migrations/**/*.ts"
],
"subscribers": [
"src/subscriber/**/*.ts"
],
"cli": {
"entitiesDir": "src/entity",
"migrationsDir": "database/migrations",
"subscribersDir": "src/subscriber"
}
}
this is the directory structure:
-database
-migrations
-src
-entity
-ormconfig.json
This creates the migrations in the database/migrations folder properly as well as executes the migrations from it.
I replaced ormconfig.json with the following ormconfig.ts :
export default {
type: 'postgres',
host: 'localhost',
port: 5432,
username: 'postgres',
password: 'postgres',
database: 'test',
synchronize: false,
"entities": [
"src/entity/**/*.ts"
],
"migrations": [
"database/migrations/**/*.ts"
],
"subscribers": [
"src/subscriber/**/*.ts"
],
"cli": {
"entitiesDir": "src/entity",
"migrationsDir": "database/migrations",
"subscribersDir": "src/subscriber"
}
};
This however creates migrations in the root directory instead of inside database/migrations.
Can anyone help me in figuring out what's missing here and how I can use ormconfig.ts to generate migrations inside the intended directory?