typeorm 0.3.22-dev.bcaa0bf → 0.3.22-dev.c3bebdc

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.
@@ -238,7 +238,7 @@ export class MigrationExecutor {
238
238
  .then(() => {
239
239
  // informative log about migration success
240
240
  successMigrations.push(migration);
241
- this.connection.logger.logSchemaBuild(`Migration ${migration.name} has been ${this.fake ? "(fake)" : ""} executed successfully.`);
241
+ this.connection.logger.logSchemaBuild(`Migration ${migration.name} has been ${this.fake ? "(fake) " : ""}executed successfully.`);
242
242
  });
243
243
  }
244
244
  // commit transaction if we started it
@@ -310,7 +310,7 @@ export class MigrationExecutor {
310
310
  await queryRunner.afterMigration();
311
311
  }
312
312
  await this.deleteExecutedMigration(queryRunner, migrationToRevert);
313
- this.connection.logger.logSchemaBuild(`Migration ${migrationToRevert.name} has been ${this.fake ? "(fake)" : ""} reverted successfully.`);
313
+ this.connection.logger.logSchemaBuild(`Migration ${migrationToRevert.name} has been ${this.fake ? "(fake) " : ""}reverted successfully.`);
314
314
  // commit transaction if we started it
315
315
  if (transactionStartedByUs)
316
316
  await queryRunner.commitTransaction();
@@ -1 +1 @@
1
- {"version":3,"sources":["../browser/src/migration/MigrationExecutor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,+BAA+B,CAAA;AAErD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAGvC,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAA;AAEnE,OAAO,EAAE,qCAAqC,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAC9E,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAEzD;;GAEG;AACH,MAAM,OAAO,iBAAiB;IA+B1B,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,YACc,UAAsB,EACtB,WAAyB;QADzB,eAAU,GAAV,UAAU,CAAY;QACtB,gBAAW,GAAX,WA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;QAClB,CAAC;IACL,CAAC;IAES,KAAK,CAAC,eAAe,CAC3B,QAAsD;QAEtD,MAAM,WAAW,GACb,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,UAAU,CAAC,iBAAiB,EAAE,CAAA;QAE3D,IAAI,CAAC;YACD,OAAO,MAAM,QAAQ,CAAC,WAAW,CAAC,CAAA;QACtC,CAAC;gBAAS,CAAC;YACP,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;gBACpB,MAAM,WAAW,CAAC,OAAO,EAAE,CAAA;YAC/B,CAAC;QACL,CAAC;IACL,CAAC;CACJ","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 const 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 const 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 mongoRunner\n .cursor(this.migrationsTableName, {})\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 await callback(queryRunner)\n } finally {\n if (!this.queryRunner) {\n await queryRunner.release()\n }\n }\n }\n}\n"],"sourceRoot":".."}
1
+ {"version":3,"sources":["../browser/src/migration/MigrationExecutor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,+BAA+B,CAAA;AAErD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAGvC,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAA;AAEnE,OAAO,EAAE,qCAAqC,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAC9E,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAEzD;;GAEG;AACH,MAAM,OAAO,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,GA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,CAAC;QACL,CAAC;IACL,CAAC;CACJ","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 const 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 const 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 mongoRunner\n .cursor(this.migrationsTableName, {})\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 await callback(queryRunner)\n } finally {\n if (!this.queryRunner) {\n await queryRunner.release()\n }\n }\n }\n}\n"],"sourceRoot":".."}
@@ -241,7 +241,7 @@ class MigrationExecutor {
241
241
  .then(() => {
242
242
  // informative log about migration success
243
243
  successMigrations.push(migration);
244
- this.connection.logger.logSchemaBuild(`Migration ${migration.name} has been ${this.fake ? "(fake)" : ""} executed successfully.`);
244
+ this.connection.logger.logSchemaBuild(`Migration ${migration.name} has been ${this.fake ? "(fake) " : ""}executed successfully.`);
245
245
  });
246
246
  }
247
247
  // commit transaction if we started it
@@ -313,7 +313,7 @@ class MigrationExecutor {
313
313
  await queryRunner.afterMigration();
314
314
  }
315
315
  await this.deleteExecutedMigration(queryRunner, migrationToRevert);
