typeorm 0.3.13-dev.a11809e → 0.3.13-dev.af4f15c
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/driver/postgres/PostgresQueryRunner.js +1 -1
- package/browser/driver/postgres/PostgresQueryRunner.js.map +1 -1
- package/browser/driver/sqlite-abstract/AbstractSqliteDriver.js +0 -7
- package/browser/driver/sqlite-abstract/AbstractSqliteDriver.js.map +1 -1
- package/browser/driver/sqlite-abstract/AbstractSqliteQueryRunner.js +1 -1
- package/browser/driver/sqlite-abstract/AbstractSqliteQueryRunner.js.map +1 -1
- package/browser/entity-schema/EntitySchemaOptions.d.ts +4 -5
- package/browser/entity-schema/EntitySchemaOptions.js.map +1 -1
- package/browser/entity-schema/EntitySchemaTransformer.js +0 -13
- package/browser/entity-schema/EntitySchemaTransformer.js.map +1 -1
- package/browser/find-options/FindOperator.d.ts +0 -2
- package/browser/find-options/FindOperator.js +0 -13
- package/browser/find-options/FindOperator.js.map +1 -1
- package/browser/find-options/FindOptionsUtils.js +15 -45
- package/browser/find-options/FindOptionsUtils.js.map +1 -1
- package/browser/metadata/EmbeddedMetadata.js +3 -3
- package/browser/metadata/EmbeddedMetadata.js.map +1 -1
- package/browser/migration/MigrationExecutor.js +2 -8
- package/browser/migration/MigrationExecutor.js.map +1 -1
- package/browser/persistence/SubjectExecutor.js +6 -6
- package/browser/persistence/SubjectExecutor.js.map +1 -1
- package/browser/query-builder/JoinAttribute.d.ts +0 -4
- package/browser/query-builder/JoinAttribute.js +0 -4
- package/browser/query-builder/JoinAttribute.js.map +1 -1
- package/browser/query-builder/SelectQueryBuilder.d.ts +3 -4
- package/browser/query-builder/SelectQueryBuilder.js +9 -17
- package/browser/query-builder/SelectQueryBuilder.js.map +1 -1
- package/browser/subscriber/Broadcaster.d.ts +6 -6
- package/browser/subscriber/Broadcaster.js +12 -12
- package/browser/subscriber/Broadcaster.js.map +1 -1
- package/driver/postgres/PostgresQueryRunner.js +1 -1
- package/driver/postgres/PostgresQueryRunner.js.map +1 -1
- package/driver/sqlite-abstract/AbstractSqliteDriver.js +0 -7
- package/driver/sqlite-abstract/AbstractSqliteDriver.js.map +1 -1
- package/driver/sqlite-abstract/AbstractSqliteQueryRunner.js +1 -1
- package/driver/sqlite-abstract/AbstractSqliteQueryRunner.js.map +1 -1
- package/entity-schema/EntitySchemaOptions.d.ts +4 -5
- package/entity-schema/EntitySchemaOptions.js.map +1 -1
- package/entity-schema/EntitySchemaTransformer.js +0 -13
- package/entity-schema/EntitySchemaTransformer.js.map +1 -1
- package/find-options/FindOperator.d.ts +0 -2
- package/find-options/FindOperator.js +0 -13
- package/find-options/FindOperator.js.map +1 -1
- package/find-options/FindOptionsUtils.js +16 -46
- package/find-options/FindOptionsUtils.js.map +1 -1
- package/metadata/EmbeddedMetadata.js +3 -3
- package/metadata/EmbeddedMetadata.js.map +1 -1
- package/migration/MigrationExecutor.js +2 -8
- package/migration/MigrationExecutor.js.map +1 -1
- package/package.json +1 -1
- package/persistence/SubjectExecutor.js +6 -6
- package/persistence/SubjectExecutor.js.map +1 -1
- package/query-builder/JoinAttribute.d.ts +0 -4
- package/query-builder/JoinAttribute.js +0 -4
- package/query-builder/JoinAttribute.js.map +1 -1
- package/query-builder/SelectQueryBuilder.d.ts +3 -4
- package/query-builder/SelectQueryBuilder.js +9 -17
- package/query-builder/SelectQueryBuilder.js.map +1 -1
- package/subscriber/Broadcaster.d.ts +6 -6
- package/subscriber/Broadcaster.js +12 -12
- package/subscriber/Broadcaster.js.map +1 -1
- package/browser/entity-schema/EntitySchemaInheritanceOptions.d.ts +0 -11
- package/browser/entity-schema/EntitySchemaInheritanceOptions.js +0 -3
- package/browser/entity-schema/EntitySchemaInheritanceOptions.js.map +0 -1
- package/entity-schema/EntitySchemaInheritanceOptions.d.ts +0 -11
- package/entity-schema/EntitySchemaInheritanceOptions.js +0 -4
- package/entity-schema/EntitySchemaInheritanceOptions.js.map +0 -1
|
@@ -204,7 +204,6 @@ class MigrationExecutor {
|
|
|
204
204
|
// start transaction if its not started yet
|
|
205
205
|
let transactionStartedByUs = false;
|
|
206
206
|
if (this.transaction === "all" && !queryRunner.isTransactionActive) {
|
|
207
|
-
await queryRunner.beforeMigration();
|
|
208
207
|
await queryRunner.startTransaction();
|
|
209
208
|
transactionStartedByUs = true;
|
|
210
209
|
}
|
|
@@ -218,7 +217,6 @@ class MigrationExecutor {
|
|
|
218
217
|
continue;
|
|
219
218
|
}
|
|
220
219
|
if (migration.transaction && !queryRunner.isTransactionActive) {
|
|
221
|
-
await queryRunner.beforeMigration();
|
|
222
220
|
await queryRunner.startTransaction();
|
|
223
221
|
transactionStartedByUs = true;
|
|
224
222
|
}
|
|
@@ -233,10 +231,8 @@ class MigrationExecutor {
|
|
|
233
231
|
// now when migration is executed we need to insert record about it into the database
|
|
234
232
|
await this.insertExecutedMigration(queryRunner, migration);
|
|
235
233
|
// commit transaction if we started it
|
|
236
|
-
if (migration.transaction && transactionStartedByUs)
|
|
234
|
+
if (migration.transaction && transactionStartedByUs)
|
|
237
235
|
await queryRunner.commitTransaction();
|
|
238
|
-
await queryRunner.afterMigration();
|
|
239
|
-
}
|
|
240
236
|
})
|
|
241
237
|
.then(() => {
|
|
242
238
|
// informative log about migration success
|
|
@@ -245,10 +241,8 @@ class MigrationExecutor {
|
|
|
245
241
|
});
|
|
246
242
|
}
|
|
247
243
|
// commit transaction if we started it
|
|
248
|
-
if (this.transaction === "all" && transactionStartedByUs)
|
|
244
|
+
if (this.transaction === "all" && transactionStartedByUs)
|
|
249
245
|
await queryRunner.commitTransaction();
|
|
250
|
-
await queryRunner.afterMigration();
|
|
251
|
-
}
|
|
252
246
|
}
|
|
253
247
|
catch (err) {
|
|
254
248
|
// rollback transaction if we started it
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/migration/MigrationExecutor.ts"],"names":[],"mappings":";;;AAAA,yDAAqD;AAErD,2CAAuC;AAGvC,uEAAmE;AAEnE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CAAC,IAAI,CAAC,WAAW,EAAE;gBACnB,MAAM,WAAW,CAAC,OAAO,EAAE,CAAA;aAC9B;SACJ;IACL,CAAC;CACJ;AA3tBD,8CA2tBC","file":"MigrationExecutor.js","sourcesContent":["import { Table } from \"../schema-builder/table/Table\"\nimport { DataSource } from \"../data-source/DataSource\"\nimport { Migration } from \"./Migration\"\nimport { ObjectLiteral } from \"../common/ObjectLiteral\"\nimport { QueryRunner } from \"../query-runner/QueryRunner\"\nimport { MssqlParameter } from \"../driver/sqlserver/MssqlParameter\"\nimport { MongoQueryRunner } from \"../driver/mongodb/MongoQueryRunner\"\nimport { ForbiddenTransactionModeOverrideError, TypeORMError } from \"../error\"\nimport { InstanceChecker } from \"../util/InstanceChecker\"\n\n/**\n * Executes migrations: runs pending and reverts previously executed migrations.\n */\nexport class MigrationExecutor {\n // -------------------------------------------------------------------------\n // Public Properties\n // -------------------------------------------------------------------------\n\n /**\n * Indicates how migrations should be run in transactions.\n * all: all migrations are run in a single transaction\n * none: all migrations are run without a transaction\n * each: each migration is run in a separate transaction\n */\n transaction: \"all\" | \"none\" | \"each\" = \"all\"\n\n /**\n * Option to fake-run or fake-revert a migration, adding to the\n * executed migrations table, but not actually running it. This feature is\n * useful for when migrations are added after the fact or for\n * interoperability between applications which are desired to each keep\n * a consistent migration history.\n */\n fake: boolean\n\n // -------------------------------------------------------------------------\n // Private Properties\n // -------------------------------------------------------------------------\n\n private readonly migrationsDatabase?: string\n private readonly migrationsSchema?: string\n private readonly migrationsTable: string\n private readonly migrationsTableName: string\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(\n protected connection: DataSource,\n protected queryRunner?: QueryRunner,\n ) {\n const { schema } = this.connection.driver.options as any\n const database = this.connection.driver.database\n this.migrationsDatabase = database\n this.migrationsSchema = schema\n this.migrationsTableName =\n connection.options.migrationsTableName || \"migrations\"\n this.migrationsTable = this.connection.driver.buildTableName(\n this.migrationsTableName,\n schema,\n database,\n )\n }\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Tries to execute a single migration given.\n */\n public async executeMigration(migration: Migration): Promise<Migration> {\n return this.withQueryRunner(async (queryRunner) => {\n await this.createMigrationsTableIfNotExist(queryRunner)\n\n // create typeorm_metadata table if it's not created yet\n const schemaBuilder = this.connection.driver.createSchemaBuilder()\n if (InstanceChecker.isRdbmsSchemaBuilder(schemaBuilder)) {\n await schemaBuilder.createMetadataTableIfNecessary(queryRunner)\n }\n\n await queryRunner.beforeMigration()\n await (migration.instance as any).up(queryRunner)\n await queryRunner.afterMigration()\n await this.insertExecutedMigration(queryRunner, migration)\n\n return migration\n })\n }\n\n /**\n * Returns an array of all migrations.\n */\n public async getAllMigrations(): Promise<Migration[]> {\n return Promise.resolve(this.getMigrations())\n }\n\n /**\n * Returns an array of all executed migrations.\n */\n public async getExecutedMigrations(): Promise<Migration[]> {\n return this.withQueryRunner(async (queryRunner) => {\n await this.createMigrationsTableIfNotExist(queryRunner)\n\n return await this.loadExecutedMigrations(queryRunner)\n })\n }\n\n /**\n * Returns an array of all pending migrations.\n */\n public async getPendingMigrations(): Promise<Migration[]> {\n const allMigrations = await this.getAllMigrations()\n const executedMigrations = await this.getExecutedMigrations()\n\n return allMigrations.filter(\n (migration) =>\n !executedMigrations.find(\n (executedMigration) =>\n executedMigration.name === migration.name,\n ),\n )\n }\n\n /**\n * Inserts an executed migration.\n */\n public insertMigration(migration: Migration): Promise<void> {\n return this.withQueryRunner((q) =>\n this.insertExecutedMigration(q, migration),\n )\n }\n\n /**\n * Deletes an executed migration.\n */\n public deleteMigration(migration: Migration): Promise<void> {\n return this.withQueryRunner((q) =>\n this.deleteExecutedMigration(q, migration),\n )\n }\n\n /**\n * Lists all migrations and whether they have been executed or not\n * returns true if there are unapplied migrations\n */\n async showMigrations(): Promise<boolean> {\n let hasUnappliedMigrations = false\n const queryRunner =\n this.queryRunner || this.connection.createQueryRunner()\n // create migrations table if its not created yet\n await this.createMigrationsTableIfNotExist(queryRunner)\n\n // get all migrations that are executed and saved in the database\n const executedMigrations = await this.loadExecutedMigrations(\n queryRunner,\n )\n\n // get all user's migrations in the source code\n const allMigrations = this.getMigrations()\n\n for (const migration of allMigrations) {\n const executedMigration = executedMigrations.find(\n (executedMigration) =>\n executedMigration.name === migration.name,\n )\n\n if (executedMigration) {\n this.connection.logger.logSchemaBuild(\n `[X] ${executedMigration.id} ${migration.name}`,\n )\n } else {\n hasUnappliedMigrations = true\n this.connection.logger.logSchemaBuild(`[ ] ${migration.name}`)\n }\n }\n\n // if query runner was created by us then release it\n if (!this.queryRunner) {\n await queryRunner.release()\n }\n\n return hasUnappliedMigrations\n }\n\n /**\n * Executes all pending migrations. Pending migrations are migrations that are not yet executed,\n * thus not saved in the database.\n */\n async executePendingMigrations(): Promise<Migration[]> {\n const queryRunner =\n this.queryRunner || this.connection.createQueryRunner()\n // create migrations table if it's not created yet\n await this.createMigrationsTableIfNotExist(queryRunner)\n\n // create the typeorm_metadata table if it's not created yet\n const schemaBuilder = this.connection.driver.createSchemaBuilder()\n if (InstanceChecker.isRdbmsSchemaBuilder(schemaBuilder)) {\n await schemaBuilder.createMetadataTableIfNecessary(queryRunner)\n }\n\n // get all migrations that are executed and saved in the database\n const executedMigrations = await this.loadExecutedMigrations(\n queryRunner,\n )\n\n // get the time when last migration was executed\n let lastTimeExecutedMigration =\n this.getLatestTimestampMigration(executedMigrations)\n\n // get all user's migrations in the source code\n const allMigrations = this.getMigrations()\n\n // variable to store all migrations we did successfully\n const successMigrations: Migration[] = []\n\n // find all migrations that needs to be executed\n const pendingMigrations = allMigrations.filter((migration) => {\n // check if we already have executed migration\n const executedMigration = executedMigrations.find(\n (executedMigration) =>\n executedMigration.name === migration.name,\n )\n if (executedMigration) return false\n\n // migration is new and not executed. now check if its timestamp is correct\n // if (lastTimeExecutedMigration && migration.timestamp < lastTimeExecutedMigration.timestamp)\n // throw new TypeORMError(`New migration found: ${migration.name}, however this migration's timestamp is not valid. Migration's timestamp should not be older then migrations already executed in the database.`);\n\n // every check is passed means that migration was not run yet and we need to run it\n return true\n })\n\n // if no migrations are pending then nothing to do here\n if (!pendingMigrations.length) {\n this.connection.logger.logSchemaBuild(`No migrations are pending`)\n // if query runner was created by us then release it\n if (!this.queryRunner) await queryRunner.release()\n return []\n }\n\n // log information about migration execution\n this.connection.logger.logSchemaBuild(\n `${executedMigrations.length} migrations are already loaded in the database.`,\n )\n this.connection.logger.logSchemaBuild(\n `${allMigrations.length} migrations were found in the source code.`,\n )\n if (lastTimeExecutedMigration)\n this.connection.logger.logSchemaBuild(\n `${\n lastTimeExecutedMigration.name\n } is the last executed migration. It was executed on ${new Date(\n lastTimeExecutedMigration.timestamp,\n ).toString()}.`,\n )\n this.connection.logger.logSchemaBuild(\n `${pendingMigrations.length} migrations are new migrations must be executed.`,\n )\n\n if (this.transaction === \"all\") {\n // If we desire to run all migrations in a single transaction\n // but there is a migration that explicitly overrides the transaction mode\n // then we have to fail since we cannot properly resolve that intent\n // In theory we could support overrides that are set to `true`,\n // however to keep the interface more rigid, we fail those too\n const migrationsOverridingTransactionMode =\n pendingMigrations.filter(\n (migration) =>\n !(migration.instance?.transaction === undefined),\n )\n\n if (migrationsOverridingTransactionMode.length > 0) {\n const error = new ForbiddenTransactionModeOverrideError(\n migrationsOverridingTransactionMode,\n )\n this.connection.logger.logMigration(\n `Migrations failed, error: ${error.message}`,\n )\n throw error\n }\n }\n\n // Set the per-migration defaults for the transaction mode\n // so that we have one centralized place that controls this behavior\n\n // When transaction mode is `each` the default is to run in a transaction\n // When transaction mode is `none` the default is to not run in a transaction\n // When transaction mode is `all` the default is to not run in a transaction\n // since all the migrations are already running in one single transaction\n\n const txModeDefault = {\n each: true,\n none: false,\n all: false,\n }[this.transaction]\n\n for (const migration of pendingMigrations) {\n if (migration.instance) {\n const instanceTx = migration.instance.transaction\n\n if (instanceTx === undefined) {\n migration.transaction = txModeDefault\n } else {\n migration.transaction = instanceTx\n }\n }\n }\n\n // start transaction if its not started yet\n let transactionStartedByUs = false\n if (this.transaction === \"all\" && !queryRunner.isTransactionActive) {\n await queryRunner.beforeMigration()\n await queryRunner.startTransaction()\n transactionStartedByUs = true\n }\n\n // run all pending migrations in a sequence\n try {\n for (const migration of pendingMigrations) {\n if (this.fake) {\n // directly insert migration record into the database if it is fake\n await this.insertExecutedMigration(queryRunner, migration)\n\n // nothing else needs to be done, continue to next migration\n continue\n }\n\n if (migration.transaction && !queryRunner.isTransactionActive) {\n await queryRunner.beforeMigration()\n await queryRunner.startTransaction()\n transactionStartedByUs = true\n }\n\n await migration\n .instance!.up(queryRunner)\n .catch((error) => {\n // informative log about migration failure\n this.connection.logger.logMigration(\n `Migration \"${migration.name}\" failed, error: ${error?.message}`,\n )\n throw error\n })\n .then(async () => {\n // now when migration is executed we need to insert record about it into the database\n await this.insertExecutedMigration(\n queryRunner,\n migration,\n )\n // commit transaction if we started it\n if (migration.transaction && transactionStartedByUs) {\n await queryRunner.commitTransaction()\n await queryRunner.afterMigration()\n }\n })\n .then(() => {\n // informative log about migration success\n successMigrations.push(migration)\n this.connection.logger.logSchemaBuild(\n `Migration ${migration.name} has been ${\n this.fake ? \"(fake)\" : \"\"\n } executed successfully.`,\n )\n })\n }\n\n // commit transaction if we started it\n if (this.transaction === \"all\" && transactionStartedByUs) {\n await queryRunner.commitTransaction()\n await queryRunner.afterMigration()\n }\n } catch (err) {\n // rollback transaction if we started it\n if (transactionStartedByUs) {\n try {\n // we throw original error even if rollback thrown an error\n await queryRunner.rollbackTransaction()\n } catch (rollbackError) {}\n }\n\n throw err\n } finally {\n // if query runner was created by us then release it\n if (!this.queryRunner) await queryRunner.release()\n }\n return successMigrations\n }\n\n /**\n * Reverts last migration that were run.\n */\n async undoLastMigration(): Promise<void> {\n const queryRunner =\n this.queryRunner || this.connection.createQueryRunner()\n\n // create migrations table if it's not created yet\n await this.createMigrationsTableIfNotExist(queryRunner)\n\n // create typeorm_metadata table if it's not created yet\n const schemaBuilder = this.connection.driver.createSchemaBuilder()\n if (InstanceChecker.isRdbmsSchemaBuilder(schemaBuilder)) {\n await schemaBuilder.createMetadataTableIfNecessary(queryRunner)\n }\n\n // get all migrations that are executed and saved in the database\n const executedMigrations = await this.loadExecutedMigrations(\n queryRunner,\n )\n\n // get the time when last migration was executed\n let lastTimeExecutedMigration =\n this.getLatestExecutedMigration(executedMigrations)\n\n // if no migrations found in the database then nothing to revert\n if (!lastTimeExecutedMigration) {\n this.connection.logger.logSchemaBuild(\n `No migrations were found in the database. Nothing to revert!`,\n )\n return\n }\n\n // get all user's migrations in the source code\n const allMigrations = this.getMigrations()\n\n // find the instance of the migration we need to remove\n const migrationToRevert = allMigrations.find(\n (migration) => migration.name === lastTimeExecutedMigration!.name,\n )\n\n // if no migrations found in the database then nothing to revert\n if (!migrationToRevert)\n throw new TypeORMError(\n `No migration ${lastTimeExecutedMigration.name} was found in the source code. Make sure you have this migration in your codebase and its included in the connection options.`,\n )\n\n // log information about migration execution\n this.connection.logger.logSchemaBuild(\n `${executedMigrations.length} migrations are already loaded in the database.`,\n )\n this.connection.logger.logSchemaBuild(\n `${\n lastTimeExecutedMigration.name\n } is the last executed migration. It was executed on ${new Date(\n lastTimeExecutedMigration.timestamp,\n ).toString()}.`,\n )\n this.connection.logger.logSchemaBuild(`Now reverting it...`)\n\n // start transaction if its not started yet\n let transactionStartedByUs = false\n if (this.transaction !== \"none\" && !queryRunner.isTransactionActive) {\n await queryRunner.startTransaction()\n transactionStartedByUs = true\n }\n\n try {\n if (!this.fake) {\n await queryRunner.beforeMigration()\n await migrationToRevert.instance!.down(queryRunner)\n await queryRunner.afterMigration()\n }\n\n await this.deleteExecutedMigration(queryRunner, migrationToRevert)\n this.connection.logger.logSchemaBuild(\n `Migration ${migrationToRevert.name} has been ${\n this.fake ? \"(fake)\" : \"\"\n } reverted successfully.`,\n )\n\n // commit transaction if we started it\n if (transactionStartedByUs) await queryRunner.commitTransaction()\n } catch (err) {\n // rollback transaction if we started it\n if (transactionStartedByUs) {\n try {\n // we throw original error even if rollback thrown an error\n await queryRunner.rollbackTransaction()\n } catch (rollbackError) {}\n }\n\n throw err\n } finally {\n // if query runner was created by us then release it\n if (!this.queryRunner) await queryRunner.release()\n }\n }\n\n // -------------------------------------------------------------------------\n // Protected Methods\n // -------------------------------------------------------------------------\n\n /**\n * Creates table \"migrations\" that will store information about executed migrations.\n */\n protected async createMigrationsTableIfNotExist(\n queryRunner: QueryRunner,\n ): Promise<void> {\n // If driver is mongo no need to create\n if (this.connection.driver.options.type === \"mongodb\") {\n return\n }\n const tableExist = await queryRunner.hasTable(this.migrationsTable) // todo: table name should be configurable\n if (!tableExist) {\n await queryRunner.createTable(\n new Table({\n database: this.migrationsDatabase,\n schema: this.migrationsSchema,\n name: this.migrationsTable,\n columns: [\n {\n name: \"id\",\n type: this.connection.driver.normalizeType({\n type: this.connection.driver.mappedDataTypes\n .migrationId,\n }),\n isGenerated: true,\n generationStrategy: \"increment\",\n isPrimary: true,\n isNullable: false,\n },\n {\n name: \"timestamp\",\n type: this.connection.driver.normalizeType({\n type: this.connection.driver.mappedDataTypes\n .migrationTimestamp,\n }),\n isPrimary: false,\n isNullable: false,\n },\n {\n name: \"name\",\n type: this.connection.driver.normalizeType({\n type: this.connection.driver.mappedDataTypes\n .migrationName,\n }),\n isNullable: false,\n },\n ],\n }),\n )\n }\n }\n\n /**\n * Loads all migrations that were executed and saved into the database (sorts by id).\n */\n protected async loadExecutedMigrations(\n queryRunner: QueryRunner,\n ): Promise<Migration[]> {\n if (this.connection.driver.options.type === \"mongodb\") {\n const mongoRunner = queryRunner as MongoQueryRunner\n return await mongoRunner.databaseConnection\n .db(this.connection.driver.database!)\n .collection(this.migrationsTableName)\n .find<Migration>()\n .sort({ _id: -1 })\n .toArray()\n } else {\n const migrationsRaw: ObjectLiteral[] = await this.connection.manager\n .createQueryBuilder(queryRunner)\n .select()\n .orderBy(this.connection.driver.escape(\"id\"), \"DESC\")\n .from(this.migrationsTable, this.migrationsTableName)\n .getRawMany()\n return migrationsRaw.map((migrationRaw) => {\n return new Migration(\n parseInt(migrationRaw[\"id\"]),\n parseInt(migrationRaw[\"timestamp\"]),\n migrationRaw[\"name\"],\n )\n })\n }\n }\n\n /**\n * Gets all migrations that setup for this connection.\n */\n protected getMigrations(): Migration[] {\n const migrations = this.connection.migrations.map((migration) => {\n const migrationClassName =\n migration.name || (migration.constructor as any).name\n const migrationTimestamp = parseInt(\n migrationClassName.substr(-13),\n 10,\n )\n if (!migrationTimestamp || isNaN(migrationTimestamp)) {\n throw new TypeORMError(\n `${migrationClassName} migration name is wrong. Migration class name should have a JavaScript timestamp appended.`,\n )\n }\n\n return new Migration(\n undefined,\n migrationTimestamp,\n migrationClassName,\n migration,\n )\n })\n\n this.checkForDuplicateMigrations(migrations)\n\n // sort them by timestamp\n return migrations.sort((a, b) => a.timestamp - b.timestamp)\n }\n\n protected checkForDuplicateMigrations(migrations: Migration[]) {\n const migrationNames = migrations.map((migration) => migration.name)\n const duplicates = Array.from(\n new Set(\n migrationNames.filter(\n (migrationName, index) =>\n migrationNames.indexOf(migrationName) < index,\n ),\n ),\n )\n if (duplicates.length > 0) {\n throw Error(`Duplicate migrations: ${duplicates.join(\", \")}`)\n }\n }\n\n /**\n * Finds the latest migration (sorts by timestamp) in the given array of migrations.\n */\n protected getLatestTimestampMigration(\n migrations: Migration[],\n ): Migration | undefined {\n const sortedMigrations = migrations\n .map((migration) => migration)\n .sort((a, b) => (a.timestamp - b.timestamp) * -1)\n return sortedMigrations.length > 0 ? sortedMigrations[0] : undefined\n }\n\n /**\n * Finds the latest migration in the given array of migrations.\n * PRE: Migration array must be sorted by descending id.\n */\n protected getLatestExecutedMigration(\n sortedMigrations: Migration[],\n ): Migration | undefined {\n return sortedMigrations.length > 0 ? sortedMigrations[0] : undefined\n }\n\n /**\n * Inserts new executed migration's data into migrations table.\n */\n protected async insertExecutedMigration(\n queryRunner: QueryRunner,\n migration: Migration,\n ): Promise<void> {\n const values: ObjectLiteral = {}\n if (this.connection.driver.options.type === \"mssql\") {\n values[\"timestamp\"] = new MssqlParameter(\n migration.timestamp,\n this.connection.driver.normalizeType({\n type: this.connection.driver.mappedDataTypes\n .migrationTimestamp,\n }) as any,\n )\n values[\"name\"] = new MssqlParameter(\n migration.name,\n this.connection.driver.normalizeType({\n type: this.connection.driver.mappedDataTypes.migrationName,\n }) as any,\n )\n } else {\n values[\"timestamp\"] = migration.timestamp\n values[\"name\"] = migration.name\n }\n if (this.connection.driver.options.type === \"mongodb\") {\n const mongoRunner = queryRunner as MongoQueryRunner\n await mongoRunner.databaseConnection\n .db(this.connection.driver.database!)\n .collection(this.migrationsTableName)\n .insertOne(values)\n } else {\n const qb = queryRunner.manager.createQueryBuilder()\n await qb\n .insert()\n .into(this.migrationsTable)\n .values(values)\n .execute()\n }\n }\n\n /**\n * Delete previously executed migration's data from the migrations table.\n */\n protected async deleteExecutedMigration(\n queryRunner: QueryRunner,\n migration: Migration,\n ): Promise<void> {\n const conditions: ObjectLiteral = {}\n if (this.connection.driver.options.type === \"mssql\") {\n conditions[\"timestamp\"] = new MssqlParameter(\n migration.timestamp,\n this.connection.driver.normalizeType({\n type: this.connection.driver.mappedDataTypes\n .migrationTimestamp,\n }) as any,\n )\n conditions[\"name\"] = new MssqlParameter(\n migration.name,\n this.connection.driver.normalizeType({\n type: this.connection.driver.mappedDataTypes.migrationName,\n }) as any,\n )\n } else {\n conditions[\"timestamp\"] = migration.timestamp\n conditions[\"name\"] = migration.name\n }\n\n if (this.connection.driver.options.type === \"mongodb\") {\n const mongoRunner = queryRunner as MongoQueryRunner\n await mongoRunner.databaseConnection\n .db(this.connection.driver.database!)\n .collection(this.migrationsTableName)\n .deleteOne(conditions)\n } else {\n const qb = queryRunner.manager.createQueryBuilder()\n await qb\n .delete()\n .from(this.migrationsTable)\n .where(`${qb.escape(\"timestamp\")} = :timestamp`)\n .andWhere(`${qb.escape(\"name\")} = :name`)\n .setParameters(conditions)\n .execute()\n }\n }\n\n protected async withQueryRunner<T extends any>(\n callback: (queryRunner: QueryRunner) => T | Promise<T>,\n ) {\n const queryRunner =\n this.queryRunner || this.connection.createQueryRunner()\n\n try {\n return callback(queryRunner)\n } finally {\n if (!this.queryRunner) {\n await queryRunner.release()\n }\n }\n }\n}\n"],"sourceRoot":".."}
|
|
1
|
+
{"version":3,"sources":["../../src/migration/MigrationExecutor.ts"],"names":[],"mappings":";;;AAAA,yDAAqD;AAErD,2CAAuC;AAGvC,uEAAmE;AAEnE,oCAA8E;AAC9E,6DAAyD;AAEzD;;GAEG;AACH,MAAa,iBAAiB;IA+B1B,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,YACc,UAAsB,EACtB,WAAyB;QADzB,eAAU,GAAV,UAAU,CAAY;QACtB,gBAAW,GAAX,WAAW,CAAc;QApCvC,4EAA4E;QAC5E,oBAAoB;QACpB,4EAA4E;QAE5E;;;;;WAKG;QACH,gBAAW,GAA4B,KAAK,CAAA;QA4BxC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,OAAc,CAAA;QACxD,MAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAA;QAChD,IAAI,CAAC,kBAAkB,GAAG,QAAQ,CAAA;QAClC,IAAI,CAAC,gBAAgB,GAAG,MAAM,CAAA;QAC9B,IAAI,CAAC,mBAAmB;YACpB,UAAU,CAAC,OAAO,CAAC,mBAAmB,IAAI,YAAY,CAAA;QAC1D,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,cAAc,CACxD,IAAI,CAAC,mBAAmB,EACxB,MAAM,EACN,QAAQ,CACX,CAAA;IACL,CAAC;IAED,4EAA4E;IAC5E,iBAAiB;IACjB,4EAA4E;IAE5E;;OAEG;IACI,KAAK,CAAC,gBAAgB,CAAC,SAAoB;QAC9C,OAAO,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,WAAW,EAAE,EAAE;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C,iBAAiB,EAAE,CAAA;QAE3D,IAAI;YACA,OAAO,QAAQ,CAAC,WAAW,CAAC,CAAA;SAC/B;gBAAS;YACN,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;gBACnB,MAAM,WAAW,CAAC,OAAO,EAAE,CAAA;aAC9B;SACJ;IACL,CAAC;CACJ;AArtBD,8CAqtBC","file":"MigrationExecutor.js","sourcesContent":["import { Table } from \"../schema-builder/table/Table\"\nimport { DataSource } from \"../data-source/DataSource\"\nimport { Migration } from \"./Migration\"\nimport { ObjectLiteral } from \"../common/ObjectLiteral\"\nimport { QueryRunner } from \"../query-runner/QueryRunner\"\nimport { MssqlParameter } from \"../driver/sqlserver/MssqlParameter\"\nimport { MongoQueryRunner } from \"../driver/mongodb/MongoQueryRunner\"\nimport { ForbiddenTransactionModeOverrideError, TypeORMError } from \"../error\"\nimport { InstanceChecker } from \"../util/InstanceChecker\"\n\n/**\n * Executes migrations: runs pending and reverts previously executed migrations.\n */\nexport class MigrationExecutor {\n // -------------------------------------------------------------------------\n // Public Properties\n // -------------------------------------------------------------------------\n\n /**\n * Indicates how migrations should be run in transactions.\n * all: all migrations are run in a single transaction\n * none: all migrations are run without a transaction\n * each: each migration is run in a separate transaction\n */\n transaction: \"all\" | \"none\" | \"each\" = \"all\"\n\n /**\n * Option to fake-run or fake-revert a migration, adding to the\n * executed migrations table, but not actually running it. This feature is\n * useful for when migrations are added after the fact or for\n * interoperability between applications which are desired to each keep\n * a consistent migration history.\n */\n fake: boolean\n\n // -------------------------------------------------------------------------\n // Private Properties\n // -------------------------------------------------------------------------\n\n private readonly migrationsDatabase?: string\n private readonly migrationsSchema?: string\n private readonly migrationsTable: string\n private readonly migrationsTableName: string\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(\n protected connection: DataSource,\n protected queryRunner?: QueryRunner,\n ) {\n const { schema } = this.connection.driver.options as any\n const database = this.connection.driver.database\n this.migrationsDatabase = database\n this.migrationsSchema = schema\n this.migrationsTableName =\n connection.options.migrationsTableName || \"migrations\"\n this.migrationsTable = this.connection.driver.buildTableName(\n this.migrationsTableName,\n schema,\n database,\n )\n }\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Tries to execute a single migration given.\n */\n public async executeMigration(migration: Migration): Promise<Migration> {\n return this.withQueryRunner(async (queryRunner) => {\n await this.createMigrationsTableIfNotExist(queryRunner)\n\n // create typeorm_metadata table if it's not created yet\n const schemaBuilder = this.connection.driver.createSchemaBuilder()\n if (InstanceChecker.isRdbmsSchemaBuilder(schemaBuilder)) {\n await schemaBuilder.createMetadataTableIfNecessary(queryRunner)\n }\n\n await queryRunner.beforeMigration()\n await (migration.instance as any).up(queryRunner)\n await queryRunner.afterMigration()\n await this.insertExecutedMigration(queryRunner, migration)\n\n return migration\n })\n }\n\n /**\n * Returns an array of all migrations.\n */\n public async getAllMigrations(): Promise<Migration[]> {\n return Promise.resolve(this.getMigrations())\n }\n\n /**\n * Returns an array of all executed migrations.\n */\n public async getExecutedMigrations(): Promise<Migration[]> {\n return this.withQueryRunner(async (queryRunner) => {\n await this.createMigrationsTableIfNotExist(queryRunner)\n\n return await this.loadExecutedMigrations(queryRunner)\n })\n }\n\n /**\n * Returns an array of all pending migrations.\n */\n public async getPendingMigrations(): Promise<Migration[]> {\n const allMigrations = await this.getAllMigrations()\n const executedMigrations = await this.getExecutedMigrations()\n\n return allMigrations.filter(\n (migration) =>\n !executedMigrations.find(\n (executedMigration) =>\n executedMigration.name === migration.name,\n ),\n )\n }\n\n /**\n * Inserts an executed migration.\n */\n public insertMigration(migration: Migration): Promise<void> {\n return this.withQueryRunner((q) =>\n this.insertExecutedMigration(q, migration),\n )\n }\n\n /**\n * Deletes an executed migration.\n */\n public deleteMigration(migration: Migration): Promise<void> {\n return this.withQueryRunner((q) =>\n this.deleteExecutedMigration(q, migration),\n )\n }\n\n /**\n * Lists all migrations and whether they have been executed or not\n * returns true if there are unapplied migrations\n */\n async showMigrations(): Promise<boolean> {\n let hasUnappliedMigrations = false\n const queryRunner =\n this.queryRunner || this.connection.createQueryRunner()\n // create migrations table if its not created yet\n await this.createMigrationsTableIfNotExist(queryRunner)\n\n // get all migrations that are executed and saved in the database\n const executedMigrations = await this.loadExecutedMigrations(\n queryRunner,\n )\n\n // get all user's migrations in the source code\n const allMigrations = this.getMigrations()\n\n for (const migration of allMigrations) {\n const executedMigration = executedMigrations.find(\n (executedMigration) =>\n executedMigration.name === migration.name,\n )\n\n if (executedMigration) {\n this.connection.logger.logSchemaBuild(\n `[X] ${executedMigration.id} ${migration.name}`,\n )\n } else {\n hasUnappliedMigrations = true\n this.connection.logger.logSchemaBuild(`[ ] ${migration.name}`)\n }\n }\n\n // if query runner was created by us then release it\n if (!this.queryRunner) {\n await queryRunner.release()\n }\n\n return hasUnappliedMigrations\n }\n\n /**\n * Executes all pending migrations. Pending migrations are migrations that are not yet executed,\n * thus not saved in the database.\n */\n async executePendingMigrations(): Promise<Migration[]> {\n const queryRunner =\n this.queryRunner || this.connection.createQueryRunner()\n // create migrations table if it's not created yet\n await this.createMigrationsTableIfNotExist(queryRunner)\n\n // create the typeorm_metadata table if it's not created yet\n const schemaBuilder = this.connection.driver.createSchemaBuilder()\n if (InstanceChecker.isRdbmsSchemaBuilder(schemaBuilder)) {\n await schemaBuilder.createMetadataTableIfNecessary(queryRunner)\n }\n\n // get all migrations that are executed and saved in the database\n const executedMigrations = await this.loadExecutedMigrations(\n queryRunner,\n )\n\n // get the time when last migration was executed\n let lastTimeExecutedMigration =\n this.getLatestTimestampMigration(executedMigrations)\n\n // get all user's migrations in the source code\n const allMigrations = this.getMigrations()\n\n // variable to store all migrations we did successfully\n const successMigrations: Migration[] = []\n\n // find all migrations that needs to be executed\n const pendingMigrations = allMigrations.filter((migration) => {\n // check if we already have executed migration\n const executedMigration = executedMigrations.find(\n (executedMigration) =>\n executedMigration.name === migration.name,\n )\n if (executedMigration) return false\n\n // migration is new and not executed. now check if its timestamp is correct\n // if (lastTimeExecutedMigration && migration.timestamp < lastTimeExecutedMigration.timestamp)\n // throw new TypeORMError(`New migration found: ${migration.name}, however this migration's timestamp is not valid. Migration's timestamp should not be older then migrations already executed in the database.`);\n\n // every check is passed means that migration was not run yet and we need to run it\n return true\n })\n\n // if no migrations are pending then nothing to do here\n if (!pendingMigrations.length) {\n this.connection.logger.logSchemaBuild(`No migrations are pending`)\n // if query runner was created by us then release it\n if (!this.queryRunner) await queryRunner.release()\n return []\n }\n\n // log information about migration execution\n this.connection.logger.logSchemaBuild(\n `${executedMigrations.length} migrations are already loaded in the database.`,\n )\n this.connection.logger.logSchemaBuild(\n `${allMigrations.length} migrations were found in the source code.`,\n )\n if (lastTimeExecutedMigration)\n this.connection.logger.logSchemaBuild(\n `${\n lastTimeExecutedMigration.name\n } is the last executed migration. It was executed on ${new Date(\n lastTimeExecutedMigration.timestamp,\n ).toString()}.`,\n )\n this.connection.logger.logSchemaBuild(\n `${pendingMigrations.length} migrations are new migrations must be executed.`,\n )\n\n if (this.transaction === \"all\") {\n // If we desire to run all migrations in a single transaction\n // but there is a migration that explicitly overrides the transaction mode\n // then we have to fail since we cannot properly resolve that intent\n // In theory we could support overrides that are set to `true`,\n // however to keep the interface more rigid, we fail those too\n const migrationsOverridingTransactionMode =\n pendingMigrations.filter(\n (migration) =>\n !(migration.instance?.transaction === undefined),\n )\n\n if (migrationsOverridingTransactionMode.length > 0) {\n const error = new ForbiddenTransactionModeOverrideError(\n migrationsOverridingTransactionMode,\n )\n this.connection.logger.logMigration(\n `Migrations failed, error: ${error.message}`,\n )\n throw error\n }\n }\n\n // Set the per-migration defaults for the transaction mode\n // so that we have one centralized place that controls this behavior\n\n // When transaction mode is `each` the default is to run in a transaction\n // When transaction mode is `none` the default is to not run in a transaction\n // When transaction mode is `all` the default is to not run in a transaction\n // since all the migrations are already running in one single transaction\n\n const txModeDefault = {\n each: true,\n none: false,\n all: false,\n }[this.transaction]\n\n for (const migration of pendingMigrations) {\n if (migration.instance) {\n const instanceTx = migration.instance.transaction\n\n if (instanceTx === undefined) {\n migration.transaction = txModeDefault\n } else {\n migration.transaction = instanceTx\n }\n }\n }\n\n // start transaction if its not started yet\n let transactionStartedByUs = false\n if (this.transaction === \"all\" && !queryRunner.isTransactionActive) {\n await queryRunner.startTransaction()\n transactionStartedByUs = true\n }\n\n // run all pending migrations in a sequence\n try {\n for (const migration of pendingMigrations) {\n if (this.fake) {\n // directly insert migration record into the database if it is fake\n await this.insertExecutedMigration(queryRunner, migration)\n\n // nothing else needs to be done, continue to next migration\n continue\n }\n\n if (migration.transaction && !queryRunner.isTransactionActive) {\n await queryRunner.startTransaction()\n transactionStartedByUs = true\n }\n\n await migration\n .instance!.up(queryRunner)\n .catch((error) => {\n // informative log about migration failure\n this.connection.logger.logMigration(\n `Migration \"${migration.name}\" failed, error: ${error?.message}`,\n )\n throw error\n })\n .then(async () => {\n // now when migration is executed we need to insert record about it into the database\n await this.insertExecutedMigration(\n queryRunner,\n migration,\n )\n // commit transaction if we started it\n if (migration.transaction && transactionStartedByUs)\n await queryRunner.commitTransaction()\n })\n .then(() => {\n // informative log about migration success\n successMigrations.push(migration)\n this.connection.logger.logSchemaBuild(\n `Migration ${migration.name} has been ${\n this.fake ? \"(fake)\" : \"\"\n } executed successfully.`,\n )\n })\n }\n\n // commit transaction if we started it\n if (this.transaction === \"all\" && transactionStartedByUs)\n await queryRunner.commitTransaction()\n } catch (err) {\n // rollback transaction if we started it\n if (transactionStartedByUs) {\n try {\n // we throw original error even if rollback thrown an error\n await queryRunner.rollbackTransaction()\n } catch (rollbackError) {}\n }\n\n throw err\n } finally {\n // if query runner was created by us then release it\n if (!this.queryRunner) await queryRunner.release()\n }\n return successMigrations\n }\n\n /**\n * Reverts last migration that were run.\n */\n async undoLastMigration(): Promise<void> {\n const queryRunner =\n this.queryRunner || this.connection.createQueryRunner()\n\n // create migrations table if it's not created yet\n await this.createMigrationsTableIfNotExist(queryRunner)\n\n // create typeorm_metadata table if it's not created yet\n const schemaBuilder = this.connection.driver.createSchemaBuilder()\n if (InstanceChecker.isRdbmsSchemaBuilder(schemaBuilder)) {\n await schemaBuilder.createMetadataTableIfNecessary(queryRunner)\n }\n\n // get all migrations that are executed and saved in the database\n const executedMigrations = await this.loadExecutedMigrations(\n queryRunner,\n )\n\n // get the time when last migration was executed\n let lastTimeExecutedMigration =\n this.getLatestExecutedMigration(executedMigrations)\n\n // if no migrations found in the database then nothing to revert\n if (!lastTimeExecutedMigration) {\n this.connection.logger.logSchemaBuild(\n `No migrations were found in the database. Nothing to revert!`,\n )\n return\n }\n\n // get all user's migrations in the source code\n const allMigrations = this.getMigrations()\n\n // find the instance of the migration we need to remove\n const migrationToRevert = allMigrations.find(\n (migration) => migration.name === lastTimeExecutedMigration!.name,\n )\n\n // if no migrations found in the database then nothing to revert\n if (!migrationToRevert)\n throw new TypeORMError(\n `No migration ${lastTimeExecutedMigration.name} was found in the source code. Make sure you have this migration in your codebase and its included in the connection options.`,\n )\n\n // log information about migration execution\n this.connection.logger.logSchemaBuild(\n `${executedMigrations.length} migrations are already loaded in the database.`,\n )\n this.connection.logger.logSchemaBuild(\n `${\n lastTimeExecutedMigration.name\n } is the last executed migration. It was executed on ${new Date(\n lastTimeExecutedMigration.timestamp,\n ).toString()}.`,\n )\n this.connection.logger.logSchemaBuild(`Now reverting it...`)\n\n // start transaction if its not started yet\n let transactionStartedByUs = false\n if (this.transaction !== \"none\" && !queryRunner.isTransactionActive) {\n await queryRunner.startTransaction()\n transactionStartedByUs = true\n }\n\n try {\n if (!this.fake) {\n await queryRunner.beforeMigration()\n await migrationToRevert.instance!.down(queryRunner)\n await queryRunner.afterMigration()\n }\n\n await this.deleteExecutedMigration(queryRunner, migrationToRevert)\n this.connection.logger.logSchemaBuild(\n `Migration ${migrationToRevert.name} has been ${\n this.fake ? \"(fake)\" : \"\"\n } reverted successfully.`,\n )\n\n // commit transaction if we started it\n if (transactionStartedByUs) await queryRunner.commitTransaction()\n } catch (err) {\n // rollback transaction if we started it\n if (transactionStartedByUs) {\n try {\n // we throw original error even if rollback thrown an error\n await queryRunner.rollbackTransaction()\n } catch (rollbackError) {}\n }\n\n throw err\n } finally {\n // if query runner was created by us then release it\n if (!this.queryRunner) await queryRunner.release()\n }\n }\n\n // -------------------------------------------------------------------------\n // Protected Methods\n // -------------------------------------------------------------------------\n\n /**\n * Creates table \"migrations\" that will store information about executed migrations.\n */\n protected async createMigrationsTableIfNotExist(\n queryRunner: QueryRunner,\n ): Promise<void> {\n // If driver is mongo no need to create\n if (this.connection.driver.options.type === \"mongodb\") {\n return\n }\n const tableExist = await queryRunner.hasTable(this.migrationsTable) // todo: table name should be configurable\n if (!tableExist) {\n await queryRunner.createTable(\n new Table({\n database: this.migrationsDatabase,\n schema: this.migrationsSchema,\n name: this.migrationsTable,\n columns: [\n {\n name: \"id\",\n type: this.connection.driver.normalizeType({\n type: this.connection.driver.mappedDataTypes\n .migrationId,\n }),\n isGenerated: true,\n generationStrategy: \"increment\",\n isPrimary: true,\n isNullable: false,\n },\n {\n name: \"timestamp\",\n type: this.connection.driver.normalizeType({\n type: this.connection.driver.mappedDataTypes\n .migrationTimestamp,\n }),\n isPrimary: false,\n isNullable: false,\n },\n {\n name: \"name\",\n type: this.connection.driver.normalizeType({\n type: this.connection.driver.mappedDataTypes\n .migrationName,\n }),\n isNullable: false,\n },\n ],\n }),\n )\n }\n }\n\n /**\n * Loads all migrations that were executed and saved into the database (sorts by id).\n */\n protected async loadExecutedMigrations(\n queryRunner: QueryRunner,\n ): Promise<Migration[]> {\n if (this.connection.driver.options.type === \"mongodb\") {\n const mongoRunner = queryRunner as MongoQueryRunner\n return await mongoRunner.databaseConnection\n .db(this.connection.driver.database!)\n .collection(this.migrationsTableName)\n .find<Migration>()\n .sort({ _id: -1 })\n .toArray()\n } else {\n const migrationsRaw: ObjectLiteral[] = await this.connection.manager\n .createQueryBuilder(queryRunner)\n .select()\n .orderBy(this.connection.driver.escape(\"id\"), \"DESC\")\n .from(this.migrationsTable, this.migrationsTableName)\n .getRawMany()\n return migrationsRaw.map((migrationRaw) => {\n return new Migration(\n parseInt(migrationRaw[\"id\"]),\n parseInt(migrationRaw[\"timestamp\"]),\n migrationRaw[\"name\"],\n )\n })\n }\n }\n\n /**\n * Gets all migrations that setup for this connection.\n */\n protected getMigrations(): Migration[] {\n const migrations = this.connection.migrations.map((migration) => {\n const migrationClassName =\n migration.name || (migration.constructor as any).name\n const migrationTimestamp = parseInt(\n migrationClassName.substr(-13),\n 10,\n )\n if (!migrationTimestamp || isNaN(migrationTimestamp)) {\n throw new TypeORMError(\n `${migrationClassName} migration name is wrong. Migration class name should have a JavaScript timestamp appended.`,\n )\n }\n\n return new Migration(\n undefined,\n migrationTimestamp,\n migrationClassName,\n migration,\n )\n })\n\n this.checkForDuplicateMigrations(migrations)\n\n // sort them by timestamp\n return migrations.sort((a, b) => a.timestamp - b.timestamp)\n }\n\n protected checkForDuplicateMigrations(migrations: Migration[]) {\n const migrationNames = migrations.map((migration) => migration.name)\n const duplicates = Array.from(\n new Set(\n migrationNames.filter(\n (migrationName, index) =>\n migrationNames.indexOf(migrationName) < index,\n ),\n ),\n )\n if (duplicates.length > 0) {\n throw Error(`Duplicate migrations: ${duplicates.join(\", \")}`)\n }\n }\n\n /**\n * Finds the latest migration (sorts by timestamp) in the given array of migrations.\n */\n protected getLatestTimestampMigration(\n migrations: Migration[],\n ): Migration | undefined {\n const sortedMigrations = migrations\n .map((migration) => migration)\n .sort((a, b) => (a.timestamp - b.timestamp) * -1)\n return sortedMigrations.length > 0 ? sortedMigrations[0] : undefined\n }\n\n /**\n * Finds the latest migration in the given array of migrations.\n * PRE: Migration array must be sorted by descending id.\n */\n protected getLatestExecutedMigration(\n sortedMigrations: Migration[],\n ): Migration | undefined {\n return sortedMigrations.length > 0 ? sortedMigrations[0] : undefined\n }\n\n /**\n * Inserts new executed migration's data into migrations table.\n */\n protected async insertExecutedMigration(\n queryRunner: QueryRunner,\n migration: Migration,\n ): Promise<void> {\n const values: ObjectLiteral = {}\n if (this.connection.driver.options.type === \"mssql\") {\n values[\"timestamp\"] = new MssqlParameter(\n migration.timestamp,\n this.connection.driver.normalizeType({\n type: this.connection.driver.mappedDataTypes\n .migrationTimestamp,\n }) as any,\n )\n values[\"name\"] = new MssqlParameter(\n migration.name,\n this.connection.driver.normalizeType({\n type: this.connection.driver.mappedDataTypes.migrationName,\n }) as any,\n )\n } else {\n values[\"timestamp\"] = migration.timestamp\n values[\"name\"] = migration.name\n }\n if (this.connection.driver.options.type === \"mongodb\") {\n const mongoRunner = queryRunner as MongoQueryRunner\n await mongoRunner.databaseConnection\n .db(this.connection.driver.database!)\n .collection(this.migrationsTableName)\n .insertOne(values)\n } else {\n const qb = queryRunner.manager.createQueryBuilder()\n await qb\n .insert()\n .into(this.migrationsTable)\n .values(values)\n .execute()\n }\n }\n\n /**\n * Delete previously executed migration's data from the migrations table.\n */\n protected async deleteExecutedMigration(\n queryRunner: QueryRunner,\n migration: Migration,\n ): Promise<void> {\n const conditions: ObjectLiteral = {}\n if (this.connection.driver.options.type === \"mssql\") {\n conditions[\"timestamp\"] = new MssqlParameter(\n migration.timestamp,\n this.connection.driver.normalizeType({\n type: this.connection.driver.mappedDataTypes\n .migrationTimestamp,\n }) as any,\n )\n conditions[\"name\"] = new MssqlParameter(\n migration.name,\n this.connection.driver.normalizeType({\n type: this.connection.driver.mappedDataTypes.migrationName,\n }) as any,\n )\n } else {\n conditions[\"timestamp\"] = migration.timestamp\n conditions[\"name\"] = migration.name\n }\n\n if (this.connection.driver.options.type === \"mongodb\") {\n const mongoRunner = queryRunner as MongoQueryRunner\n await mongoRunner.databaseConnection\n .db(this.connection.driver.database!)\n .collection(this.migrationsTableName)\n .deleteOne(conditions)\n } else {\n const qb = queryRunner.manager.createQueryBuilder()\n await qb\n .delete()\n .from(this.migrationsTable)\n .where(`${qb.escape(\"timestamp\")} = :timestamp`)\n .andWhere(`${qb.escape(\"name\")} = :name`)\n .setParameters(conditions)\n .execute()\n }\n }\n\n protected async withQueryRunner<T extends any>(\n callback: (queryRunner: QueryRunner) => T | Promise<T>,\n ) {\n const queryRunner =\n this.queryRunner || this.connection.createQueryRunner()\n\n try {\n return callback(queryRunner)\n } finally {\n if (!this.queryRunner) {\n await queryRunner.release()\n }\n }\n }\n}\n"],"sourceRoot":".."}
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{ "name": "typeorm", "private": false, "version": "0.3.13-dev.
|
|
1
|
+
{ "name": "typeorm", "private": false, "version": "0.3.13-dev.af4f15c", "description": "Data-Mapper ORM for TypeScript, ES7, ES6, ES5. Supports MySQL, PostgreSQL, MariaDB, SQLite, MS SQL Server, Oracle, MongoDB databases.", "license": "MIT", "readmeFilename": "README.md", "author": { "name": "Umed Khudoiberdiev", "email": "pleerock.me@gmail.com" }, "engines": { "node": ">= 12.9.0" }, "exports": { ".": { "types": "./index.d.ts", "node": { "import": "./index.mjs", "require": "./index.js", "types": "./index.d.ts" }, "browser": { "require": "./index.js", "import": "./browser/index.js", "default": "./index.js" } }, "./browser": { "types": "./index.d.ts", "default": "./browser/index.js" }, "./*.js": "./*.js", "./*": { "require": "./*.js", "import": "./*" } }, "main": "./index.js", "module": "./index.mjs", "types": "./index.d.ts", "browser": { "./browser/connection/ConnectionOptionsReader.js": "./browser/platform/BrowserConnectionOptionsReaderDummy.js", "./browser/connection/options-reader/ConnectionOptionsXmlReader.js": "./browser/platform/BrowserConnectionOptionsReaderDummy.js", "./browser/connection/options-reader/ConnectionOptionsYmlReader.js": "./browser/platform/BrowserConnectionOptionsReaderDummy.js", "./browser/driver/aurora-data-api/AuroraDataApiDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/better-sqlite3/BetterSqlite3Driver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/cockroachdb/CockroachDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/mongodb/MongoDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/mongodb/MongoQueryRunner.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/mysql/MysqlDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/oracle/OracleDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/postgres/PostgresDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/sap/SapDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/sqlite/SqliteDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/sqlserver/SqlServerDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/entity-manager/MongoEntityManager.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/logger/FileLogger.js": "./browser/platform/BrowserFileLoggerDummy.js", "./browser/platform/PlatformTools.js": "./browser/platform/BrowserPlatformTools.js", "./browser/repository/MongoRepository.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/util/DirectoryExportedClassesLoader.js": "./browser/platform/BrowserDirectoryExportedClassesLoader.js", "./index.js": "./browser/index.js", "./index.mjs": "./browser/index.js" }, "repository": { "type": "git", "url": "https://github.com/typeorm/typeorm.git" }, "bugs": { "url": "https://github.com/typeorm/typeorm/issues" }, "homepage": "https://typeorm.io", "tags": [ "orm", "typescript", "typescript-orm", "mysql", "mysql-orm", "postgresql", "postgresql-orm", "mariadb", "mariadb-orm", "spanner", "sqlite", "sqlite-orm", "sql-server", "sql-server-orm", "oracle", "oracle-orm", "cloud-spanner", "cloud-spanner-orm" ], "devDependencies": { "@types/app-root-path": "^1.2.4", "@types/chai": "^4.3.4", "@types/chai-as-promised": "^7.1.5", "@types/debug": "^4.1.7", "@types/js-yaml": "^4.0.5", "@types/mkdirp": "^1.0.2", "@types/mocha": "^10.0.1", "@types/node": "^18.13.0", "@types/sha.js": "^2.4.0", "@types/sinon": "^10.0.13", "@types/source-map-support": "^0.5.6", "@types/uuid": "^9.0.0", "@types/xml2js": "^0.4.11", "@types/yargs": "^17.0.22", "better-sqlite3": "^8.1.0", "chai": "^4.3.7", "chai-as-promised": "^7.1.1", "class-transformer": "^0.5.1", "conventional-changelog-angular": "^5.0.13", "conventional-changelog-cli": "^2.2.2", "del": "6.1.1", "gulp": "^4.0.2", "gulp-istanbul": "^1.1.3", "gulp-mocha": "^8.0.0", "gulp-rename": "^2.0.0", "gulp-replace": "^1.1.4", "gulp-shell": "^0.8.0", "gulp-sourcemaps": "^3.0.0", "gulp-typescript": "^6.0.0-alpha.1", "gulpclass": "^0.2.0", "husky": "^8.0.3", "mocha": "^10.2.0", "mongodb": "^3.7.3", "mssql": "^9.1.1", "mysql": "^2.18.1", "mysql2": "^3.1.1", "pg": "^8.9.0", "pg-query-stream": "^4.3.0", "prettier": "^2.8.3", "redis": "^4.6.4", "remap-istanbul": "^0.13.0", "rimraf": "^4.1.2", "sinon": "^15.0.1", "sinon-chai": "^3.7.0", "source-map-support": "^0.5.21", "sql.js": "^1.8.0", "sqlite3": "^5.1.4", "ts-node": "^10.9.1", "typeorm-aurora-data-api-driver": "^2.4.4", "typescript": "^4.9.5" }, "peerDependencies": { "@google-cloud/spanner": "^5.18.0", "@sap/hana-client": "^2.12.25", "better-sqlite3": "^7.1.2 || ^8.0.0", "hdb-pool": "^0.1.6", "ioredis": "^5.0.4", "mongodb": "^3.6.0", "mssql": "^9.1.1", "mysql2": "^2.2.5 || ^3.0.1", "oracledb": "^5.1.0", "pg": "^8.5.1", "pg-native": "^3.0.0", "pg-query-stream": "^4.0.0", "redis": "^3.1.1 || ^4.0.0", "sql.js": "^1.4.0", "sqlite3": "^5.0.3", "ts-node": "^10.7.0", "typeorm-aurora-data-api-driver": "^2.0.0" }, "peerDependenciesMeta": { "@google-cloud/spanner": { "optional": true }, "@sap/hana-client": { "optional": true }, "better-sqlite3": { "optional": true }, "hdb-pool": { "optional": true }, "ioredis": { "optional": true }, "mongodb": { "optional": true }, "mssql": { "optional": true }, "mysql2": { "optional": true }, "oracledb": { "optional": true }, "pg": { "optional": true }, "pg-native": { "optional": true }, "pg-query-stream": { "optional": true }, "redis": { "optional": true }, "sql.js": { "optional": true }, "sqlite3": { "optional": true }, "ts-node": { "optional": true }, "typeorm-aurora-data-api-driver": { "optional": true } }, "dependencies": { "@sqltools/formatter": "^1.2.5", "app-root-path": "^3.1.0", "buffer": "^6.0.3", "chalk": "^4.1.2", "cli-highlight": "^2.1.11", "debug": "^4.3.4", "dotenv": "^16.0.3", "glob": "^8.1.0", "js-yaml": "^4.1.0", "mkdirp": "^2.1.3", "reflect-metadata": "^0.1.13", "sha.js": "^2.4.11", "tslib": "^2.5.0", "uuid": "^9.0.0", "xml2js": "^0.4.23", "yargs": "^17.6.2" }, "scripts": { "test": "rimraf ./build && tsc && mocha --file ./build/compiled/test/utils/test-setup.js --bail --recursive --timeout 60000 ./build/compiled/test", "test-fast": "mocha --file ./build/compiled/test/utils/test-setup.js --bail --recursive --timeout 60000 ./build/compiled/test", "compile": "rimraf ./build && tsc", "watch": "./node_modules/.bin/tsc -w", "package": "gulp package", "pack": "gulp pack", "lint": "prettier --check \"./src/**/*.ts\" \"./test/**/*.ts\" \"./sample/**/*.ts\"", "format": "prettier --write \"./src/**/*.ts\" \"./test/**/*.ts\" \"./sample/**/*.ts\"", "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 2" }, "bin": { "typeorm": "./cli.js", "typeorm-ts-node-commonjs": "./cli-ts-node-commonjs.js", "typeorm-ts-node-esm": "./cli-ts-node-esm.js" }, "funding": "https://opencollective.com/typeorm", "collective": { "type": "opencollective", "url": "https://opencollective.com/typeorm", "logo": "https://opencollective.com/opencollective/logo.txt" }, "nyc": { "all": true, "cache": false, "exclude": [ "**/*.d.ts" ], "extension": [ ".ts" ], "include": [ "build/compiled/src/**", "src/**" ], "reporter": "json" } }
|
|
@@ -164,11 +164,11 @@ class SubjectExecutor {
|
|
|
164
164
|
if (this.updateSubjects.length)
|
|
165
165
|
this.updateSubjects.forEach((subject) => this.queryRunner.broadcaster.broadcastBeforeUpdateEvent(result, subject.metadata, subject.entity, subject.databaseEntity, subject.diffColumns, subject.diffRelations));
|
|
166
166
|
if (this.removeSubjects.length)
|
|
167
|
-
this.removeSubjects.forEach((subject) => this.queryRunner.broadcaster.broadcastBeforeRemoveEvent(result, subject.metadata, subject.entity, subject.databaseEntity
|
|
167
|
+
this.removeSubjects.forEach((subject) => this.queryRunner.broadcaster.broadcastBeforeRemoveEvent(result, subject.metadata, subject.entity, subject.databaseEntity));
|
|
168
168
|
if (this.softRemoveSubjects.length)
|
|
169
|
-
this.softRemoveSubjects.forEach((subject) => this.queryRunner.broadcaster.broadcastBeforeSoftRemoveEvent(result, subject.metadata, subject.entity, subject.databaseEntity
|
|
169
|
+
this.softRemoveSubjects.forEach((subject) => this.queryRunner.broadcaster.broadcastBeforeSoftRemoveEvent(result, subject.metadata, subject.entity, subject.databaseEntity));
|
|
170
170
|
if (this.recoverSubjects.length)
|
|
171
|
-
this.recoverSubjects.forEach((subject) => this.queryRunner.broadcaster.broadcastBeforeRecoverEvent(result, subject.metadata, subject.entity, subject.databaseEntity
|
|
171
|
+
this.recoverSubjects.forEach((subject) => this.queryRunner.broadcaster.broadcastBeforeRecoverEvent(result, subject.metadata, subject.entity, subject.databaseEntity));
|
|
172
172
|
return result;
|
|
173
173
|
}
|
|
174
174
|
/**
|
|
@@ -183,11 +183,11 @@ class SubjectExecutor {
|
|
|
183
183
|
if (this.updateSubjects.length)
|
|
184
184
|
this.updateSubjects.forEach((subject) => this.queryRunner.broadcaster.broadcastAfterUpdateEvent(result, subject.metadata, subject.entity, subject.databaseEntity, subject.diffColumns, subject.diffRelations));
|
|
185
185
|
if (this.removeSubjects.length)
|
|
186
|
-
this.removeSubjects.forEach((subject) => this.queryRunner.broadcaster.broadcastAfterRemoveEvent(result, subject.metadata, subject.entity, subject.databaseEntity
|
|
186
|
+
this.removeSubjects.forEach((subject) => this.queryRunner.broadcaster.broadcastAfterRemoveEvent(result, subject.metadata, subject.entity, subject.databaseEntity));
|
|
187
187
|
if (this.softRemoveSubjects.length)
|
|
188
|
-
this.softRemoveSubjects.forEach((subject) => this.queryRunner.broadcaster.broadcastAfterSoftRemoveEvent(result, subject.metadata, subject.entity, subject.databaseEntity
|
|
188
|
+
this.softRemoveSubjects.forEach((subject) => this.queryRunner.broadcaster.broadcastAfterSoftRemoveEvent(result, subject.metadata, subject.entity, subject.databaseEntity));
|
|
189
189
|
if (this.recoverSubjects.length)
|
|
190
|
-
this.recoverSubjects.forEach((subject) => this.queryRunner.broadcaster.broadcastAfterRecoverEvent(result, subject.metadata, subject.entity, subject.databaseEntity
|
|
190
|
+
this.recoverSubjects.forEach((subject) => this.queryRunner.broadcaster.broadcastAfterRecoverEvent(result, subject.metadata, subject.entity, subject.databaseEntity));
|
|
191
191
|
return result;
|
|
192
192
|
}
|
|
193
193
|
/**
|