I tried to run the migrations directly from the code in runtime, but when the datasource is initialized, the cli typeorm is immediately launched.
typeorm ver. 0.3.2
nodejs ver. v22.13.1
ts-node ver. v10.9.2
typescript ver. 5.8.2
Code:
import { DataSource } from 'typeorm'
const dataSource = new DataSource({
type: 'postgres',
host: '...',
port: 5432,
username: '...',
password: '...',
database: '...',
migrationsTableName: '...',
migrationsRun: false,
synchronize: false,
migrations: ['../migrations/**/*.js'],
})
dataSource.initialize()
Result:
$ npx ts-node src/test.ts
Usage: bin.js <command> [options]
Commands:
bin.js schema:sync Synchronizes your entities with database
schema. It runs schema update queries on all
connections you have. To run update queries
on a concrete connection use -c option.
bin.js schema:log Shows sql to be executed by schema:sync
...
...
...
If you remove the line with the path to migrations, cli does not start. Tried to run compiled js but the same thing happens.