With this architecture , how do you setup the migrations . I've been trying since couple of days , without success.
I di the below :
`
const configService = new ConfigService();
export const dataSourceOptions: DataSourceOptions = {
type: 'postgres',
url: configService.get('POSTGRES_URL'),
entities: ['dist/**/.entity.js'],
migrations: ['dist/migrations/.js'],
logging: true,
synchronize: false,
};
const dataSource = new DataSource(dataSourceOptions);
export default dataSource;
`
then in packagejson
"typeorm": "npm run build && npx typeorm -d ./libs/common/src/config/data-source.ts", "migration:generate": "npm run typeorm -- migration:generate", "migration:run": "npm run typeorm -- migration:run", "migration:revert": "npm run typeorm -- migration:revert",
and finnally i run the command
npm run typeorm -- migration:generate "migrations/create-users"
but i'm getting the error
Error: Unable to open file: "/home/zoutigo/projets/ordering/ordering_app/libs/common/src/config/data-source.ts". Cannot use import statement outside a module
at Function.loadDataSource (/home/zoutigo/projets/ordering/ordering_app/node_modules/typeorm/commands/CommandUtils.js:22:19)
at async Object.handler (/home/zoutigo/projets/ordering/ordering_app/node_modules/typeorm/commands/MigrationGenerateCommand.js:68:26)
Could you please tell we what i'm doing wrong ?