ORM for TypeScript and JavaScript. Supports MySQL, PostgreSQL, MariaDB, SQLite, MS SQL Server, Oracle, SAP Hana, WebSQL databases. Works in NodeJS, Browser, Ionic, Cordova and Electron platforms.
Steps to reproduce or a small repository showing the problem:
when attempting to use getDatabases() from inside a migration file, the method always returns an empty array []. Migrations against the default Database run fine.
our use case is needing to update 1-n databases for a multi-tenant scenario, we would like to grab all databases from the method and then iterate through each one applying the same migration up/down logic.
example code to reproduce the issue.
`import {MigrationInterface, QueryRunner} from 'typeorm';
export class MigrationOne1564078353345 implements MigrationInterface {
Issue type:
[ ] question [x ] bug report [ ] feature request [ ] documentation issue
Database system/driver:
[ ]
cordova
[ ]mongodb
[ ]mssql
[x ]mysql
/mariadb
[ ]oracle
[ ]postgres
[ ]cockroachdb
[ ]sqlite
[ ]sqljs
[ ]react-native
[ ]expo
TypeORM version:
[ ]
latest
[ ]@next
[x] 0.2.18Steps to reproduce or a small repository showing the problem:
when attempting to use getDatabases() from inside a migration file, the method always returns an empty array []. Migrations against the default Database run fine.
our use case is needing to update 1-n databases for a multi-tenant scenario, we would like to grab all databases from the method and then iterate through each one applying the same migration up/down logic.
example code to reproduce the issue.
`import {MigrationInterface, QueryRunner} from 'typeorm';
export class MigrationOne1564078353345 implements MigrationInterface {
async up(queryRunner: QueryRunner): Promise {
const schemas = await queryRunner.getDatabases();
console.log('#databases = ' + schemas.length);
}
async down(queryRunner: QueryRunner): Promise {
// do stuff here
}
}`
ormconfig
{ name: this.config.get('aws').rdsDatabaseMasterSchema, type: 'mysql', host: this.config.get('aws').rdsDatabaseInstanceEndpoint, port: this.config.get('aws').rdsDatabaseInstancePort, username: this.config.get('aws').rdsDatabaseInstanceUser, password: this.config.get('aws').rdsDatabaseInstanceUserPassword, // TODO: Make this dynamic using roles database: this.config.get('aws').rdsDatabaseMasterSchema, entities: [__dirname + '/../entities/*{.ts,.js}'], synchronize: false, migrationsRun: true, migrationsTableName: 'database_migrations', migrations: [ __dirname + '/../migrations/*{.ts,.js}', ], cli: { entitiesDir: __dirname + '/../entities/', migrationsDir: __dirname + '/../migrations', } };