typeorm 0.2.39-dev.2c861af → 0.2.39-dev.6558295
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/driver/cockroachdb/CockroachDriver.js +23 -14
- package/browser/driver/cockroachdb/CockroachDriver.js.map +1 -1
- package/browser/driver/cockroachdb/CockroachQueryRunner.js +63 -69
- package/browser/driver/cockroachdb/CockroachQueryRunner.js.map +1 -1
- package/browser/driver/cordova/CordovaDriver.d.ts +1 -1
- package/browser/driver/cordova/CordovaDriver.js +25 -18
- package/browser/driver/cordova/CordovaDriver.js.map +1 -1
- package/browser/driver/cordova/CordovaQueryRunner.js +50 -43
- package/browser/driver/cordova/CordovaQueryRunner.js.map +1 -1
- package/browser/driver/postgres/PostgresDriver.d.ts +2 -2
- package/browser/driver/postgres/PostgresDriver.js +31 -40
- package/browser/driver/postgres/PostgresDriver.js.map +1 -1
- package/browser/driver/postgres/PostgresQueryRunner.js +7 -15
- package/browser/driver/postgres/PostgresQueryRunner.js.map +1 -1
- package/browser/driver/sap/SapQueryRunner.js +10 -28
- package/browser/driver/sap/SapQueryRunner.js.map +1 -1
- package/browser/driver/sqljs/SqljsDriver.js +5 -22
- package/browser/driver/sqljs/SqljsDriver.js.map +1 -1
- package/browser/driver/sqljs/SqljsQueryRunner.js +9 -10
- package/browser/driver/sqljs/SqljsQueryRunner.js.map +1 -1
- package/browser/migration/MigrationExecutor.d.ts +1 -1
- package/browser/migration/MigrationExecutor.js +6 -14
- package/browser/migration/MigrationExecutor.js.map +1 -1
- package/browser/persistence/SubjectExecutor.js +3 -3
- package/browser/persistence/SubjectExecutor.js.map +1 -1
- package/browser/persistence/subject-builder/OneToManySubjectBuilder.js +10 -4
- package/browser/persistence/subject-builder/OneToManySubjectBuilder.js.map +1 -1
- package/browser/query-builder/transformer/RawSqlResultsToEntityTransformer.js +2 -8
- package/browser/query-builder/transformer/RawSqlResultsToEntityTransformer.js.map +1 -1
- package/browser/query-runner/BaseQueryRunner.js +3 -2
- package/browser/query-runner/BaseQueryRunner.js.map +1 -1
- package/driver/cockroachdb/CockroachDriver.js +23 -14
- package/driver/cockroachdb/CockroachDriver.js.map +1 -1
- package/driver/cockroachdb/CockroachQueryRunner.js +63 -69
- package/driver/cockroachdb/CockroachQueryRunner.js.map +1 -1
- package/driver/cordova/CordovaDriver.d.ts +1 -1
- package/driver/cordova/CordovaDriver.js +25 -18
- package/driver/cordova/CordovaDriver.js.map +1 -1
- package/driver/cordova/CordovaQueryRunner.js +50 -43
- package/driver/cordova/CordovaQueryRunner.js.map +1 -1
- package/driver/postgres/PostgresDriver.d.ts +2 -2
- package/driver/postgres/PostgresDriver.js +31 -40
- package/driver/postgres/PostgresDriver.js.map +1 -1
- package/driver/postgres/PostgresQueryRunner.js +7 -15
- package/driver/postgres/PostgresQueryRunner.js.map +1 -1
- package/driver/sap/SapQueryRunner.js +10 -28
- package/driver/sap/SapQueryRunner.js.map +1 -1
- package/driver/sqljs/SqljsDriver.js +5 -22
- package/driver/sqljs/SqljsDriver.js.map +1 -1
- package/driver/sqljs/SqljsQueryRunner.js +9 -10
- package/driver/sqljs/SqljsQueryRunner.js.map +1 -1
- package/migration/MigrationExecutor.d.ts +1 -1
- package/migration/MigrationExecutor.js +6 -14
- package/migration/MigrationExecutor.js.map +1 -1
- package/package.json +1 -1
- package/persistence/SubjectExecutor.js +3 -3
- package/persistence/SubjectExecutor.js.map +1 -1
- package/persistence/subject-builder/OneToManySubjectBuilder.js +10 -4
- package/persistence/subject-builder/OneToManySubjectBuilder.js.map +1 -1
- package/query-builder/transformer/RawSqlResultsToEntityTransformer.js +2 -8
- package/query-builder/transformer/RawSqlResultsToEntityTransformer.js.map +1 -1
- package/query-runner/BaseQueryRunner.js +3 -2
- package/query-runner/BaseQueryRunner.js.map +1 -1
|
@@ -51,18 +51,10 @@ var SqljsDriver = /** @class */ (function (_super) {
|
|
|
51
51
|
*/
|
|
52
52
|
SqljsDriver.prototype.disconnect = function () {
|
|
53
53
|
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
54
|
-
var _this = this;
|
|
55
54
|
return (0, tslib_1.__generator)(this, function (_a) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
_this.databaseConnection.close();
|
|
60
|
-
ok();
|
|
61
|
-
}
|
|
62
|
-
catch (e) {
|
|
63
|
-
fail(e);
|
|
64
|
-
}
|
|
65
|
-
})];
|
|
55
|
+
this.queryRunner = undefined;
|
|
56
|
+
this.databaseConnection.close();
|
|
57
|
+
return [2 /*return*/];
|
|
66
58
|
});
|
|
67
59
|
});
|
|
68
60
|
};
|
|
@@ -265,7 +257,6 @@ var SqljsDriver = /** @class */ (function (_super) {
|
|
|
265
257
|
SqljsDriver.prototype.createDatabaseConnectionWithImport = function (database) {
|
|
266
258
|
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
267
259
|
var isLegacyVersion, sqlite, _a;
|
|
268
|
-
var _this = this;
|
|
269
260
|
return (0, tslib_1.__generator)(this, function (_b) {
|
|
270
261
|
switch (_b.label) {
|
|
271
262
|
case 0:
|
|
@@ -285,16 +276,8 @@ var SqljsDriver = /** @class */ (function (_super) {
|
|
|
285
276
|
else {
|
|
286
277
|
this.databaseConnection = new sqlite.Database();
|
|
287
278
|
}
|
|
288
|
-
|
|
289
|
-
return [2 /*return*/,
|
|
290
|
-
try {
|
|
291
|
-
_this.databaseConnection.exec("PRAGMA foreign_keys = ON;");
|
|
292
|
-
ok(_this.databaseConnection);
|
|
293
|
-
}
|
|
294
|
-
catch (e) {
|
|
295
|
-
fail(e);
|
|
296
|
-
}
|
|
297
|
-
})];
|
|
279
|
+
this.databaseConnection.exec("PRAGMA foreign_keys = ON;");
|
|
280
|
+
return [2 /*return*/, this.databaseConnection];
|
|
298
281
|
}
|
|
299
282
|
});
|
|
300
283
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/driver/sqljs/SqljsDriver.ts"],"names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CAAC,MAAM,GAAG,CAAC,EAAE;4BACjC,IAAI,CAAC,kBAAkB,GAAG,IAAI,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;yBAC3D;6BACI;4BACD,IAAI,CAAC,kBAAkB,GAAG,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;yBACnD;wBAED,mCAAmC;wBACnC,sBAAO,IAAI,OAAO,CAAM,UAAC,EAAE,EAAE,IAAI;gCAC7B,IAAI;oCACA,KAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;oCAC1D,EAAE,CAAC,KAAI,CAAC,kBAAkB,CAAC,CAAC;iCAC/B;gCACD,OAAO,CAAC,EAAE;oCACN,IAAI,CAAC,CAAC,CAAC,CAAC;iCACX;4BACL,CAAC,CAAC,EAAC;;;;KACN;IAED;;OAEG;IACO,sCAAgB,GAA1B;QACI,IAAI,6BAAa,CAAC,IAAI,KAAK,SAAS,EAAE;YAClC,IAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,MAAM,CAAC,GAAG,CAAC;YACjD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;SACxB;aACI;YACD,IAAI;gBACA,IAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,6BAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;gBACnE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;aAExB;YAAC,OAAO,CAAC,EAAE;gBACR,MAAM,IAAI,+DAA8B,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;aAChE;SACJ;IACL,CAAC;IACL,kBAAC;AAAD,CA7QA,AA6QC,CA7QgC,2CAAoB,GA6QpD;AA7QY,kCAAW","file":"SqljsDriver.js","sourcesContent":["import {AbstractSqliteDriver} from \"../sqlite-abstract/AbstractSqliteDriver\";\nimport {SqljsConnectionOptions} from \"./SqljsConnectionOptions\";\nimport {SqljsQueryRunner} from \"./SqljsQueryRunner\";\nimport {QueryRunner} from \"../../query-runner/QueryRunner\";\nimport {Connection} from \"../../connection/Connection\";\nimport {DriverPackageNotInstalledError} from \"../../error/DriverPackageNotInstalledError\";\nimport {DriverOptionNotSetError} from \"../../error/DriverOptionNotSetError\";\nimport {PlatformTools} from \"../../platform/PlatformTools\";\nimport {EntityMetadata} from \"../../metadata/EntityMetadata\";\nimport {OrmUtils} from \"../../util/OrmUtils\";\nimport {ObjectLiteral} from \"../../common/ObjectLiteral\";\nimport {ReplicationMode} from \"../types/ReplicationMode\";\nimport { TypeORMError } from \"../../error\";\n\n// This is needed to satisfy the typescript compiler.\ninterface Window {\n SQL: any;\n localforage: any;\n}\ndeclare let window: Window;\n\nexport class SqljsDriver extends AbstractSqliteDriver {\n // The driver specific options.\n options: SqljsConnectionOptions;\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(connection: Connection) {\n super(connection);\n\n // If autoSave is enabled by user, location or autoSaveCallback have to be set\n // because either autoSave saves to location or calls autoSaveCallback.\n if (this.options.autoSave && !this.options.location && !this.options.autoSaveCallback) {\n throw new DriverOptionNotSetError(`location or autoSaveCallback`);\n }\n\n // load sql.js package\n this.loadDependencies();\n }\n\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Performs connection to the database.\n */\n async connect(): Promise<void> {\n this.databaseConnection = await this.createDatabaseConnection();\n }\n\n /**\n * Closes connection with database.\n */\n async disconnect(): Promise<void> {\n return new Promise<void>((ok, fail) => {\n try {\n this.queryRunner = undefined;\n this.databaseConnection.close();\n ok();\n }\n catch (e) {\n fail(e);\n }\n });\n }\n\n /**\n * Creates a query runner used to execute database queries.\n */\n createQueryRunner(mode: ReplicationMode): QueryRunner {\n if (!this.queryRunner)\n this.queryRunner = new SqljsQueryRunner(this);\n\n return this.queryRunner;\n }\n\n /**\n * Loads a database from a given file (Node.js), local storage key (browser) or array.\n * This will delete the current database!\n */\n async load(fileNameOrLocalStorageOrData: string | Uint8Array, checkIfFileOrLocalStorageExists: boolean = true): Promise<any> {\n if (typeof fileNameOrLocalStorageOrData === \"string\") {\n // content has to be loaded\n if (PlatformTools.type === \"node\") {\n // Node.js\n // fileNameOrLocalStorageOrData should be a path to the file\n if (PlatformTools.fileExist(fileNameOrLocalStorageOrData)) {\n const database = PlatformTools.readFileSync(fileNameOrLocalStorageOrData);\n return this.createDatabaseConnectionWithImport(database);\n }\n else if (checkIfFileOrLocalStorageExists) {\n throw new TypeORMError(`File ${fileNameOrLocalStorageOrData} does not exist`);\n }\n else {\n // File doesn't exist and checkIfFileOrLocalStorageExists is set to false.\n // Therefore open a database without importing an existing file.\n // File will be written on first write operation.\n return this.createDatabaseConnectionWithImport();\n }\n }\n else {\n // browser\n // fileNameOrLocalStorageOrData should be a local storage / indexedDB key\n let localStorageContent = null;\n if (this.options.useLocalForage) {\n if (window.localforage) {\n localStorageContent = await window.localforage.getItem(fileNameOrLocalStorageOrData);\n } else {\n throw new TypeORMError(`localforage is not defined - please import localforage.js into your site`);\n }\n } else {\n localStorageContent = PlatformTools.getGlobalVariable().localStorage.getItem(fileNameOrLocalStorageOrData);\n }\n\n if (localStorageContent != null) {\n // localStorage value exists.\n return this.createDatabaseConnectionWithImport(JSON.parse(localStorageContent));\n }\n else if (checkIfFileOrLocalStorageExists) {\n throw new TypeORMError(`File ${fileNameOrLocalStorageOrData} does not exist`);\n }\n else {\n // localStorage value doesn't exist and checkIfFileOrLocalStorageExists is set to false.\n // Therefore open a database without importing anything.\n // localStorage value will be written on first write operation.\n return this.createDatabaseConnectionWithImport();\n }\n }\n }\n else {\n return this.createDatabaseConnectionWithImport(fileNameOrLocalStorageOrData);\n }\n }\n\n /**\n * Saved the current database to the given file (Node.js), local storage key (browser) or\n * indexedDB key (browser with enabled useLocalForage option).\n * If no location path is given, the location path in the options (if specified) will be used.\n */\n async save(location?: string) {\n if (!location && !this.options.location) {\n throw new TypeORMError(`No location is set, specify a location parameter or add the location option to your configuration`);\n }\n\n let path = \"\";\n if (location) {\n path = location;\n }\n else if (this.options.location) {\n path = this.options.location;\n }\n\n if (PlatformTools.type === \"node\") {\n try {\n const content = Buffer.from(this.databaseConnection.export());\n await PlatformTools.writeFile(path, content);\n }\n catch (e) {\n throw new TypeORMError(`Could not save database, error: ${e}`);\n }\n }\n else {\n const database: Uint8Array = this.databaseConnection.export();\n // convert Uint8Array to number array to improve local-storage storage\n const databaseArray = [].slice.call(database);\n if (this.options.useLocalForage) {\n if (window.localforage) {\n await window.localforage.setItem(path, JSON.stringify(databaseArray));\n } else {\n throw new TypeORMError(`localforage is not defined - please import localforage.js into your site`);\n }\n } else {\n PlatformTools.getGlobalVariable().localStorage.setItem(path, JSON.stringify(databaseArray));\n }\n }\n }\n\n /**\n * This gets called by the QueryRunner when a change to the database is made.\n * If a custom autoSaveCallback is specified, it get's called with the database as Uint8Array,\n * otherwise the save method is called which saves it to file (Node.js), local storage (browser)\n * or indexedDB (browser with enabled useLocalForage option).\n */\n async autoSave() {\n if (this.options.autoSave) {\n if (this.options.autoSaveCallback) {\n await this.options.autoSaveCallback(this.export());\n }\n else {\n await this.save();\n }\n }\n }\n\n /**\n * Returns the current database as Uint8Array.\n */\n export(): Uint8Array {\n return this.databaseConnection.export();\n }\n\n /**\n * Creates generated map of values generated or returned by database after INSERT query.\n */\n createGeneratedMap(metadata: EntityMetadata, insertResult: any) {\n const generatedMap = metadata.generatedColumns.reduce((map, generatedColumn) => {\n // seems to be the only way to get the inserted id, see https://github.com/kripken/sql.js/issues/77\n if (generatedColumn.isPrimary && generatedColumn.generationStrategy === \"increment\") {\n const query = \"SELECT last_insert_rowid()\";\n try {\n let result = this.databaseConnection.exec(query);\n this.connection.logger.logQuery(query);\n return OrmUtils.mergeDeep(map, generatedColumn.createValueMap(result[0].values[0][0]));\n }\n catch (e) {\n this.connection.logger.logQueryError(e, query, []);\n }\n }\n\n return map;\n }, {} as ObjectLiteral);\n\n return Object.keys(generatedMap).length > 0 ? generatedMap : undefined;\n }\n\n // -------------------------------------------------------------------------\n // Protected Methods\n // -------------------------------------------------------------------------\n\n /**\n * Creates connection with the database.\n * If the location option is set, the database is loaded first.\n */\n protected createDatabaseConnection(): Promise<any> {\n if (this.options.location) {\n return this.load(this.options.location, false);\n }\n\n return this.createDatabaseConnectionWithImport(this.options.database);\n }\n\n /**\n * Creates connection with an optional database.\n * If database is specified it is loaded, otherwise a new empty database is created.\n */\n protected async createDatabaseConnectionWithImport(database?: Uint8Array): Promise<any> {\n // sql.js < 1.0 exposes an object with a `Database` method.\n const isLegacyVersion = typeof this.sqlite.Database === \"function\";\n const sqlite = isLegacyVersion ? this.sqlite : await this.sqlite(this.options.sqlJsConfig);\n if (database && database.length > 0) {\n this.databaseConnection = new sqlite.Database(database);\n }\n else {\n this.databaseConnection = new sqlite.Database();\n }\n\n // Enable foreign keys for database\n return new Promise<any>((ok, fail) => {\n try {\n this.databaseConnection.exec(`PRAGMA foreign_keys = ON;`);\n ok(this.databaseConnection);\n }\n catch (e) {\n fail(e);\n }\n });\n }\n\n /**\n * If driver dependency is not given explicitly, then try to load it via \"require\".\n */\n protected loadDependencies(): void {\n if (PlatformTools.type === \"browser\") {\n const sqlite = this.options.driver || window.SQL;\n this.sqlite = sqlite;\n }\n else {\n try {\n const sqlite = this.options.driver || PlatformTools.load(\"sql.js\");\n this.sqlite = sqlite;\n\n } catch (e) {\n throw new DriverPackageNotInstalledError(\"sql.js\", \"sql.js\");\n }\n }\n }\n}\n"],"sourceRoot":"../.."}
|
|
1
|
+
{"version":3,"sources":["../../src/driver/sqljs/SqljsDriver.ts"],"names":[],"mappings":";;;;AAAA,gFAA6E;AAE7E,uDAAoD;AAGpD,6FAA0F;AAC1F,+EAA4E;AAC5E,8DAA2D;AAE3D,gDAA6C;AAG7C,qCAA2C;AAS3C;IAAiC,4CAAoB;IAIjD,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,qBAAY,UAAsB;QAAlC,YACI,kBAAM,UAAU,CAAC,SAUpB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,OAAO,CAAC,MAAM,IAAI,MAAM,CAAC,GAAG,CAAC;YACjD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;SACxB;aACI;YACD,IAAI;gBACA,IAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,6BAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;gBACnE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;aAExB;YAAC,OAAO,CAAC,EAAE;gBACR,MAAM,IAAI,+DAA8B,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;aAChE;SACJ;IACL,CAAC;IACL,kBAAC;AAAD,CA9PA,AA8PC,CA9PgC,2CAAoB,GA8PpD;AA9PY,kCAAW","file":"SqljsDriver.js","sourcesContent":["import {AbstractSqliteDriver} from \"../sqlite-abstract/AbstractSqliteDriver\";\nimport {SqljsConnectionOptions} from \"./SqljsConnectionOptions\";\nimport {SqljsQueryRunner} from \"./SqljsQueryRunner\";\nimport {QueryRunner} from \"../../query-runner/QueryRunner\";\nimport {Connection} from \"../../connection/Connection\";\nimport {DriverPackageNotInstalledError} from \"../../error/DriverPackageNotInstalledError\";\nimport {DriverOptionNotSetError} from \"../../error/DriverOptionNotSetError\";\nimport {PlatformTools} from \"../../platform/PlatformTools\";\nimport {EntityMetadata} from \"../../metadata/EntityMetadata\";\nimport {OrmUtils} from \"../../util/OrmUtils\";\nimport {ObjectLiteral} from \"../../common/ObjectLiteral\";\nimport {ReplicationMode} from \"../types/ReplicationMode\";\nimport { TypeORMError } from \"../../error\";\n\n// This is needed to satisfy the typescript compiler.\ninterface Window {\n SQL: any;\n localforage: any;\n}\ndeclare let window: Window;\n\nexport class SqljsDriver extends AbstractSqliteDriver {\n // The driver specific options.\n options: SqljsConnectionOptions;\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(connection: Connection) {\n super(connection);\n\n // If autoSave is enabled by user, location or autoSaveCallback have to be set\n // because either autoSave saves to location or calls autoSaveCallback.\n if (this.options.autoSave && !this.options.location && !this.options.autoSaveCallback) {\n throw new DriverOptionNotSetError(`location or autoSaveCallback`);\n }\n\n // load sql.js package\n this.loadDependencies();\n }\n\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Performs connection to the database.\n */\n async connect(): Promise<void> {\n this.databaseConnection = await this.createDatabaseConnection();\n }\n\n /**\n * Closes connection with database.\n */\n async disconnect(): Promise<void> {\n this.queryRunner = undefined;\n this.databaseConnection.close();\n }\n\n /**\n * Creates a query runner used to execute database queries.\n */\n createQueryRunner(mode: ReplicationMode): QueryRunner {\n if (!this.queryRunner)\n this.queryRunner = new SqljsQueryRunner(this);\n\n return this.queryRunner;\n }\n\n /**\n * Loads a database from a given file (Node.js), local storage key (browser) or array.\n * This will delete the current database!\n */\n async load(fileNameOrLocalStorageOrData: string | Uint8Array, checkIfFileOrLocalStorageExists: boolean = true): Promise<any> {\n if (typeof fileNameOrLocalStorageOrData === \"string\") {\n // content has to be loaded\n if (PlatformTools.type === \"node\") {\n // Node.js\n // fileNameOrLocalStorageOrData should be a path to the file\n if (PlatformTools.fileExist(fileNameOrLocalStorageOrData)) {\n const database = PlatformTools.readFileSync(fileNameOrLocalStorageOrData);\n return this.createDatabaseConnectionWithImport(database);\n }\n else if (checkIfFileOrLocalStorageExists) {\n throw new TypeORMError(`File ${fileNameOrLocalStorageOrData} does not exist`);\n }\n else {\n // File doesn't exist and checkIfFileOrLocalStorageExists is set to false.\n // Therefore open a database without importing an existing file.\n // File will be written on first write operation.\n return this.createDatabaseConnectionWithImport();\n }\n }\n else {\n // browser\n // fileNameOrLocalStorageOrData should be a local storage / indexedDB key\n let localStorageContent = null;\n if (this.options.useLocalForage) {\n if (window.localforage) {\n localStorageContent = await window.localforage.getItem(fileNameOrLocalStorageOrData);\n } else {\n throw new TypeORMError(`localforage is not defined - please import localforage.js into your site`);\n }\n } else {\n localStorageContent = PlatformTools.getGlobalVariable().localStorage.getItem(fileNameOrLocalStorageOrData);\n }\n\n if (localStorageContent != null) {\n // localStorage value exists.\n return this.createDatabaseConnectionWithImport(JSON.parse(localStorageContent));\n }\n else if (checkIfFileOrLocalStorageExists) {\n throw new TypeORMError(`File ${fileNameOrLocalStorageOrData} does not exist`);\n }\n else {\n // localStorage value doesn't exist and checkIfFileOrLocalStorageExists is set to false.\n // Therefore open a database without importing anything.\n // localStorage value will be written on first write operation.\n return this.createDatabaseConnectionWithImport();\n }\n }\n }\n else {\n return this.createDatabaseConnectionWithImport(fileNameOrLocalStorageOrData);\n }\n }\n\n /**\n * Saved the current database to the given file (Node.js), local storage key (browser) or\n * indexedDB key (browser with enabled useLocalForage option).\n * If no location path is given, the location path in the options (if specified) will be used.\n */\n async save(location?: string) {\n if (!location && !this.options.location) {\n throw new TypeORMError(`No location is set, specify a location parameter or add the location option to your configuration`);\n }\n\n let path = \"\";\n if (location) {\n path = location;\n }\n else if (this.options.location) {\n path = this.options.location;\n }\n\n if (PlatformTools.type === \"node\") {\n try {\n const content = Buffer.from(this.databaseConnection.export());\n await PlatformTools.writeFile(path, content);\n }\n catch (e) {\n throw new TypeORMError(`Could not save database, error: ${e}`);\n }\n }\n else {\n const database: Uint8Array = this.databaseConnection.export();\n // convert Uint8Array to number array to improve local-storage storage\n const databaseArray = [].slice.call(database);\n if (this.options.useLocalForage) {\n if (window.localforage) {\n await window.localforage.setItem(path, JSON.stringify(databaseArray));\n } else {\n throw new TypeORMError(`localforage is not defined - please import localforage.js into your site`);\n }\n } else {\n PlatformTools.getGlobalVariable().localStorage.setItem(path, JSON.stringify(databaseArray));\n }\n }\n }\n\n /**\n * This gets called by the QueryRunner when a change to the database is made.\n * If a custom autoSaveCallback is specified, it get's called with the database as Uint8Array,\n * otherwise the save method is called which saves it to file (Node.js), local storage (browser)\n * or indexedDB (browser with enabled useLocalForage option).\n */\n async autoSave() {\n if (this.options.autoSave) {\n if (this.options.autoSaveCallback) {\n await this.options.autoSaveCallback(this.export());\n }\n else {\n await this.save();\n }\n }\n }\n\n /**\n * Returns the current database as Uint8Array.\n */\n export(): Uint8Array {\n return this.databaseConnection.export();\n }\n\n /**\n * Creates generated map of values generated or returned by database after INSERT query.\n */\n createGeneratedMap(metadata: EntityMetadata, insertResult: any) {\n const generatedMap = metadata.generatedColumns.reduce((map, generatedColumn) => {\n // seems to be the only way to get the inserted id, see https://github.com/kripken/sql.js/issues/77\n if (generatedColumn.isPrimary && generatedColumn.generationStrategy === \"increment\") {\n const query = \"SELECT last_insert_rowid()\";\n try {\n let result = this.databaseConnection.exec(query);\n this.connection.logger.logQuery(query);\n return OrmUtils.mergeDeep(map, generatedColumn.createValueMap(result[0].values[0][0]));\n }\n catch (e) {\n this.connection.logger.logQueryError(e, query, []);\n }\n }\n\n return map;\n }, {} as ObjectLiteral);\n\n return Object.keys(generatedMap).length > 0 ? generatedMap : undefined;\n }\n\n // -------------------------------------------------------------------------\n // Protected Methods\n // -------------------------------------------------------------------------\n\n /**\n * Creates connection with the database.\n * If the location option is set, the database is loaded first.\n */\n protected createDatabaseConnection(): Promise<any> {\n if (this.options.location) {\n return this.load(this.options.location, false);\n }\n\n return this.createDatabaseConnectionWithImport(this.options.database);\n }\n\n /**\n * Creates connection with an optional database.\n * If database is specified it is loaded, otherwise a new empty database is created.\n */\n protected async createDatabaseConnectionWithImport(database?: Uint8Array): Promise<any> {\n // sql.js < 1.0 exposes an object with a `Database` method.\n const isLegacyVersion = typeof this.sqlite.Database === \"function\";\n const sqlite = isLegacyVersion ? this.sqlite : await this.sqlite(this.options.sqlJsConfig);\n if (database && database.length > 0) {\n this.databaseConnection = new sqlite.Database(database);\n }\n else {\n this.databaseConnection = new sqlite.Database();\n }\n\n this.databaseConnection.exec(`PRAGMA foreign_keys = ON;`);\n\n return this.databaseConnection;\n }\n\n /**\n * If driver dependency is not given explicitly, then try to load it via \"require\".\n */\n protected loadDependencies(): void {\n if (PlatformTools.type === \"browser\") {\n const sqlite = this.options.driver || window.SQL;\n this.sqlite = sqlite;\n }\n else {\n try {\n const sqlite = this.options.driver || PlatformTools.load(\"sql.js\");\n this.sqlite = sqlite;\n\n } catch (e) {\n throw new DriverPackageNotInstalledError(\"sql.js\", \"sql.js\");\n }\n }\n }\n}\n"],"sourceRoot":"../.."}
|
|
@@ -80,15 +80,14 @@ var SqljsQueryRunner = /** @class */ (function (_super) {
|
|
|
80
80
|
* Executes a given SQL query.
|
|
81
81
|
*/
|
|
82
82
|
SqljsQueryRunner.prototype.query = function (query, parameters, useStructuredResult) {
|
|
83
|
-
var _this = this;
|
|
84
83
|
if (parameters === void 0) { parameters = []; }
|
|
85
84
|
if (useStructuredResult === void 0) { useStructuredResult = false; }
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
var command = query.trim().split(" ", 1)[0];
|
|
89
|
-
return new Promise(function (ok, fail) { return (0, tslib_1.__awaiter)(_this, void 0, void 0, function () {
|
|
90
|
-
var databaseConnection, queryStartTime, statement, maxQueryExecutionTime, queryEndTime, queryExecutionTime, records, result;
|
|
85
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
86
|
+
var command, databaseConnection, queryStartTime, statement, maxQueryExecutionTime, queryEndTime, queryExecutionTime, records, result;
|
|
91
87
|
return (0, tslib_1.__generator)(this, function (_a) {
|
|
88
|
+
if (this.isReleased)
|
|
89
|
+
throw new QueryRunnerAlreadyReleasedError_1.QueryRunnerAlreadyReleasedError();
|
|
90
|
+
command = query.trim().split(" ", 1)[0];
|
|
92
91
|
databaseConnection = this.driver.databaseConnection;
|
|
93
92
|
this.driver.connection.logger.logQuery(query, parameters, this);
|
|
94
93
|
queryStartTime = +new Date();
|
|
@@ -116,10 +115,10 @@ var SqljsQueryRunner = /** @class */ (function (_super) {
|
|
|
116
115
|
this.isDirty = true;
|
|
117
116
|
}
|
|
118
117
|
if (useStructuredResult) {
|
|
119
|
-
|
|
118
|
+
return [2 /*return*/, result];
|
|
120
119
|
}
|
|
121
120
|
else {
|
|
122
|
-
|
|
121
|
+
return [2 /*return*/, result.raw];
|
|
123
122
|
}
|
|
124
123
|
}
|
|
125
124
|
catch (e) {
|
|
@@ -127,11 +126,11 @@ var SqljsQueryRunner = /** @class */ (function (_super) {
|
|
|
127
126
|
statement.free();
|
|
128
127
|
}
|
|
129
128
|
this.driver.connection.logger.logQueryError(e, query, parameters, this);
|
|
130
|
-
|
|
129
|
+
throw new QueryFailedError_1.QueryFailedError(query, parameters, e);
|
|
131
130
|
}
|
|
132
131
|
return [2 /*return*/];
|
|
133
132
|
});
|
|
134
|
-
});
|
|
133
|
+
});
|
|
135
134
|
};
|
|
136
135
|
return SqljsQueryRunner;
|
|
137
136
|
}(AbstractSqliteQueryRunner_1.AbstractSqliteQueryRunner));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/driver/sqljs/SqljsQueryRunner.ts"],"names":[],"mappings":";;;;AAAA,+FAA4F;AAC5F,0FAAuF;AAEvF,4DAAyD;AACzD,iEAA8D;AAC9D,8DAA6D;AAE7D;;GAEG;AACH;IAAsC,iDAAyB;IAY3D,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,0BAAY,MAAmB;QAA/B,YACI,iBAAO,SAIV;QAnBD;;WAEG;QACK,aAAO,GAAG,KAAK,CAAC;QAapB,KAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,KAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;QACpC,KAAI,CAAC,WAAW,GAAG,IAAI,yBAAW,CAAC,KAAI,CAAC,CAAC;;IAC7C,CAAC;IAED,4EAA4E;IAC5E,iBAAiB;IACjB,4EAA4E;IAE9D,gCAAK,GAAnB;;;;;6BACQ,IAAI,CAAC,OAAO,EAAZ,wBAAY;wBACZ,qBAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAA;;wBAA5B,SAA4B,CAAC;wBAC7B,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;;;;;;KAE5B;IAEK,kCAAO,GAAb;;;;4B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AAC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,YAAY,CAAC,kBAAkB,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;oBAEtF,OAAO,GAAU,EAAE,CAAC;oBAE1B,OAAO,SAAS,CAAC,IAAI,EAAE,EAAE;wBACrB,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC,CAAC;qBACzC;oBAEK,MAAM,GAAG,IAAI,yBAAW,EAAE,CAAC;oBAEjC,MAAM,CAAC,QAAQ,GAAG,kBAAkB,CAAC,eAAe,EAAE,CAAC;oBACvD,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC;oBACzB,MAAM,CAAC,GAAG,GAAG,OAAO,CAAC;oBAErB,SAAS,CAAC,IAAI,EAAE,CAAC;oBAEjB,IAAI,OAAO,KAAK,QAAQ,EAAE;wBACtB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;qBACvB;oBAED,IAAI,mBAAmB,EAAE;wBACrB,sBAAO,MAAM,EAAC;qBACjB;yBAAM;wBACH,sBAAO,MAAM,CAAC,GAAG,EAAC;qBACrB;iBACJ;gBAAC,OAAO,CAAC,EAAE;oBACR,IAAI,SAAS,EAAE;wBACX,SAAS,CAAC,IAAI,EAAE,CAAC;qBACpB;oBAED,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;oBACxE,MAAM,IAAI,mCAAgB,CAAC,KAAK,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC;iBACpD;;;;KACJ;IACL,uBAAC;AAAD,CA5GA,AA4GC,CA5GqC,qDAAyB,GA4G9D;AA5GY,4CAAgB","file":"SqljsQueryRunner.js","sourcesContent":["import {QueryRunnerAlreadyReleasedError} from \"../../error/QueryRunnerAlreadyReleasedError\";\nimport {AbstractSqliteQueryRunner} from \"../sqlite-abstract/AbstractSqliteQueryRunner\";\nimport {SqljsDriver} from \"./SqljsDriver\";\nimport {Broadcaster} from \"../../subscriber/Broadcaster\";\nimport {QueryFailedError} from \"../../error/QueryFailedError\";\nimport { QueryResult } from \"../../query-runner/QueryResult\";\n\n/**\n * Runs queries on a single sqlite database connection.\n */\nexport class SqljsQueryRunner extends AbstractSqliteQueryRunner {\n\n /**\n * Flag to determine if a modification has happened since the last time this query runner has requested a save.\n */\n private isDirty = false;\n\n /**\n * Database driver used by connection.\n */\n driver: SqljsDriver;\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(driver: SqljsDriver) {\n super();\n this.driver = driver;\n this.connection = driver.connection;\n this.broadcaster = new Broadcaster(this);\n }\n\n // -------------------------------------------------------------------------\n // Public methods\n // -------------------------------------------------------------------------\n\n private async flush() {\n if (this.isDirty) {\n await this.driver.autoSave();\n this.isDirty = false;\n }\n }\n\n async release(): Promise<void> {\n await this.flush();\n return super.release();\n }\n\n /**\n * Commits transaction.\n * Error will be thrown if transaction was not started.\n */\n async commitTransaction(): Promise<void> {\n await super.commitTransaction();\n await this.flush();\n }\n\n /**\n * Executes a given SQL query.\n */\n async query(query: string, parameters: any[] = [], useStructuredResult = false): Promise<any> {\n if (this.isReleased)\n throw new QueryRunnerAlreadyReleasedError();\n\n const command = query.trim().split(\" \", 1)[0];\n\n const databaseConnection = this.driver.databaseConnection;\n this.driver.connection.logger.logQuery(query, parameters, this);\n const queryStartTime = +new Date();\n let statement: any;\n try {\n statement = databaseConnection.prepare(query);\n if (parameters) {\n parameters = parameters.map(p => typeof p !== 'undefined' ? p : null);\n\n statement.bind(parameters);\n }\n\n // log slow queries if maxQueryExecution time is set\n const maxQueryExecutionTime = this.driver.options.maxQueryExecutionTime;\n const queryEndTime = +new Date();\n const queryExecutionTime = queryEndTime - queryStartTime;\n if (maxQueryExecutionTime && queryExecutionTime > maxQueryExecutionTime)\n this.driver.connection.logger.logQuerySlow(queryExecutionTime, query, parameters, this);\n\n const records: any[] = [];\n\n while (statement.step()) {\n records.push(statement.getAsObject());\n }\n\n const result = new QueryResult();\n\n result.affected = databaseConnection.getRowsModified();\n result.records = records;\n result.raw = records;\n\n statement.free();\n\n if (command !== \"SELECT\") {\n this.isDirty = true;\n }\n\n if (useStructuredResult) {\n return result;\n } else {\n return result.raw;\n }\n } catch (e) {\n if (statement) {\n statement.free();\n }\n\n this.driver.connection.logger.logQueryError(e, query, parameters, this);\n throw new QueryFailedError(query, parameters, e);\n }\n }\n}\n"],"sourceRoot":"../.."}
|
|
@@ -87,5 +87,5 @@ export declare class MigrationExecutor {
|
|
|
87
87
|
* Delete previously executed migration's data from the migrations table.
|
|
88
88
|
*/
|
|
89
89
|
protected deleteExecutedMigration(queryRunner: QueryRunner, migration: Migration): Promise<void>;
|
|
90
|
-
protected withQueryRunner<T extends any>(callback: (queryRunner: QueryRunner) => T): Promise<T>;
|
|
90
|
+
protected withQueryRunner<T extends any>(callback: (queryRunner: QueryRunner) => T | Promise<T>): Promise<T>;
|
|
91
91
|
}
|
|
@@ -123,26 +123,14 @@ var MigrationExecutor = /** @class */ (function () {
|
|
|
123
123
|
*/
|
|
124
124
|
MigrationExecutor.prototype.insertMigration = function (migration) {
|
|
125
125
|
var _this = this;
|
|
126
|
-
return
|
|
127
|
-
_this.withQueryRunner(function (queryRunner) {
|
|
128
|
-
_this.insertExecutedMigration(queryRunner, migration)
|
|
129
|
-
.then(resolve)
|
|
130
|
-
.catch(reject);
|
|
131
|
-
});
|
|
132
|
-
});
|
|
126
|
+
return this.withQueryRunner(function (q) { return _this.insertExecutedMigration(q, migration); });
|
|
133
127
|
};
|
|
134
128
|
/**
|
|
135
129
|
* Deletes an executed migration.
|
|
136
130
|
*/
|
|
137
131
|
MigrationExecutor.prototype.deleteMigration = function (migration) {
|
|
138
132
|
var _this = this;
|
|
139
|
-
return
|
|
140
|
-
_this.withQueryRunner(function (queryRunner) {
|
|
141
|
-
_this.deleteExecutedMigration(queryRunner, migration)
|
|
142
|
-
.then(resolve)
|
|
143
|
-
.catch(reject);
|
|
144
|
-
});
|
|
145
|
-
});
|
|
133
|
+
return this.withQueryRunner(function (q) { return _this.deleteExecutedMigration(q, migration); });
|
|
146
134
|
};
|
|
147
135
|
/**
|
|
148
136
|
* Lists all migrations and whether they have been executed or not
|
|
@@ -270,6 +258,10 @@ var MigrationExecutor = /** @class */ (function () {
|
|
|
270
258
|
transactionStartedByUs = true;
|
|
271
259
|
_c.label = 2;
|
|
272
260
|
case 2: return [4 /*yield*/, migration.instance.up(queryRunner)
|
|
261
|
+
.catch(function (error) {
|
|
262
|
+
_this.connection.logger.logMigration("Migration \"" + migration.name + "\" has been failed, error: " + (error === null || error === void 0 ? void 0 : error.message));
|
|
263
|
+
throw error;
|
|
264
|
+
})
|
|
273
265
|
.then(function () { return (0, tslib_1.__awaiter)(_this, void 0, void 0, function () {
|
|
274
266
|
return (0, tslib_1.__generator)(this, function (_a) {
|
|
275
267
|
switch (_a.label) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/migration/MigrationExecutor.ts"],"names":[],"mappings":";;;;AAAA,uDAAoD;AAEpD,yCAAsC;AAGtC,uEAAoE;AACpE,qEAAkE;AAClE,6DAA0D;AAE1D,kCAAwC;AAExC;;GAEG;AACH;IAuBI,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,2BAAsB,UAAsB,EACtB,WAAyB;QADzB,eAAU,GAAV,UAAU,CAAY;QACtB,gBAAW,GAAX,WAAW,CAAc;QA1B/C,4EAA4E;QAC5E,oBAAoB;QACpB,4EAA4E;QAE5E;;;;;WAKG;QACH,gBAAW,GAA4B,KAAK,CAAC;QAkBjC,IAAA,MAAM,GAAK,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,OAAc,OAA1C,CAA2C;QACzD,IAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC;QACjD,IAAI,CAAC,kBAAkB,GAAG,QAAQ,CAAC;QACnC,IAA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;;;KAGvC;IACL,wBAAC;AAAD,CAnfA,AAmfC,IAAA;AAnfY,8CAAiB","file":"MigrationExecutor.js","sourcesContent":["import {Table} from \"../schema-builder/table/Table\";\nimport {Connection} from \"../connection/Connection\";\nimport {Migration} from \"./Migration\";\nimport {ObjectLiteral} from \"../common/ObjectLiteral\";\nimport {QueryRunner} from \"../query-runner/QueryRunner\";\nimport {SqlServerDriver} from \"../driver/sqlserver/SqlServerDriver\";\nimport {MssqlParameter} from \"../driver/sqlserver/MssqlParameter\";\nimport {MongoDriver} from \"../driver/mongodb/MongoDriver\";\nimport {MongoQueryRunner} from \"../driver/mongodb/MongoQueryRunner\";\nimport { TypeORMError } from \"../error\";\n\n/**\n * Executes migrations: runs pending and reverts previously executed migrations.\n */\nexport class MigrationExecutor {\n\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 // 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(protected connection: Connection,\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 = connection.options.migrationsTableName || \"migrations\";\n this.migrationsTable = this.connection.driver.buildTableName(this.migrationsTableName, schema, database);\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 await (migration.instance as any).up(queryRunner);\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(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 new Promise((resolve, reject) => {\n this.withQueryRunner(queryRunner => {\n this.insertExecutedMigration(queryRunner, migration)\n .then(resolve)\n .catch(reject);\n });\n });\n }\n\n /**\n * Deletes an executed migration.\n */\n public deleteMigration(migration: Migration): Promise<void> {\n return new Promise((resolve, reject) => {\n this.withQueryRunner(queryRunner => {\n this.deleteExecutedMigration(queryRunner, migration)\n .then(resolve)\n .catch(reject);\n });\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 = this.queryRunner || this.connection.createQueryRunner();\n // create migrations table if its not created yet\n await this.createMigrationsTableIfNotExist(queryRunner);\n // get all migrations that are executed and saved in the database\n const executedMigrations = await this.loadExecutedMigrations(queryRunner);\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(executedMigration => executedMigration.name === migration.name);\n\n if (executedMigration) {\n this.connection.logger.logSchemaBuild(` [X] ${migration.name}`);\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\n const queryRunner = this.queryRunner || this.connection.createQueryRunner();\n // create migrations table if its not created yet\n await this.createMigrationsTableIfNotExist(queryRunner);\n // get all migrations that are executed and saved in the database\n const executedMigrations = await this.loadExecutedMigrations(queryRunner);\n\n // get the time when last migration was executed\n let lastTimeExecutedMigration = 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 successefuly\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(executedMigration => executedMigration.name === migration.name);\n if (executedMigration)\n 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)\n await queryRunner.release();\n return [];\n }\n\n // log information about migration execution\n this.connection.logger.logSchemaBuild(`${executedMigrations.length} migrations are already loaded in the database.`);\n this.connection.logger.logSchemaBuild(`${allMigrations.length} migrations were found in the source code.`);\n if (lastTimeExecutedMigration)\n this.connection.logger.logSchemaBuild(`${lastTimeExecutedMigration.name} is the last executed migration. It was executed on ${new Date(lastTimeExecutedMigration.timestamp).toString()}.`);\n this.connection.logger.logSchemaBuild(`${pendingMigrations.length} migrations are new migrations that needs to be executed.`);\n\n // start transaction if its not started yet\n let transactionStartedByUs = false;\n if (this.transaction === \"all\" && !queryRunner.isTransactionActive) {\n await queryRunner.startTransaction();\n transactionStartedByUs = true;\n }\n\n // run all pending migrations in a sequence\n try {\n for (const migration of pendingMigrations) {\n if (this.transaction === \"each\" && !queryRunner.isTransactionActive) {\n await queryRunner.startTransaction();\n transactionStartedByUs = true;\n }\n\n await migration.instance!.up(queryRunner)\n .then(async () => { // now when migration is executed we need to insert record about it into the database\n await this.insertExecutedMigration(queryRunner, migration);\n // commit transaction if we started it\n if (this.transaction === \"each\" && transactionStartedByUs)\n await queryRunner.commitTransaction();\n })\n .then(() => { // informative log about migration success\n successMigrations.push(migration);\n this.connection.logger.logSchemaBuild(`Migration ${migration.name} has been executed successfully.`);\n });\n }\n\n // commit transaction if we started it\n if (this.transaction === \"all\" && transactionStartedByUs)\n await queryRunner.commitTransaction();\n\n } catch (err) { // rollback transaction if we started it\n if (transactionStartedByUs) {\n try { // we throw original error even if rollback thrown an error\n await queryRunner.rollbackTransaction();\n } catch (rollbackError) { }\n }\n\n throw err;\n\n } finally {\n\n // if query runner was created by us then release it\n if (!this.queryRunner)\n await queryRunner.release();\n }\n return successMigrations;\n\n }\n\n /**\n * Reverts last migration that were run.\n */\n async undoLastMigration(): Promise<void> {\n\n const queryRunner = this.queryRunner || this.connection.createQueryRunner();\n\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(queryRunner);\n\n // get the time when last migration was executed\n let lastTimeExecutedMigration = this.getLatestExecutedMigration(executedMigrations);\n\n // if no migrations found in the database then nothing to revert\n if (!lastTimeExecutedMigration) {\n this.connection.logger.logSchemaBuild(`No migrations was found in the database. Nothing to revert!`);\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(migration => migration.name === lastTimeExecutedMigration!.name);\n\n // if no migrations found in the database then nothing to revert\n if (!migrationToRevert)\n throw new TypeORMError(`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 // log information about migration execution\n this.connection.logger.logSchemaBuild(`${executedMigrations.length} migrations are already loaded in the database.`);\n this.connection.logger.logSchemaBuild(`${lastTimeExecutedMigration.name} is the last executed migration. It was executed on ${new Date(lastTimeExecutedMigration.timestamp).toString()}.`);\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 await migrationToRevert.instance!.down(queryRunner);\n await this.deleteExecutedMigration(queryRunner, migrationToRevert);\n this.connection.logger.logSchemaBuild(`Migration ${migrationToRevert.name} has been reverted successfully.`);\n\n // commit transaction if we started it\n if (transactionStartedByUs)\n await queryRunner.commitTransaction();\n\n } catch (err) { // rollback transaction if we started it\n if (transactionStartedByUs) {\n try { // we throw original error even if rollback thrown an error\n await queryRunner.rollbackTransaction();\n } catch (rollbackError) { }\n }\n\n throw err;\n\n } finally {\n\n // if query runner was created by us then release it\n if (!this.queryRunner)\n 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(queryRunner: QueryRunner): Promise<void> {\n // If driver is mongo no need to create\n if (this.connection.driver instanceof MongoDriver) {\n return;\n }\n const tableExist = await queryRunner.hasTable(this.migrationsTable); // todo: table name should be configurable\n if (!tableExist) {\n await queryRunner.createTable(new Table(\n {\n database: this.migrationsDatabase,\n schema: this.migrationsSchema,\n name: this.migrationsTable,\n columns: [\n {\n name: \"id\",\n type: this.connection.driver.normalizeType({type: this.connection.driver.mappedDataTypes.migrationId}),\n isGenerated: true,\n generationStrategy: \"increment\",\n isPrimary: true,\n isNullable: false\n },\n {\n name: \"timestamp\",\n type: this.connection.driver.normalizeType({type: this.connection.driver.mappedDataTypes.migrationTimestamp}),\n isPrimary: false,\n isNullable: false\n },\n {\n name: \"name\",\n type: this.connection.driver.normalizeType({type: this.connection.driver.mappedDataTypes.migrationName}),\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(queryRunner: QueryRunner): Promise<Migration[]> {\n if (this.connection.driver instanceof MongoDriver) {\n const mongoRunner = queryRunner as MongoQueryRunner;\n return await mongoRunner.databaseConnection\n .db(this.connection.driver.database!)\n .collection(this.migrationsTableName)\n .find<Migration>()\n .sort({\"_id\": -1})\n .toArray();\n } else {\n const migrationsRaw: ObjectLiteral[] = await this.connection.manager\n .createQueryBuilder(queryRunner)\n .select()\n .orderBy(this.connection.driver.escape(\"id\"), \"DESC\")\n .from(this.migrationsTable, this.migrationsTableName)\n .getRawMany();\n return migrationsRaw.map(migrationRaw => {\n return new Migration(parseInt(migrationRaw[\"id\"]), parseInt(migrationRaw[\"timestamp\"]), migrationRaw[\"name\"]);\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 = migration.name || (migration.constructor as any).name;\n const migrationTimestamp = parseInt(migrationClassName.substr(-13), 10);\n if (!migrationTimestamp || isNaN(migrationTimestamp)) {\n throw new TypeORMError(`${migrationClassName} migration name is wrong. Migration class name should have a JavaScript timestamp appended.`);\n }\n\n return new Migration(undefined, migrationTimestamp, migrationClassName, migration);\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(new Set(migrationNames.filter((migrationName, index) => migrationNames.indexOf(migrationName) < index)));\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(migrations: Migration[]): Migration|undefined {\n const sortedMigrations = migrations.map(migration => migration).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(sortedMigrations: Migration[]): 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(queryRunner: QueryRunner, migration: Migration): Promise<void> {\n const values: ObjectLiteral = {};\n if (this.connection.driver instanceof SqlServerDriver) {\n values[\"timestamp\"] = new MssqlParameter(migration.timestamp, this.connection.driver.normalizeType({ type: this.connection.driver.mappedDataTypes.migrationTimestamp }) as any);\n values[\"name\"] = new MssqlParameter(migration.name, this.connection.driver.normalizeType({ type: this.connection.driver.mappedDataTypes.migrationName }) as any);\n } else {\n values[\"timestamp\"] = migration.timestamp;\n values[\"name\"] = migration.name;\n }\n if (this.connection.driver instanceof MongoDriver) {\n const mongoRunner = queryRunner as MongoQueryRunner;\n await mongoRunner.databaseConnection.db(this.connection.driver.database!).collection(this.migrationsTableName).insertOne(values);\n } else {\n const qb = queryRunner.manager.createQueryBuilder();\n await qb.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(queryRunner: QueryRunner, migration: Migration): Promise<void> {\n\n const conditions: ObjectLiteral = {};\n if (this.connection.driver instanceof SqlServerDriver) {\n conditions[\"timestamp\"] = new MssqlParameter(migration.timestamp, this.connection.driver.normalizeType({ type: this.connection.driver.mappedDataTypes.migrationTimestamp }) as any);\n conditions[\"name\"] = new MssqlParameter(migration.name, this.connection.driver.normalizeType({ type: this.connection.driver.mappedDataTypes.migrationName }) as any);\n } else {\n conditions[\"timestamp\"] = migration.timestamp;\n conditions[\"name\"] = migration.name;\n }\n\n if (this.connection.driver instanceof MongoDriver) {\n const mongoRunner = queryRunner as MongoQueryRunner;\n await mongoRunner.databaseConnection.db(this.connection.driver.database!).collection(this.migrationsTableName).deleteOne(conditions);\n } else {\n const qb = queryRunner.manager.createQueryBuilder();\n await qb.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\n protected async withQueryRunner<T extends any>(callback: (queryRunner: QueryRunner) => T) {\n const queryRunner = this.queryRunner || this.connection.createQueryRunner();\n\n try {\n return callback(queryRunner);\n } finally {\n if (!this.queryRunner) {\n await queryRunner.release();\n }\n }\n }\n}\n"],"sourceRoot":".."}
|
|
1
|
+
{"version":3,"sources":["../../src/migration/MigrationExecutor.ts"],"names":[],"mappings":";;;;AAAA,uDAAoD;AAEpD,yCAAsC;AAGtC,uEAAoE;AACpE,qEAAkE;AAClE,6DAA0D;AAE1D,kCAAwC;AAExC;;GAEG;AACH;IAuBI,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,2BAAsB,UAAsB,EACtB,WAAyB;QADzB,eAAU,GAAV,UAAU,CAAY;QACtB,gBAAW,GAAX,WAAW,CAAc;QA1B/C,4EAA4E;QAC5E,oBAAoB;QACpB,4EAA4E;QAE5E;;;;;WAKG;QACH,gBAAW,GAA4B,KAAK,CAAC;QAkBjC,IAAA,MAAM,GAAK,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,OAAc,OAA1C,CAA2C;QACzD,IAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC;QACjD,IAAI,CAAC,kBAAkB,GAAG,QAAQ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,CA3eA,AA2eC,IAAA;AA3eY,8CAAiB","file":"MigrationExecutor.js","sourcesContent":["import {Table} from \"../schema-builder/table/Table\";\nimport {Connection} from \"../connection/Connection\";\nimport {Migration} from \"./Migration\";\nimport {ObjectLiteral} from \"../common/ObjectLiteral\";\nimport {QueryRunner} from \"../query-runner/QueryRunner\";\nimport {SqlServerDriver} from \"../driver/sqlserver/SqlServerDriver\";\nimport {MssqlParameter} from \"../driver/sqlserver/MssqlParameter\";\nimport {MongoDriver} from \"../driver/mongodb/MongoDriver\";\nimport {MongoQueryRunner} from \"../driver/mongodb/MongoQueryRunner\";\nimport { TypeORMError } from \"../error\";\n\n/**\n * Executes migrations: runs pending and reverts previously executed migrations.\n */\nexport class MigrationExecutor {\n\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 // 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(protected connection: Connection,\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 = connection.options.migrationsTableName || \"migrations\";\n this.migrationsTable = this.connection.driver.buildTableName(this.migrationsTableName, schema, database);\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 await (migration.instance as any).up(queryRunner);\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(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 => this.insertExecutedMigration(q, migration));\n }\n\n /**\n * Deletes an executed migration.\n */\n public deleteMigration(migration: Migration): Promise<void> {\n return this.withQueryRunner(q => this.deleteExecutedMigration(q, migration));\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 = this.queryRunner || this.connection.createQueryRunner();\n // create migrations table if its not created yet\n await this.createMigrationsTableIfNotExist(queryRunner);\n // get all migrations that are executed and saved in the database\n const executedMigrations = await this.loadExecutedMigrations(queryRunner);\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(executedMigration => executedMigration.name === migration.name);\n\n if (executedMigration) {\n this.connection.logger.logSchemaBuild(` [X] ${migration.name}`);\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\n const queryRunner = this.queryRunner || this.connection.createQueryRunner();\n // create migrations table if its not created yet\n await this.createMigrationsTableIfNotExist(queryRunner);\n // get all migrations that are executed and saved in the database\n const executedMigrations = await this.loadExecutedMigrations(queryRunner);\n\n // get the time when last migration was executed\n let lastTimeExecutedMigration = 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 successefuly\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(executedMigration => executedMigration.name === migration.name);\n if (executedMigration)\n 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)\n await queryRunner.release();\n return [];\n }\n\n // log information about migration execution\n this.connection.logger.logSchemaBuild(`${executedMigrations.length} migrations are already loaded in the database.`);\n this.connection.logger.logSchemaBuild(`${allMigrations.length} migrations were found in the source code.`);\n if (lastTimeExecutedMigration)\n this.connection.logger.logSchemaBuild(`${lastTimeExecutedMigration.name} is the last executed migration. It was executed on ${new Date(lastTimeExecutedMigration.timestamp).toString()}.`);\n this.connection.logger.logSchemaBuild(`${pendingMigrations.length} migrations are new migrations that needs to be executed.`);\n\n // start transaction if its not started yet\n let transactionStartedByUs = false;\n if (this.transaction === \"all\" && !queryRunner.isTransactionActive) {\n await queryRunner.startTransaction();\n transactionStartedByUs = true;\n }\n\n // run all pending migrations in a sequence\n try {\n for (const migration of pendingMigrations) {\n if (this.transaction === \"each\" && !queryRunner.isTransactionActive) {\n await queryRunner.startTransaction();\n transactionStartedByUs = true;\n }\n\n await migration.instance!.up(queryRunner)\n .catch(error => { // informative log about migration failure\n this.connection.logger.logMigration(`Migration \"${migration.name}\" has been failed, error: ${error?.message}`);\n throw error;\n })\n .then(async () => { // now when migration is executed we need to insert record about it into the database\n await this.insertExecutedMigration(queryRunner, migration);\n // commit transaction if we started it\n if (this.transaction === \"each\" && transactionStartedByUs)\n await queryRunner.commitTransaction();\n })\n .then(() => { // informative log about migration success\n successMigrations.push(migration);\n this.connection.logger.logSchemaBuild(`Migration ${migration.name} has been executed successfully.`);\n });\n }\n\n // commit transaction if we started it\n if (this.transaction === \"all\" && transactionStartedByUs)\n await queryRunner.commitTransaction();\n\n } catch (err) { // rollback transaction if we started it\n if (transactionStartedByUs) {\n try { // we throw original error even if rollback thrown an error\n await queryRunner.rollbackTransaction();\n } catch (rollbackError) { }\n }\n\n throw err;\n\n } finally {\n\n // if query runner was created by us then release it\n if (!this.queryRunner)\n await queryRunner.release();\n }\n return successMigrations;\n\n }\n\n /**\n * Reverts last migration that were run.\n */\n async undoLastMigration(): Promise<void> {\n\n const queryRunner = this.queryRunner || this.connection.createQueryRunner();\n\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(queryRunner);\n\n // get the time when last migration was executed\n let lastTimeExecutedMigration = this.getLatestExecutedMigration(executedMigrations);\n\n // if no migrations found in the database then nothing to revert\n if (!lastTimeExecutedMigration) {\n this.connection.logger.logSchemaBuild(`No migrations was found in the database. Nothing to revert!`);\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(migration => migration.name === lastTimeExecutedMigration!.name);\n\n // if no migrations found in the database then nothing to revert\n if (!migrationToRevert)\n throw new TypeORMError(`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 // log information about migration execution\n this.connection.logger.logSchemaBuild(`${executedMigrations.length} migrations are already loaded in the database.`);\n this.connection.logger.logSchemaBuild(`${lastTimeExecutedMigration.name} is the last executed migration. It was executed on ${new Date(lastTimeExecutedMigration.timestamp).toString()}.`);\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 await migrationToRevert.instance!.down(queryRunner);\n await this.deleteExecutedMigration(queryRunner, migrationToRevert);\n this.connection.logger.logSchemaBuild(`Migration ${migrationToRevert.name} has been reverted successfully.`);\n\n // commit transaction if we started it\n if (transactionStartedByUs)\n await queryRunner.commitTransaction();\n\n } catch (err) { // rollback transaction if we started it\n if (transactionStartedByUs) {\n try { // we throw original error even if rollback thrown an error\n await queryRunner.rollbackTransaction();\n } catch (rollbackError) { }\n }\n\n throw err;\n\n } finally {\n\n // if query runner was created by us then release it\n if (!this.queryRunner)\n 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(queryRunner: QueryRunner): Promise<void> {\n // If driver is mongo no need to create\n if (this.connection.driver instanceof MongoDriver) {\n return;\n }\n const tableExist = await queryRunner.hasTable(this.migrationsTable); // todo: table name should be configurable\n if (!tableExist) {\n await queryRunner.createTable(new Table(\n {\n database: this.migrationsDatabase,\n schema: this.migrationsSchema,\n name: this.migrationsTable,\n columns: [\n {\n name: \"id\",\n type: this.connection.driver.normalizeType({type: this.connection.driver.mappedDataTypes.migrationId}),\n isGenerated: true,\n generationStrategy: \"increment\",\n isPrimary: true,\n isNullable: false\n },\n {\n name: \"timestamp\",\n type: this.connection.driver.normalizeType({type: this.connection.driver.mappedDataTypes.migrationTimestamp}),\n isPrimary: false,\n isNullable: false\n },\n {\n name: \"name\",\n type: this.connection.driver.normalizeType({type: this.connection.driver.mappedDataTypes.migrationName}),\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(queryRunner: QueryRunner): Promise<Migration[]> {\n if (this.connection.driver instanceof MongoDriver) {\n const mongoRunner = queryRunner as MongoQueryRunner;\n return await mongoRunner.databaseConnection\n .db(this.connection.driver.database!)\n .collection(this.migrationsTableName)\n .find<Migration>()\n .sort({\"_id\": -1})\n .toArray();\n } else {\n const migrationsRaw: ObjectLiteral[] = await this.connection.manager\n .createQueryBuilder(queryRunner)\n .select()\n .orderBy(this.connection.driver.escape(\"id\"), \"DESC\")\n .from(this.migrationsTable, this.migrationsTableName)\n .getRawMany();\n return migrationsRaw.map(migrationRaw => {\n return new Migration(parseInt(migrationRaw[\"id\"]), parseInt(migrationRaw[\"timestamp\"]), migrationRaw[\"name\"]);\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 = migration.name || (migration.constructor as any).name;\n const migrationTimestamp = parseInt(migrationClassName.substr(-13), 10);\n if (!migrationTimestamp || isNaN(migrationTimestamp)) {\n throw new TypeORMError(`${migrationClassName} migration name is wrong. Migration class name should have a JavaScript timestamp appended.`);\n }\n\n return new Migration(undefined, migrationTimestamp, migrationClassName, migration);\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(new Set(migrationNames.filter((migrationName, index) => migrationNames.indexOf(migrationName) < index)));\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(migrations: Migration[]): Migration|undefined {\n const sortedMigrations = migrations.map(migration => migration).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(sortedMigrations: Migration[]): 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(queryRunner: QueryRunner, migration: Migration): Promise<void> {\n const values: ObjectLiteral = {};\n if (this.connection.driver instanceof SqlServerDriver) {\n values[\"timestamp\"] = new MssqlParameter(migration.timestamp, this.connection.driver.normalizeType({ type: this.connection.driver.mappedDataTypes.migrationTimestamp }) as any);\n values[\"name\"] = new MssqlParameter(migration.name, this.connection.driver.normalizeType({ type: this.connection.driver.mappedDataTypes.migrationName }) as any);\n } else {\n values[\"timestamp\"] = migration.timestamp;\n values[\"name\"] = migration.name;\n }\n if (this.connection.driver instanceof MongoDriver) {\n const mongoRunner = queryRunner as MongoQueryRunner;\n await mongoRunner.databaseConnection.db(this.connection.driver.database!).collection(this.migrationsTableName).insertOne(values);\n } else {\n const qb = queryRunner.manager.createQueryBuilder();\n await qb.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(queryRunner: QueryRunner, migration: Migration): Promise<void> {\n\n const conditions: ObjectLiteral = {};\n if (this.connection.driver instanceof SqlServerDriver) {\n conditions[\"timestamp\"] = new MssqlParameter(migration.timestamp, this.connection.driver.normalizeType({ type: this.connection.driver.mappedDataTypes.migrationTimestamp }) as any);\n conditions[\"name\"] = new MssqlParameter(migration.name, this.connection.driver.normalizeType({ type: this.connection.driver.mappedDataTypes.migrationName }) as any);\n } else {\n conditions[\"timestamp\"] = migration.timestamp;\n conditions[\"name\"] = migration.name;\n }\n\n if (this.connection.driver instanceof MongoDriver) {\n const mongoRunner = queryRunner as MongoQueryRunner;\n await mongoRunner.databaseConnection.db(this.connection.driver.database!).collection(this.migrationsTableName).deleteOne(conditions);\n } else {\n const qb = queryRunner.manager.createQueryBuilder();\n await qb.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\n protected async withQueryRunner<T extends any>(callback: (queryRunner: QueryRunner) => T | Promise<T>) {\n const queryRunner = this.queryRunner || this.connection.createQueryRunner();\n\n try {\n return callback(queryRunner);\n } finally {\n if (!this.queryRunner) {\n await queryRunner.release();\n }\n }\n }\n}\n"],"sourceRoot":".."}
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{ "name": "typeorm", "private": false, "version": "0.2.39-dev.
|
|
1
|
+
{ "name": "typeorm", "private": false, "version": "0.2.39-dev.6558295", "description": "Data-Mapper ORM for TypeScript, ES7, ES6, ES5. Supports MySQL, PostgreSQL, MariaDB, SQLite, MS SQL Server, Oracle, MongoDB databases.", "license": "MIT", "readmeFilename": "README.md", "author": { "name": "Umed Khudoiberdiev", "email": "pleerock.me@gmail.com" }, "main": "./index.js", "browser": { "./browser/driver/aurora-data-api/AuroraDataApiDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/cockroachdb/CockroachDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/postgres/PostgresDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/oracle/OracleDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/sap/SapDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/mysql/MysqlDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/sqlserver/SqlServerDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/mongodb/MongoDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/mongodb/MongoQueryRunner.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/entity-manager/MongoEntityManager.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/repository/MongoRepository.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/sqlite/SqliteDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/better-sqlite3/BetterSqlite3Driver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/util/DirectoryExportedClassesLoader.js": "./browser/platform/BrowserDirectoryExportedClassesLoader.js", "./browser/logger/FileLogger.js": "./browser/platform/BrowserFileLoggerDummy.js", "./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/platform/PlatformTools.js": "./browser/platform/BrowserPlatformTools.js", "./index.js": "./browser/index.js" }, "repository": { "type": "git", "url": "https://github.com/typeorm/typeorm.git" }, "bugs": { "url": "https://github.com/typeorm/typeorm/issues" }, "tags": [ "orm", "typescript", "typescript-orm", "mysql", "mysql-orm", "postgresql", "postgresql-orm", "mariadb", "mariadb-orm", "sqlite", "sqlite-orm", "sql-server", "sql-server-orm", "oracle", "oracle-orm" ], "devDependencies": { "@types/app-root-path": "^1.2.4", "@types/chai": "^4.2.15", "@types/chai-as-promised": "^7.1.3", "@types/debug": "^4.1.5", "@types/dotenv": "^8.2.0", "@types/js-yaml": "^4.0.0", "@types/mkdirp": "^1.0.1", "@types/mocha": "^8.2.1", "@types/node": "^14.14.31", "@types/rimraf": "^3.0.0", "@types/sha.js": "^2.4.0", "@types/sinon": "^9.0.10", "@types/source-map-support": "^0.5.3", "@types/xml2js": "^0.4.8", "@types/yargs": "^17.0.2", "@typescript-eslint/eslint-plugin": "^4.15.2", "@typescript-eslint/parser": "^4.15.2", "better-sqlite3": "^7.1.2", "chai": "^4.3.0", "chai-as-promised": "^7.1.1", "class-transformer": "^0.4.0", "conventional-changelog-angular": "^5.0.12", "conventional-changelog-cli": "^2.1.1", "del": "^6.0.0", "eslint": "^7.20.0", "gulp": "^4.0.2", "gulp-eslint": "^6.0.0", "gulp-istanbul": "^1.1.3", "gulp-mocha": "^8.0.0", "gulp-rename": "^2.0.0", "gulp-replace": "^1.0.0", "gulp-shell": "^0.8.0", "gulp-sourcemaps": "^3.0.0", "gulp-typescript": "^6.0.0-alpha.1", "gulpclass": "^0.2.0", "husky": "^5.1.1", "lint-staged": "^10.5.4", "mocha": "^8.3.0", "mongodb": "^3.6.4", "mssql": "^6.3.1", "mysql": "^2.18.1", "mysql2": "^2.2.5", "oracledb": "^5.1.0", "pg": "^8.5.1", "pg-query-stream": "^4.0.0", "redis": "^3.1.1", "remap-istanbul": "^0.13.0", "rimraf": "^3.0.2", "sinon": "^9.2.4", "sinon-chai": "^3.5.0", "source-map-support": "^0.5.19", "sql.js": "^1.4.0", "sqlite3": "^5.0.2", "ts-node": "^9.1.1", "typeorm-aurora-data-api-driver": "^2.0.0", "typescript": "^4.2.2" }, "peerDependencies": { "@sap/hana-client": "*", "better-sqlite3": "*", "hdb-pool": "*", "ioredis": "*", "mongodb": "^3.6.0", "mssql": "*", "mysql2": "*", "oracledb": "*", "pg": "*", "pg-native": "*", "pg-query-stream": "*", "redis": "*", "sql.js": "*", "sqlite3": "*", "typeorm-aurora-data-api-driver": "*" }, "peerDependenciesMeta": { "@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 }, "typeorm-aurora-data-api-driver": { "optional": true } }, "dependencies": { "@sqltools/formatter": "^1.2.2", "app-root-path": "^3.0.0", "buffer": "^6.0.3", "chalk": "^4.1.0", "cli-highlight": "^2.1.11", "debug": "^4.3.1", "dotenv": "^8.2.0", "glob": "^7.1.6", "js-yaml": "^4.0.0", "mkdirp": "^1.0.4", "reflect-metadata": "^0.1.13", "sha.js": "^2.4.11", "tslib": "^2.1.0", "xml2js": "^0.4.23", "yargs": "^17.0.1", "zen-observable-ts": "^1.0.0" }, "lint-staged": { "*.ts": [ "eslint --fix", "git add" ] }, "scripts": { "test": "rimraf ./build && tsc && mocha --file ./build/compiled/test/utils/test-setup.js --bail --recursive --timeout 60000 ./build/compiled/test", "test-fast": "mocha --file ./build/compiled/test/utils/test-setup.js --bail --recursive --timeout 60000 ./build/compiled/test", "compile": "rimraf ./build && tsc", "watch": "./node_modules/.bin/tsc -w", "package": "gulp package", "lint": "eslint -c ./.eslintrc.js src/**/*.ts test/**/*.ts sample/**/*.ts", "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 1" }, "bin": { "typeorm": "./cli.js" }, "funding": "https://opencollective.com/typeorm", "collective": { "type": "opencollective", "url": "https://opencollective.com/typeorm", "logo": "https://opencollective.com/opencollective/logo.txt" }, "nyc": { "all": true, "cache": false, "exclude": [ "**/*.d.ts" ], "extension": [ ".ts" ], "include": [ "build/compiled/src/**", "src/**" ], "reporter": "json" } }
|
|
@@ -531,7 +531,7 @@ var SubjectExecutor = /** @class */ (function () {
|
|
|
531
531
|
}
|
|
532
532
|
finally { if (e_3) throw e_3.error; }
|
|
533
533
|
}
|
|
534
|
-
nestedSetPromise = new Promise(function (
|
|
534
|
+
nestedSetPromise = new Promise(function (ok, fail) { return (0, tslib_1.__awaiter)(_this, void 0, void 0, function () {
|
|
535
535
|
var nestedSetSubjects_1, nestedSetSubjects_1_1, subject, error_1, e_4_1;
|
|
536
536
|
var e_4, _a;
|
|
537
537
|
return (0, tslib_1.__generator)(this, function (_b) {
|
|
@@ -552,7 +552,7 @@ var SubjectExecutor = /** @class */ (function () {
|
|
|
552
552
|
return [3 /*break*/, 5];
|
|
553
553
|
case 4:
|
|
554
554
|
error_1 = _b.sent();
|
|
555
|
-
|
|
555
|
+
fail(error_1);
|
|
556
556
|
return [3 /*break*/, 5];
|
|
557
557
|
case 5:
|
|
558
558
|
nestedSetSubjects_1_1 = nestedSetSubjects_1.next();
|
|
@@ -569,7 +569,7 @@ var SubjectExecutor = /** @class */ (function () {
|
|
|
569
569
|
finally { if (e_4) throw e_4.error; }
|
|
570
570
|
return [7 /*endfinally*/];
|
|
571
571
|
case 9:
|
|
572
|
-
|
|
572
|
+
ok();
|
|
573
573
|
return [2 /*return*/];
|
|
574
574
|
}
|
|
575
575
|
});
|