316
- this.connection.logger.logSchemaBuild(`Migration ${migrationToRevert.name} has been ${this.fake ? "(fake)" : ""} reverted successfully.`);
316
+ this.connection.logger.logSchemaBuild(`Migration ${migrationToRevert.name} has been ${this.fake ? "(fake) " : ""}reverted successfully.`);
317
317
  // commit transaction if we started it
318
318
  if (transactionStartedByUs)
319
319
  await queryRunner.commitTransaction();
@@ -1 +1 @@
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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CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;gBACpB,MAAM,WAAW,CAAC,OAAO,EAAE,CAAA;YAC/B,CAAC;QACL,CAAC;IACL,CAAC;CACJ;AAztBD,8CAytBC","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 const 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 const 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 mongoRunner\n .cursor(this.migrationsTableName, {})\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 await 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;YAC9C,MAAM,IAAI,CAAC,+BA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AC;iBACpC,UAAU,CAAC,IAAI,CAAC,mBAAmB,CAAC;iBACpC,SAAS,CAAC,UAAU,CAAC,CAAA;QAC9B,CAAC;aAAM,CAAC;YACJ,MAAM,EAAE,GAAG,WAAW,CAAC,OAAO,CAAC,kBAAkB,EAAE,CAAA;YACnD,MAAM,EAAE;iBACH,MAAM,EAAE;iBACR,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC;iBAC1B,KAAK,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,eAAe,CAAC;iBAC/C,QAAQ,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC;iBACxC,aAAa,CAAC,UAAU,CAAC;iBACzB,OAAO,EAAE,CAAA;QAClB,CAAC;IACL,CAAC;IAES,KAAK,CAAC,eAAe,CAC3B,QAAsD;QAEtD,MAAM,WAAW,GACb,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,UAAU,CAAC,iBAAiB,EAAE,CAAA;QAE3D,IAAI,CAAC;YACD,OAAO,MAAM,QAAQ,CAAC,WAAW,CAAC,CAAA;QACtC,CAAC;gBAAS,CAAC;YACP,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;gBACpB,MAAM,WAAW,CAAC,OAAO,EAAE,CAAA;YAC/B,CAAC;QACL,CAAC;IACL,CAAC;CACJ;AAztBD,8CAytBC","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 const 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 const 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 mongoRunner\n .cursor(this.migrationsTableName, {})\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 await 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", "version": "0.3.22-dev.bcaa0bf", "private": false, "description": "Data-Mapper ORM for TypeScript and ES2021+. Supports MySQL/MariaDB, PostgreSQL, MS SQL Server, Oracle, SAP HANA, SQLite, MongoDB databases.", "homepage": "https://typeorm.io", "bugs": { "url": "https://github.com/typeorm/typeorm/issues" }, "repository": { "type": "git", "url": "https://github.com/typeorm/typeorm.git" }, "funding": "https://opencollective.com/typeorm", "license": "MIT", "author": { "name": "Umed Khudoiberdiev", "email": "pleerock.me@gmail.com" }, "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", "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/mongodb/bson.typings.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/mongodb/typings.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" }, "types": "./index.d.ts", "bin": { "typeorm": "./cli.js", "typeorm-ts-node-commonjs": "./cli-ts-node-commonjs.js", "typeorm-ts-node-esm": "./cli-ts-node-esm.js" }, "scripts": { "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 1", "compile": "rimraf ./build && tsc", "format": "prettier --cache --write \"./**/*.ts\"", "format:ci": "prettier --check \"./**/*.ts\"", "lint": "eslint .", "pack": "gulp pack", "package": "gulp package", "test": "npm run compile && npm run test:fast --", "test:ci": "mocha --bail", "test:fast": "mocha", "watch": "tsc --watch" }, "dependencies": { "@sqltools/formatter": "^1.2.5", "ansis": "^3.17.0", "app-root-path": "^3.1.0", "buffer": "^6.0.3", "dayjs": "^1.11.13", "debug": "^4.4.0", "dotenv": "^16.4.7", "glob": "^10.4.5", "sha.js": "^2.4.11", "sql-highlight": "^6.0.0", "tslib": "^2.8.1", "uuid": "^11.1.0", "yargs": "^17.7.2" }, "devDependencies": { "@eslint/js": "^9.22.0", "@sap/hana-client": "^2.24.21", "@tsconfig/node16": "^16.1.3", "@types/chai": "^4.3.20", "@types/chai-as-promised": "^7.1.8", "@types/debug": "^4.1.12", "@types/gulp-rename": "^2.0.6", "@types/gulp-sourcemaps": "^0.0.38", "@types/mocha": "^10.0.10", "@types/node": "^16.18.126", "@types/sha.js": "^2.4.4", "@types/sinon": "^10.0.20", "@types/sinon-chai": "^4.0.0", "@types/source-map-support": "^0.5.10", "@types/yargs": "^17.0.33", "better-sqlite3": "^8.7.0", "chai": "^4.5.0", "chai-as-promised": "^7.1.2", "class-transformer": "^0.5.1", "conventional-changelog-angular": "^7.0.0", "conventional-changelog-cli": "^5.0.0", "eslint": "^9.22.0", "globals": "^16.0.0", "gulp": "^4.0.2", "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", "hdb-pool": "^0.1.6", "mocha": "^10.8.2", "mongodb": "^6.15.0", "mssql": "^11.0.1", "mysql": "^2.18.1", "mysql2": "^3.14.0", "nyc": "^17.1.0", "oracledb": "^6.8.0", "pg": "^8.14.1", "pg-query-stream": "^4.8.1", "prettier": "^2.8.8", "redis": "^4.7.0", "remap-istanbul": "^0.13.0", "rimraf": "^5.0.10", "sinon": "^15.2.0", "sinon-chai": "^3.7.0", "source-map-support": "^0.5.21", "sql.js": "^1.13.0", "sqlite3": "^5.1.7", "ts-node": "^10.9.2", "typescript": "^5.8.2", "typescript-eslint": "^8.27.0" }, "peerDependencies": { "@google-cloud/spanner": "^5.18.0 || ^6.0.0 || ^7.0.0", "@sap/hana-client": "^2.12.25", "better-sqlite3": "^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0", "hdb-pool": "^0.1.6", "ioredis": "^5.0.4", "mongodb": "^5.8.0 || ^6.0.0", "mssql": "^9.1.1 || ^10.0.1 || ^11.0.1", "mysql2": "^2.2.5 || ^3.0.1", "oracledb": "^6.3.0", "pg": "^8.5.1", "pg-native": "^3.0.0", "pg-query-stream": "^4.0.0", "redis": "^3.1.1 || ^4.0.0", "reflect-metadata": "^0.1.14 || ^0.2.0", "sql.js": "^1.4.0", "sqlite3": "^5.0.3", "ts-node": "^10.7.0", "typeorm-aurora-data-api-driver": "^2.0.0 || ^3.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 } }, "engines": { "node": ">=16.13.0" }, "collective": { "type": "opencollective", "url": "https://opencollective.com/typeorm", "logo": "https://opencollective.com/opencollective/logo.txt" }, "readmeFilename": "README.md", "tags": [ "orm", "typescript", "typescript-orm", "mariadb", "mariadb-orm", "mysql", "mysql-orm", "oracle", "oracle-orm", "postgresql", "postgresql-orm", "sap-hana", "sap-hana-orm", "spanner", "cloud-spanner", "cloud-spanner-orm", "sqlite", "sqlite-orm", "sql-server", "sql-server-orm" ] }
1
+ { "name": "typeorm", "version": "0.3.22-dev.c3bebdc", "private": false, "description": "Data-Mapper ORM for TypeScript and ES2021+. Supports MySQL/MariaDB, PostgreSQL, MS SQL Server, Oracle, SAP HANA, SQLite, MongoDB databases.", "homepage": "https://typeorm.io", "bugs": { "url": "https://github.com/typeorm/typeorm/issues" }, "repository": { "type": "git", "url": "https://github.com/typeorm/typeorm.git" }, "funding": "https://opencollective.com/typeorm", "license": "MIT", "author": { "name": "Umed Khudoiberdiev", "email": "pleerock.me@gmail.com" }, "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", "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/mongodb/bson.typings.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/mongodb/typings.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" }, "types": "./index.d.ts", "bin": { "typeorm": "./cli.js", "typeorm-ts-node-commonjs": "./cli-ts-node-commonjs.js", "typeorm-ts-node-esm": "./cli-ts-node-esm.js" }, "scripts": { "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 1", "compile": "rimraf ./build && tsc", "format": "prettier --cache --write \"./**/*.ts\"", "format:ci": "prettier --check \"./**/*.ts\"", "lint": "eslint .", "pack": "gulp pack", "package": "gulp package", "test": "npm run compile && npm run test:fast --", "test:ci": "mocha --bail", "test:fast": "mocha", "watch": "tsc --watch" }, "dependencies": { "@sqltools/formatter": "^1.2.5", "ansis": "^3.17.0", "app-root-path": "^3.1.0", "buffer": "^6.0.3", "dayjs": "^1.11.13", "debug": "^4.4.0", "dotenv": "^16.4.7", "glob": "^10.4.5", "sha.js": "^2.4.11", "sql-highlight": "^6.0.0", "tslib": "^2.8.1", "uuid": "^11.1.0", "yargs": "^17.7.2" }, "devDependencies": { "@eslint/js": "^9.22.0", "@sap/hana-client": "^2.24.21", "@tsconfig/node16": "^16.1.3", "@types/chai": "^4.3.20", "@types/chai-as-promised": "^7.1.8", "@types/debug": "^4.1.12", "@types/gulp-rename": "^2.0.6", "@types/gulp-sourcemaps": "^0.0.38", "@types/mocha": "^10.0.10", "@types/node": "^16.18.126", "@types/sha.js": "^2.4.4", "@types/sinon": "^10.0.20", "@types/sinon-chai": "^4.0.0", "@types/source-map-support": "^0.5.10", "@types/yargs": "^17.0.33", "better-sqlite3": "^8.7.0", "chai": "^4.5.0", "chai-as-promised": "^7.1.2", "class-transformer": "^0.5.1", "conventional-changelog-angular": "^7.0.0", "conventional-changelog-cli": "^5.0.0", "eslint": "^9.22.0", "globals": "^16.0.0", "gulp": "^4.0.2", "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", "hdb-pool": "^0.1.6", "mocha": "^10.8.2", "mongodb": "^6.15.0", "mssql": "^11.0.1", "mysql": "^2.18.1", "mysql2": "^3.14.0", "nyc": "^17.1.0", "oracledb": "^6.8.0", "pg": "^8.14.1", "pg-query-stream": "^4.8.1", "prettier": "^2.8.8", "redis": "^4.7.0", "remap-istanbul": "^0.13.0", "rimraf": "^5.0.10", "sinon": "^15.2.0", "sinon-chai": "^3.7.0", "source-map-support": "^0.5.21", "sql.js": "^1.13.0", "sqlite3": "^5.1.7", "ts-node": "^10.9.2", "typescript": "^5.8.2", "typescript-eslint": "^8.27.0" }, "peerDependencies": { "@google-cloud/spanner": "^5.18.0 || ^6.0.0 || ^7.0.0", "@sap/hana-client": "^2.12.25", "better-sqlite3": "^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0", "hdb-pool": "^0.1.6", "ioredis": "^5.0.4", "mongodb": "^5.8.0 || ^6.0.0", "mssql": "^9.1.1 || ^10.0.1 || ^11.0.1", "mysql2": "^2.2.5 || ^3.0.1", "oracledb": "^6.3.0", "pg": "^8.5.1", "pg-native": "^3.0.0", "pg-query-stream": "^4.0.0", "redis": "^3.1.1 || ^4.0.0", "reflect-metadata": "^0.1.14 || ^0.2.0", "sql.js": "^1.4.0", "sqlite3": "^5.0.3", "ts-node": "^10.7.0", "typeorm-aurora-data-api-driver": "^2.0.0 || ^3.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 } }, "engines": { "node": ">=16.13.0" }, "collective": { "type": "opencollective", "url": "https://opencollective.com/typeorm", "logo": "https://opencollective.com/opencollective/logo.txt" }, "readmeFilename": "README.md", "tags": [ "orm", "typescript", "typescript-orm", "mariadb", "mariadb-orm", "mysql", "mysql-orm", "oracle", "oracle-orm", "postgresql", "postgresql-orm", "sap-hana", "sap-hana-orm", "spanner", "cloud-spanner", "cloud-spanner-orm", "sqlite", "sqlite-orm", "sql-server", "sql-server-orm" ] }