typeorm 0.3.15-dev.f6a3ce7 → 0.3.16-dev.68aa573
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/cache/DbQueryResultCache.d.ts +1 -1
- package/browser/cache/DbQueryResultCache.js +1 -1
- package/browser/cache/DbQueryResultCache.js.map +1 -1
- package/browser/cache/QueryResultCacheOptions.d.ts +2 -2
- package/browser/cache/QueryResultCacheOptions.js.map +1 -1
- package/browser/cache/RedisQueryResultCache.d.ts +1 -1
- package/browser/cache/RedisQueryResultCache.js +1 -1
- package/browser/cache/RedisQueryResultCache.js.map +1 -1
- package/browser/driver/sqlite-abstract/AbstractSqliteDriver.js +6 -10
- package/browser/driver/sqlite-abstract/AbstractSqliteDriver.js.map +1 -1
- package/browser/metadata-builder/RelationJoinColumnBuilder.d.ts +1 -1
- package/browser/metadata-builder/RelationJoinColumnBuilder.js +18 -20
- package/browser/metadata-builder/RelationJoinColumnBuilder.js.map +1 -1
- package/browser/query-builder/SelectQueryBuilder.d.ts +1 -1
- package/browser/query-builder/SelectQueryBuilder.js +3 -2
- package/browser/query-builder/SelectQueryBuilder.js.map +1 -1
- package/browser/schema-builder/RdbmsSchemaBuilder.js +1 -1
- package/browser/schema-builder/RdbmsSchemaBuilder.js.map +1 -1
- package/cache/DbQueryResultCache.d.ts +1 -1
- package/cache/DbQueryResultCache.js +1 -1
- package/cache/DbQueryResultCache.js.map +1 -1
- package/cache/QueryResultCacheOptions.d.ts +2 -2
- package/cache/QueryResultCacheOptions.js.map +1 -1
- package/cache/RedisQueryResultCache.d.ts +1 -1
- package/cache/RedisQueryResultCache.js +1 -1
- package/cache/RedisQueryResultCache.js.map +1 -1
- package/driver/sqlite-abstract/AbstractSqliteDriver.js +6 -10
- package/driver/sqlite-abstract/AbstractSqliteDriver.js.map +1 -1
- package/metadata-builder/RelationJoinColumnBuilder.d.ts +1 -1
- package/metadata-builder/RelationJoinColumnBuilder.js +18 -20
- package/metadata-builder/RelationJoinColumnBuilder.js.map +1 -1
- package/package.json +1 -1
- package/query-builder/SelectQueryBuilder.d.ts +1 -1
- package/query-builder/SelectQueryBuilder.js +3 -2
- package/query-builder/SelectQueryBuilder.js.map +1 -1
- package/schema-builder/RdbmsSchemaBuilder.js +1 -1
- package/schema-builder/RdbmsSchemaBuilder.js.map +1 -1
|
@@ -256,7 +256,7 @@ export class RdbmsSchemaBuilder {
|
|
|
256
256
|
continue;
|
|
257
257
|
const renamedColumn = renamedTableColumns[0].clone();
|
|
258
258
|
renamedColumn.name = renamedMetadataColumns[0].databaseName;
|
|
259
|
-
this.connection.logger.logSchemaBuild(`renaming column "${renamedTableColumns[0].name}" in to "${renamedColumn.name}"`);
|
|
259
|
+
this.connection.logger.logSchemaBuild(`renaming column "${renamedTableColumns[0].name}" in "${table.name}" to "${renamedColumn.name}"`);
|
|
260
260
|
await this.queryRunner.renameColumn(table, renamedTableColumns[0], renamedColumn);
|
|
261
261
|
}
|
|
262
262
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../browser/src/schema-builder/RdbmsSchemaBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAO/C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAE9C,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AACvD,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC5C,OAA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iBACZ;aACJ;SACJ,CAAC,EACF,IAAI,CACP,CAAA;IACL,CAAC;CACJ","file":"RdbmsSchemaBuilder.js","sourcesContent":["import { Table } from \"./table/Table\"\nimport { TableColumn } from \"./table/TableColumn\"\nimport { TableForeignKey } from \"./table/TableForeignKey\"\nimport { TableIndex } from \"./table/TableIndex\"\nimport { QueryRunner } from \"../query-runner/QueryRunner\"\nimport { ColumnMetadata } from \"../metadata/ColumnMetadata\"\nimport { EntityMetadata } from \"../metadata/EntityMetadata\"\nimport { DataSource } from \"../data-source/DataSource\"\nimport { SchemaBuilder } from \"./SchemaBuilder\"\nimport { SqlInMemory } from \"../driver/SqlInMemory\"\nimport { TableUtils } from \"./util/TableUtils\"\nimport { TableColumnOptions } from \"./options/TableColumnOptions\"\nimport { TableUnique } from \"./table/TableUnique\"\nimport { TableCheck } from \"./table/TableCheck\"\nimport { TableExclusion } from \"./table/TableExclusion\"\nimport { View } from \"./view/View\"\nimport { ViewUtils } from \"./util/ViewUtils\"\nimport { DriverUtils } from \"../driver/DriverUtils\"\nimport { PostgresQueryRunner } from \"../driver/postgres/PostgresQueryRunner\"\n\n/**\n * Creates complete tables schemas in the database based on the entity metadatas.\n *\n * Steps how schema is being built:\n * 1. load list of all tables with complete column and keys information from the db\n * 2. drop all (old) foreign keys that exist in the table, but does not exist in the metadata\n * 3. create new tables that does not exist in the db, but exist in the metadata\n * 4. drop all columns exist (left old) in the db table, but does not exist in the metadata\n * 5. add columns from metadata which does not exist in the table\n * 6. update all exist columns which metadata has changed\n * 7. update primary keys - update old and create new primary key from changed columns\n * 8. create foreign keys which does not exist in the table yet\n * 9. create indices which are missing in db yet, and drops indices which exist in the db, but does not exist in the metadata anymore\n */\nexport class RdbmsSchemaBuilder implements SchemaBuilder {\n readonly \"@instanceof\" = Symbol.for(\"RdbmsSchemaBuilder\")\n\n /**\n * Used to execute schema creation queries in a single connection.\n */\n protected queryRunner: QueryRunner\n\n private currentDatabase?: string\n\n private currentSchema?: string\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(protected connection: DataSource) {}\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Creates complete schemas for the given entity metadatas.\n */\n async build(): Promise<void> {\n this.queryRunner = this.connection.createQueryRunner()\n\n // this.connection.driver.database || this.currentDatabase;\n this.currentDatabase = this.connection.driver.database\n this.currentSchema = this.connection.driver.schema\n\n // CockroachDB implements asynchronous schema sync operations which can not been executed in transaction.\n // E.g. if you try to DROP column and ADD it again in the same transaction, crdb throws error.\n // In Spanner queries against the INFORMATION_SCHEMA can be used in a read-only transaction,\n // but not in a read-write transaction.\n const isUsingTransactions =\n !(this.connection.driver.options.type === \"cockroachdb\") &&\n !(this.connection.driver.options.type === \"spanner\") &&\n this.connection.options.migrationsTransactionMode !== \"none\"\n\n await this.queryRunner.beforeMigration()\n\n if (isUsingTransactions) {\n await this.queryRunner.startTransaction()\n }\n\n try {\n await this.createMetadataTableIfNecessary(this.queryRunner)\n // Flush the queryrunner table & view cache\n const tablePaths = this.entityToSyncMetadatas.map((metadata) =>\n this.getTablePath(metadata),\n )\n const viewPaths = this.viewEntityToSyncMetadatas.map((metadata) =>\n this.getTablePath(metadata),\n )\n\n await this.queryRunner.getTables(tablePaths)\n await this.queryRunner.getViews(viewPaths)\n\n await this.executeSchemaSyncOperationsInProperOrder()\n\n // if cache is enabled then perform cache-synchronization as well\n if (this.connection.queryResultCache)\n await this.connection.queryResultCache.synchronize(\n this.queryRunner,\n )\n\n if (isUsingTransactions) {\n await this.queryRunner.commitTransaction()\n }\n } catch (error) {\n try {\n // we throw original error even if rollback thrown an error\n if (isUsingTransactions) {\n await this.queryRunner.rollbackTransaction()\n }\n } catch (rollbackError) {}\n throw error\n } finally {\n await this.queryRunner.afterMigration()\n\n await this.queryRunner.release()\n }\n }\n\n /**\n * Create the typeorm_metadata table if necessary.\n */\n async createMetadataTableIfNecessary(\n queryRunner: QueryRunner,\n ): Promise<void> {\n if (\n this.viewEntityToSyncMetadatas.length > 0 ||\n this.hasGeneratedColumns()\n ) {\n await this.createTypeormMetadataTable(queryRunner)\n }\n }\n\n /**\n * Returns sql queries to be executed by schema builder.\n */\n async log(): Promise<SqlInMemory> {\n this.queryRunner = this.connection.createQueryRunner()\n try {\n // Flush the queryrunner table & view cache\n const tablePaths = this.entityToSyncMetadatas.map((metadata) =>\n this.getTablePath(metadata),\n )\n const viewPaths = this.viewEntityToSyncMetadatas.map((metadata) =>\n this.getTablePath(metadata),\n )\n await this.queryRunner.getTables(tablePaths)\n await this.queryRunner.getViews(viewPaths)\n\n this.queryRunner.enableSqlMemory()\n await this.executeSchemaSyncOperationsInProperOrder()\n\n // if cache is enabled then perform cache-synchronization as well\n if (this.connection.queryResultCache)\n // todo: check this functionality\n await this.connection.queryResultCache.synchronize(\n this.queryRunner,\n )\n\n return this.queryRunner.getMemorySql()\n } finally {\n // its important to disable this mode despite the fact we are release query builder\n // because there exist drivers which reuse same query runner. Also its important to disable\n // sql memory after call of getMemorySql() method because last one flushes sql memory.\n this.queryRunner.disableSqlMemory()\n await this.queryRunner.release()\n }\n }\n\n // -------------------------------------------------------------------------\n // Protected Methods\n // -------------------------------------------------------------------------\n\n /**\n * Returns only entities that should be synced in the database.\n */\n protected get entityToSyncMetadatas(): EntityMetadata[] {\n return this.connection.entityMetadatas.filter(\n (metadata) =>\n metadata.synchronize &&\n metadata.tableType !== \"entity-child\" &&\n metadata.tableType !== \"view\",\n )\n }\n\n /**\n * Returns only entities that should be synced in the database.\n */\n protected get viewEntityToSyncMetadatas(): EntityMetadata[] {\n return (\n this.connection.entityMetadatas\n .filter(\n (metadata) =>\n metadata.tableType === \"view\" && metadata.synchronize,\n )\n // sort views in creation order by dependencies\n .sort(ViewUtils.viewMetadataCmp)\n )\n }\n\n /**\n * Checks if there are at least one generated column.\n */\n protected hasGeneratedColumns(): boolean {\n return this.connection.entityMetadatas.some((entityMetadata) => {\n return entityMetadata.columns.some((column) => column.generatedType)\n })\n }\n\n /**\n * Executes schema sync operations in a proper order.\n * Order of operations matter here.\n */\n protected async executeSchemaSyncOperationsInProperOrder(): Promise<void> {\n await this.dropOldViews()\n await this.dropOldForeignKeys()\n await this.dropOldIndices()\n await this.dropOldChecks()\n await this.dropOldExclusions()\n await this.dropCompositeUniqueConstraints()\n // await this.renameTables();\n await this.renameColumns()\n await this.createNewTables()\n await this.dropRemovedColumns()\n await this.addNewColumns()\n await this.updatePrimaryKeys()\n await this.updateExistColumns()\n await this.createNewIndices()\n await this.createNewChecks()\n await this.createNewExclusions()\n await this.createCompositeUniqueConstraints()\n await this.createForeignKeys()\n await this.createViews()\n await this.createNewViewIndices()\n }\n\n private getTablePath(\n target: EntityMetadata | Table | View | TableForeignKey | string,\n ): string {\n const parsed = this.connection.driver.parseTableName(target)\n\n return this.connection.driver.buildTableName(\n parsed.tableName,\n parsed.schema || this.currentSchema,\n parsed.database || this.currentDatabase,\n )\n }\n\n /**\n * Drops all (old) foreign keys that exist in the tables, but do not exist in the entity metadata.\n */\n protected async dropOldForeignKeys(): Promise<void> {\n for (const metadata of this.entityToSyncMetadatas) {\n const table = this.queryRunner.loadedTables.find(\n (table) =>\n this.getTablePath(table) === this.getTablePath(metadata),\n )\n if (!table) continue\n\n // find foreign keys that exist in the schemas but does not exist in the entity metadata\n const tableForeignKeysToDrop = table.foreignKeys.filter(\n (tableForeignKey) => {\n const metadataFK = metadata.foreignKeys.find(\n (metadataForeignKey) =>\n tableForeignKey.name === metadataForeignKey.name &&\n this.getTablePath(tableForeignKey) ===\n this.getTablePath(\n metadataForeignKey.referencedEntityMetadata,\n ),\n )\n return (\n !metadataFK ||\n (metadataFK.onDelete &&\n metadataFK.onDelete !== tableForeignKey.onDelete) ||\n (metadataFK.onUpdate &&\n metadataFK.onUpdate !== tableForeignKey.onUpdate)\n )\n },\n )\n if (tableForeignKeysToDrop.length === 0) continue\n\n this.connection.logger.logSchemaBuild(\n `dropping old foreign keys of ${\n table.name\n }: ${tableForeignKeysToDrop\n .map((dbForeignKey) => dbForeignKey.name)\n .join(\", \")}`,\n )\n\n // drop foreign keys from the database\n await this.queryRunner.dropForeignKeys(\n table,\n tableForeignKeysToDrop,\n )\n }\n }\n\n /**\n * Rename tables\n */\n protected async renameTables(): Promise<void> {\n // for (const metadata of this.entityToSyncMetadatas) {\n // const table = this.queryRunner.loadedTables.find(table => this.getTablePath(table) === this.getTablePath(metadata));\n // }\n }\n\n /**\n * Renames columns.\n * Works if only one column per table was changed.\n * Changes only column name. If something besides name was changed, these changes will be ignored.\n */\n protected async renameColumns(): Promise<void> {\n for (const metadata of this.entityToSyncMetadatas) {\n const table = this.queryRunner.loadedTables.find(\n (table) =>\n this.getTablePath(table) === this.getTablePath(metadata),\n )\n if (!table) continue\n\n if (metadata.columns.length !== table.columns.length) continue\n\n const renamedMetadataColumns = metadata.columns\n .filter((c) => !c.isVirtualProperty)\n .filter((column) => {\n return !table.columns.find((tableColumn) => {\n return (\n tableColumn.name === column.databaseName &&\n tableColumn.type ===\n this.connection.driver.normalizeType(column) &&\n tableColumn.isNullable === column.isNullable &&\n tableColumn.isUnique ===\n this.connection.driver.normalizeIsUnique(column)\n )\n })\n })\n\n if (\n renamedMetadataColumns.length === 0 ||\n renamedMetadataColumns.length > 1\n )\n continue\n\n const renamedTableColumns = table.columns.filter((tableColumn) => {\n return !metadata.columns.find((column) => {\n return (\n !column.isVirtualProperty &&\n column.databaseName === tableColumn.name &&\n this.connection.driver.normalizeType(column) ===\n tableColumn.type &&\n column.isNullable === tableColumn.isNullable &&\n this.connection.driver.normalizeIsUnique(column) ===\n tableColumn.isUnique\n )\n })\n })\n\n if (\n renamedTableColumns.length === 0 ||\n renamedTableColumns.length > 1\n )\n continue\n\n const renamedColumn = renamedTableColumns[0].clone()\n renamedColumn.name = renamedMetadataColumns[0].databaseName\n\n this.connection.logger.logSchemaBuild(\n `renaming column \"${renamedTableColumns[0].name}\" in to \"${renamedColumn.name}\"`,\n )\n await this.queryRunner.renameColumn(\n table,\n renamedTableColumns[0],\n renamedColumn,\n )\n }\n }\n\n protected async dropOldIndices(): Promise<void> {\n for (const metadata of this.entityToSyncMetadatas) {\n const table = this.queryRunner.loadedTables.find(\n (table) =>\n this.getTablePath(table) === this.getTablePath(metadata),\n )\n if (!table) continue\n\n const dropQueries = table.indices\n .filter((tableIndex) => {\n const indexMetadata = metadata.indices.find(\n (index) => index.name === tableIndex.name,\n )\n if (indexMetadata) {\n if (indexMetadata.synchronize === false) return false\n\n if (indexMetadata.isUnique !== tableIndex.isUnique)\n return true\n\n if (indexMetadata.isSpatial !== tableIndex.isSpatial)\n return true\n\n if (\n this.connection.driver.isFullTextColumnTypeSupported() &&\n indexMetadata.isFulltext !== tableIndex.isFulltext\n )\n return true\n\n if (\n indexMetadata.columns.length !==\n tableIndex.columnNames.length\n )\n return true\n\n return !indexMetadata.columns.every(\n (column) =>\n tableIndex.columnNames.indexOf(\n column.databaseName,\n ) !== -1,\n )\n }\n\n return true\n })\n .map(async (tableIndex) => {\n this.connection.logger.logSchemaBuild(\n `dropping an index: \"${tableIndex.name}\" from table ${table.name}`,\n )\n await this.queryRunner.dropIndex(table, tableIndex)\n })\n\n await Promise.all(dropQueries)\n }\n if (this.connection.options.type === \"postgres\") {\n const postgresQueryRunner: PostgresQueryRunner = <\n PostgresQueryRunner\n >this.queryRunner\n for (const metadata of this.viewEntityToSyncMetadatas) {\n const view = this.queryRunner.loadedViews.find(\n (view) =>\n this.getTablePath(view) === this.getTablePath(metadata),\n )\n if (!view) continue\n\n const dropQueries = view.indices\n .filter((tableIndex) => {\n const indexMetadata = metadata.indices.find(\n (index) => index.name === tableIndex.name,\n )\n if (indexMetadata) {\n if (indexMetadata.synchronize === false)\n return false\n\n if (indexMetadata.isUnique !== tableIndex.isUnique)\n return true\n\n if (\n indexMetadata.isSpatial !== tableIndex.isSpatial\n )\n return true\n\n if (\n this.connection.driver.isFullTextColumnTypeSupported() &&\n indexMetadata.isFulltext !==\n tableIndex.isFulltext\n )\n return true\n\n if (\n indexMetadata.columns.length !==\n tableIndex.columnNames.length\n )\n return true\n\n return !indexMetadata.columns.every(\n (column) =>\n tableIndex.columnNames.indexOf(\n column.databaseName,\n ) !== -1,\n )\n }\n\n return true\n })\n .map(async (tableIndex) => {\n this.connection.logger.logSchemaBuild(\n `dropping an index: \"${tableIndex.name}\" from view ${view.name}`,\n )\n await postgresQueryRunner.dropViewIndex(\n view,\n tableIndex,\n )\n })\n\n await Promise.all(dropQueries)\n }\n }\n }\n\n protected async dropOldChecks(): Promise<void> {\n // Mysql does not support check constraints\n if (\n DriverUtils.isMySQLFamily(this.connection.driver) ||\n this.connection.driver.options.type === \"aurora-mysql\"\n )\n return\n\n for (const metadata of this.entityToSyncMetadatas) {\n const table = this.queryRunner.loadedTables.find(\n (table) =>\n this.getTablePath(table) === this.getTablePath(metadata),\n )\n if (!table) continue\n\n const oldChecks = table.checks.filter((tableCheck) => {\n return !metadata.checks.find(\n (checkMetadata) => checkMetadata.name === tableCheck.name,\n )\n })\n\n if (oldChecks.length === 0) continue\n\n this.connection.logger.logSchemaBuild(\n `dropping old check constraint: ${oldChecks\n .map((check) => `\"${check.name}\"`)\n .join(\", \")} from table \"${table.name}\"`,\n )\n await this.queryRunner.dropCheckConstraints(table, oldChecks)\n }\n }\n\n protected async dropCompositeUniqueConstraints(): Promise<void> {\n for (const metadata of this.entityToSyncMetadatas) {\n const table = this.queryRunner.loadedTables.find(\n (table) =>\n this.getTablePath(table) === this.getTablePath(metadata),\n )\n if (!table) continue\n\n const compositeUniques = table.uniques.filter((tableUnique) => {\n return (\n tableUnique.columnNames.length > 1 &&\n !metadata.uniques.find(\n (uniqueMetadata) =>\n uniqueMetadata.name === tableUnique.name,\n )\n )\n })\n\n if (compositeUniques.length === 0) continue\n\n this.connection.logger.logSchemaBuild(\n `dropping old unique constraint: ${compositeUniques\n .map((unique) => `\"${unique.name}\"`)\n .join(\", \")} from table \"${table.name}\"`,\n )\n await this.queryRunner.dropUniqueConstraints(\n table,\n compositeUniques,\n )\n }\n }\n\n protected async dropOldExclusions(): Promise<void> {\n // Only PostgreSQL supports exclusion constraints\n if (!(this.connection.driver.options.type === \"postgres\")) return\n\n for (const metadata of this.entityToSyncMetadatas) {\n const table = this.queryRunner.loadedTables.find(\n (table) =>\n this.getTablePath(table) === this.getTablePath(metadata),\n )\n if (!table) continue\n\n const oldExclusions = table.exclusions.filter((tableExclusion) => {\n return !metadata.exclusions.find(\n (exclusionMetadata) =>\n exclusionMetadata.name === tableExclusion.name,\n )\n })\n\n if (oldExclusions.length === 0) continue\n\n this.connection.logger.logSchemaBuild(\n `dropping old exclusion constraint: ${oldExclusions\n .map((exclusion) => `\"${exclusion.name}\"`)\n .join(\", \")} from table \"${table.name}\"`,\n )\n await this.queryRunner.dropExclusionConstraints(\n table,\n oldExclusions,\n )\n }\n }\n\n /**\n * Creates tables that do not exist in the database yet.\n * New tables are created without foreign and primary keys.\n * Primary key only can be created in conclusion with auto generated column.\n */\n protected async createNewTables(): Promise<void> {\n for (const metadata of this.entityToSyncMetadatas) {\n // check if table does not exist yet\n const existTable = this.queryRunner.loadedTables.find(\n (table) =>\n this.getTablePath(table) === this.getTablePath(metadata),\n )\n if (existTable) continue\n\n this.connection.logger.logSchemaBuild(\n `creating a new table: ${this.getTablePath(metadata)}`,\n )\n\n // create a new table and sync it in the database\n const table = Table.create(metadata, this.connection.driver)\n await this.queryRunner.createTable(table, false, false)\n this.queryRunner.loadedTables.push(table)\n }\n }\n\n protected async createViews(): Promise<void> {\n for (const metadata of this.viewEntityToSyncMetadatas) {\n // check if view does not exist yet\n const existView = this.queryRunner.loadedViews.find((view) => {\n const viewExpression =\n typeof view.expression === \"string\"\n ? view.expression.trim()\n : view.expression(this.connection).getQuery()\n const metadataExpression =\n typeof metadata.expression === \"string\"\n ? metadata.expression.trim()\n : metadata.expression!(this.connection).getQuery()\n return (\n this.getTablePath(view) === this.getTablePath(metadata) &&\n viewExpression === metadataExpression\n )\n })\n if (existView) continue\n\n this.connection.logger.logSchemaBuild(\n `creating a new view: ${this.getTablePath(metadata)}`,\n )\n\n // create a new view and sync it in the database\n const view = View.create(metadata, this.connection.driver)\n await this.queryRunner.createView(view, true)\n this.queryRunner.loadedViews.push(view)\n }\n }\n\n protected async dropOldViews(): Promise<void> {\n const droppedViews: Array<View> = []\n const viewEntityToSyncMetadatas = this.viewEntityToSyncMetadatas\n // BuIld lookup cache for finding views metadata\n const viewToMetadata = new Map<View, EntityMetadata>()\n for (const view of this.queryRunner.loadedViews) {\n const viewMetadata = viewEntityToSyncMetadatas.find((metadata) => {\n return this.getTablePath(view) === this.getTablePath(metadata)\n })\n if (viewMetadata) {\n viewToMetadata.set(view, viewMetadata)\n }\n }\n // Gather all changed view, that need a drop\n for (const view of this.queryRunner.loadedViews) {\n const viewMetadata = viewToMetadata.get(view)\n if (!viewMetadata) {\n continue\n }\n const viewExpression =\n typeof view.expression === \"string\"\n ? view.expression.trim()\n : view.expression(this.connection).getQuery()\n const metadataExpression =\n typeof viewMetadata.expression === \"string\"\n ? viewMetadata.expression.trim()\n : viewMetadata.expression!(this.connection).getQuery()\n\n if (viewExpression === metadataExpression) continue\n\n this.connection.logger.logSchemaBuild(\n `dropping an old view: ${view.name}`,\n )\n\n // Collect view to be dropped\n droppedViews.push(view)\n }\n\n // Helper function that for a given view, will recursively return list of the view and all views that depend on it\n const viewDependencyChain = (view: View): View[] => {\n // Get the view metadata\n const viewMetadata = viewToMetadata.get(view)\n let viewWithDependencies = [view]\n // If no metadata is known for the view, simply return the view itself\n if (!viewMetadata) {\n return viewWithDependencies\n }\n // Iterate over all known views\n for (const [\n currentView,\n currentMetadata,\n ] of viewToMetadata.entries()) {\n // Ignore self reference\n if (currentView === view) {\n continue\n }\n // If the currently iterated view depends on the passed in view\n if (\n currentMetadata.dependsOn &&\n (currentMetadata.dependsOn.has(viewMetadata.target) ||\n currentMetadata.dependsOn.has(viewMetadata.name))\n ) {\n // Recursively add currently iterate view and its dependents\n viewWithDependencies = viewWithDependencies.concat(\n viewDependencyChain(currentView),\n )\n }\n }\n // Return all collected views\n return viewWithDependencies\n }\n\n // Collect final list of views to be dropped in a Set so there are no duplicates\n const droppedViewsWithDependencies: Set<View> = new Set(\n // Collect all dropped views, and their dependencies\n droppedViews\n .map((view) => viewDependencyChain(view))\n // Flattened to single Array ( can be replaced with flatMap, once supported)\n .reduce((all, segment) => {\n return all.concat(segment)\n }, [])\n // Sort the views to be dropped in creation order\n .sort((a, b) => {\n return ViewUtils.viewMetadataCmp(\n viewToMetadata.get(a),\n viewToMetadata.get(b),\n )\n })\n // reverse order to get drop order\n .reverse(),\n )\n\n // Finally emit all drop views\n for (const view of droppedViewsWithDependencies) {\n await this.queryRunner.dropView(view)\n }\n this.queryRunner.loadedViews = this.queryRunner.loadedViews.filter(\n (view) => !droppedViewsWithDependencies.has(view),\n )\n }\n\n /**\n * Drops all columns that exist in the table, but does not exist in the metadata (left old).\n * We drop their keys too, since it should be safe.\n */\n protected async dropRemovedColumns(): Promise<void> {\n for (const metadata of this.entityToSyncMetadatas) {\n const table = this.queryRunner.loadedTables.find(\n (table) =>\n this.getTablePath(table) === this.getTablePath(metadata),\n )\n if (!table) continue\n\n // find columns that exist in the database but does not exist in the metadata\n const droppedTableColumns = table.columns.filter((tableColumn) => {\n return !metadata.columns.find(\n (columnMetadata) =>\n columnMetadata.isVirtualProperty ||\n columnMetadata.databaseName === tableColumn.name,\n )\n })\n if (droppedTableColumns.length === 0) continue\n\n this.connection.logger.logSchemaBuild(\n `columns dropped in ${table.name}: ` +\n droppedTableColumns.map((column) => column.name).join(\", \"),\n )\n\n // drop columns from the database\n await this.queryRunner.dropColumns(table, droppedTableColumns)\n }\n }\n\n /**\n * Adds columns from metadata which does not exist in the table.\n * Columns are created without keys.\n */\n protected async addNewColumns(): Promise<void> {\n for (const metadata of this.entityToSyncMetadatas) {\n const table = this.queryRunner.loadedTables.find(\n (table) =>\n this.getTablePath(table) === this.getTablePath(metadata),\n )\n if (!table) continue\n\n // find which columns are new\n const newColumnMetadatas = metadata.columns.filter(\n (columnMetadata) => {\n return (\n !columnMetadata.isVirtualProperty &&\n !table.columns.find(\n (tableColumn) =>\n tableColumn.name ===\n columnMetadata.databaseName,\n )\n )\n },\n )\n if (newColumnMetadatas.length === 0) continue\n\n // create columns in the database\n const newTableColumnOptions =\n this.metadataColumnsToTableColumnOptions(newColumnMetadatas)\n const newTableColumns = newTableColumnOptions.map(\n (option) => new TableColumn(option),\n )\n\n if (newTableColumns.length === 0) continue\n\n this.connection.logger.logSchemaBuild(\n `new columns added: ` +\n newColumnMetadatas\n .map((column) => column.databaseName)\n .join(\", \"),\n )\n await this.queryRunner.addColumns(table, newTableColumns)\n }\n }\n\n /**\n * Updates composite primary keys.\n */\n protected async updatePrimaryKeys(): Promise<void> {\n for (const metadata of this.entityToSyncMetadatas) {\n const table = this.queryRunner.loadedTables.find(\n (table) =>\n this.getTablePath(table) === this.getTablePath(metadata),\n )\n if (!table) continue\n\n const primaryMetadataColumns = metadata.columns.filter(\n (column) => column.isPrimary,\n )\n const primaryTableColumns = table.columns.filter(\n (column) => column.isPrimary,\n )\n if (\n primaryTableColumns.length !== primaryMetadataColumns.length &&\n primaryMetadataColumns.length > 1\n ) {\n const changedPrimaryColumns = primaryMetadataColumns.map(\n (primaryMetadataColumn) => {\n return new TableColumn(\n TableUtils.createTableColumnOptions(\n primaryMetadataColumn,\n this.connection.driver,\n ),\n )\n },\n )\n await this.queryRunner.updatePrimaryKeys(\n table,\n changedPrimaryColumns,\n )\n }\n }\n }\n\n /**\n * Update all exist columns which metadata has changed.\n * Still don't create keys. Also we don't touch foreign keys of the changed columns.\n */\n protected async updateExistColumns(): Promise<void> {\n for (const metadata of this.entityToSyncMetadatas) {\n const table = this.queryRunner.loadedTables.find(\n (table) =>\n this.getTablePath(table) === this.getTablePath(metadata),\n )\n if (!table) continue\n\n const changedColumns = this.connection.driver.findChangedColumns(\n table.columns,\n metadata.columns,\n )\n if (changedColumns.length === 0) continue\n\n // drop all foreign keys that point to this column\n for (const changedColumn of changedColumns) {\n await this.dropColumnReferencedForeignKeys(\n this.getTablePath(metadata),\n changedColumn.databaseName,\n )\n }\n\n // drop all composite indices related to this column\n for (const changedColumn of changedColumns) {\n await this.dropColumnCompositeIndices(\n this.getTablePath(metadata),\n changedColumn.databaseName,\n )\n }\n\n // drop all composite uniques related to this column\n // Mysql does not support unique constraints.\n if (\n !(\n DriverUtils.isMySQLFamily(this.connection.driver) ||\n this.connection.driver.options.type === \"aurora-mysql\" ||\n this.connection.driver.options.type === \"spanner\"\n )\n ) {\n for (const changedColumn of changedColumns) {\n await this.dropColumnCompositeUniques(\n this.getTablePath(metadata),\n changedColumn.databaseName,\n )\n }\n }\n\n // generate a map of new/old columns\n const newAndOldTableColumns = changedColumns.map(\n (changedColumn) => {\n const oldTableColumn = table.columns.find(\n (column) => column.name === changedColumn.databaseName,\n )!\n const newTableColumnOptions =\n TableUtils.createTableColumnOptions(\n changedColumn,\n this.connection.driver,\n )\n const newTableColumn = new TableColumn(\n newTableColumnOptions,\n )\n\n return {\n oldColumn: oldTableColumn,\n newColumn: newTableColumn,\n }\n },\n )\n\n if (newAndOldTableColumns.length === 0) continue\n\n this.connection.logger.logSchemaBuild(\n `columns changed in \"${table.name}\". updating: ` +\n changedColumns\n .map((column) => column.databaseName)\n .join(\", \"),\n )\n await this.queryRunner.changeColumns(table, newAndOldTableColumns)\n }\n }\n\n /**\n * Creates composite indices which are missing in db yet.\n */\n protected async createNewIndices(): Promise<void> {\n for (const metadata of this.entityToSyncMetadatas) {\n const table = this.queryRunner.loadedTables.find(\n (table) =>\n this.getTablePath(table) === this.getTablePath(metadata),\n )\n if (!table) continue\n\n const newIndices = metadata.indices\n .filter(\n (indexMetadata) =>\n !table.indices.find(\n (tableIndex) =>\n tableIndex.name === indexMetadata.name,\n ) && indexMetadata.synchronize === true,\n )\n .map((indexMetadata) => TableIndex.create(indexMetadata))\n\n if (newIndices.length === 0) continue\n\n this.connection.logger.logSchemaBuild(\n `adding new indices ${newIndices\n .map((index) => `\"${index.name}\"`)\n .join(\", \")} in table \"${table.name}\"`,\n )\n await this.queryRunner.createIndices(table, newIndices)\n }\n }\n\n /**\n * Creates indices for materialized views.\n */\n protected async createNewViewIndices(): Promise<void> {\n // Only PostgreSQL supports indices for materialized views.\n if (\n this.connection.options.type !== \"postgres\" ||\n !DriverUtils.isPostgresFamily(this.connection.driver)\n ) {\n return\n }\n const postgresQueryRunner: PostgresQueryRunner = <PostgresQueryRunner>(\n this.queryRunner\n )\n for (const metadata of this.viewEntityToSyncMetadatas) {\n // check if view does not exist yet\n const view = this.queryRunner.loadedViews.find((view) => {\n const viewExpression =\n typeof view.expression === \"string\"\n ? view.expression.trim()\n : view.expression(this.connection).getQuery()\n const metadataExpression =\n typeof metadata.expression === \"string\"\n ? metadata.expression.trim()\n : metadata.expression!(this.connection).getQuery()\n return (\n this.getTablePath(view) === this.getTablePath(metadata) &&\n viewExpression === metadataExpression\n )\n })\n if (!view || !view.materialized) continue\n\n const newIndices = metadata.indices\n .filter(\n (indexMetadata) =>\n !view.indices.find(\n (tableIndex) =>\n tableIndex.name === indexMetadata.name,\n ) && indexMetadata.synchronize === true,\n )\n .map((indexMetadata) => TableIndex.create(indexMetadata))\n\n if (newIndices.length === 0) continue\n\n this.connection.logger.logSchemaBuild(\n `adding new indices ${newIndices\n .map((index) => `\"${index.name}\"`)\n .join(\", \")} in view \"${view.name}\"`,\n )\n await postgresQueryRunner.createViewIndices(view, newIndices)\n }\n }\n\n protected async createNewChecks(): Promise<void> {\n // Mysql does not support check constraints\n if (\n DriverUtils.isMySQLFamily(this.connection.driver) ||\n this.connection.driver.options.type === \"aurora-mysql\"\n )\n return\n\n for (const metadata of this.entityToSyncMetadatas) {\n const table = this.queryRunner.loadedTables.find(\n (table) =>\n this.getTablePath(table) === this.getTablePath(metadata),\n )\n if (!table) continue\n\n const newChecks = metadata.checks\n .filter(\n (checkMetadata) =>\n !table.checks.find(\n (tableCheck) =>\n tableCheck.name === checkMetadata.name,\n ),\n )\n .map((checkMetadata) => TableCheck.create(checkMetadata))\n\n if (newChecks.length === 0) continue\n\n this.connection.logger.logSchemaBuild(\n `adding new check constraints: ${newChecks\n .map((index) => `\"${index.name}\"`)\n .join(\", \")} in table \"${table.name}\"`,\n )\n await this.queryRunner.createCheckConstraints(table, newChecks)\n }\n }\n\n /**\n * Creates composite uniques which are missing in db yet.\n */\n protected async createCompositeUniqueConstraints(): Promise<void> {\n for (const metadata of this.entityToSyncMetadatas) {\n const table = this.queryRunner.loadedTables.find(\n (table) =>\n this.getTablePath(table) === this.getTablePath(metadata),\n )\n if (!table) continue\n\n const compositeUniques = metadata.uniques\n .filter(\n (uniqueMetadata) =>\n uniqueMetadata.columns.length > 1 &&\n !table.uniques.find(\n (tableUnique) =>\n tableUnique.name === uniqueMetadata.name,\n ),\n )\n .map((uniqueMetadata) => TableUnique.create(uniqueMetadata))\n\n if (compositeUniques.length === 0) continue\n\n this.connection.logger.logSchemaBuild(\n `adding new unique constraints: ${compositeUniques\n .map((unique) => `\"${unique.name}\"`)\n .join(\", \")} in table \"${table.name}\"`,\n )\n await this.queryRunner.createUniqueConstraints(\n table,\n compositeUniques,\n )\n }\n }\n\n /**\n * Creates exclusions which are missing in db yet.\n */\n protected async createNewExclusions(): Promise<void> {\n // Only PostgreSQL supports exclusion constraints\n if (!(this.connection.driver.options.type === \"postgres\")) return\n\n for (const metadata of this.entityToSyncMetadatas) {\n const table = this.queryRunner.loadedTables.find(\n (table) =>\n this.getTablePath(table) === this.getTablePath(metadata),\n )\n if (!table) continue\n\n const newExclusions = metadata.exclusions\n .filter(\n (exclusionMetadata) =>\n !table.exclusions.find(\n (tableExclusion) =>\n tableExclusion.name === exclusionMetadata.name,\n ),\n )\n .map((exclusionMetadata) =>\n TableExclusion.create(exclusionMetadata),\n )\n\n if (newExclusions.length === 0) continue\n\n this.connection.logger.logSchemaBuild(\n `adding new exclusion constraints: ${newExclusions\n .map((exclusion) => `\"${exclusion.name}\"`)\n .join(\", \")} in table \"${table.name}\"`,\n )\n await this.queryRunner.createExclusionConstraints(\n table,\n newExclusions,\n )\n }\n }\n\n /**\n * Creates foreign keys which does not exist in the table yet.\n */\n protected async createForeignKeys(): Promise<void> {\n for (const metadata of this.entityToSyncMetadatas) {\n const table = this.queryRunner.loadedTables.find(\n (table) =>\n this.getTablePath(table) === this.getTablePath(metadata),\n )\n if (!table) continue\n\n const newKeys = metadata.foreignKeys.filter((foreignKey) => {\n return !table.foreignKeys.find(\n (dbForeignKey) =>\n dbForeignKey.name === foreignKey.name &&\n this.getTablePath(dbForeignKey) ===\n this.getTablePath(\n foreignKey.referencedEntityMetadata,\n ),\n )\n })\n if (newKeys.length === 0) continue\n\n const dbForeignKeys = newKeys.map((foreignKeyMetadata) =>\n TableForeignKey.create(\n foreignKeyMetadata,\n this.connection.driver,\n ),\n )\n this.connection.logger.logSchemaBuild(\n `creating a foreign keys: ${newKeys\n .map((key) => key.name)\n .join(\", \")} on table \"${table.name}\"`,\n )\n await this.queryRunner.createForeignKeys(table, dbForeignKeys)\n }\n }\n\n /**\n * Drops all foreign keys where given column of the given table is being used.\n */\n protected async dropColumnReferencedForeignKeys(\n tablePath: string,\n columnName: string,\n ): Promise<void> {\n const table = this.queryRunner.loadedTables.find(\n (table) => this.getTablePath(table) === tablePath,\n )\n if (!table) return\n\n const tablesWithFK: Table[] = []\n const columnForeignKey = table.foreignKeys.find(\n (foreignKey) => foreignKey.columnNames.indexOf(columnName) !== -1,\n )\n if (columnForeignKey) {\n const clonedTable = table.clone()\n clonedTable.foreignKeys = [columnForeignKey]\n tablesWithFK.push(clonedTable)\n table.removeForeignKey(columnForeignKey)\n }\n\n for (const loadedTable of this.queryRunner.loadedTables) {\n const dependForeignKeys = loadedTable.foreignKeys.filter(\n (foreignKey) => {\n return (\n this.getTablePath(foreignKey) === tablePath &&\n foreignKey.referencedColumnNames.indexOf(columnName) !==\n -1\n )\n },\n )\n\n if (dependForeignKeys.length > 0) {\n const clonedTable = loadedTable.clone()\n clonedTable.foreignKeys = dependForeignKeys\n tablesWithFK.push(clonedTable)\n dependForeignKeys.forEach((dependForeignKey) =>\n loadedTable.removeForeignKey(dependForeignKey),\n )\n }\n }\n\n if (tablesWithFK.length > 0) {\n for (const tableWithFK of tablesWithFK) {\n this.connection.logger.logSchemaBuild(\n `dropping related foreign keys of ${\n tableWithFK.name\n }: ${tableWithFK.foreignKeys\n .map((foreignKey) => foreignKey.name)\n .join(\", \")}`,\n )\n await this.queryRunner.dropForeignKeys(\n tableWithFK,\n tableWithFK.foreignKeys,\n )\n }\n }\n }\n\n /**\n * Drops all composite indices, related to given column.\n */\n protected async dropColumnCompositeIndices(\n tablePath: string,\n columnName: string,\n ): Promise<void> {\n const table = this.queryRunner.loadedTables.find(\n (table) => this.getTablePath(table) === tablePath,\n )\n if (!table) return\n\n const relatedIndices = table.indices.filter(\n (index) =>\n index.columnNames.length > 1 &&\n index.columnNames.indexOf(columnName) !== -1,\n )\n if (relatedIndices.length === 0) return\n\n this.connection.logger.logSchemaBuild(\n `dropping related indices of \"${tablePath}\".\"${columnName}\": ${relatedIndices\n .map((index) => index.name)\n .join(\", \")}`,\n )\n await this.queryRunner.dropIndices(table, relatedIndices)\n }\n\n /**\n * Drops all composite uniques, related to given column.\n */\n protected async dropColumnCompositeUniques(\n tablePath: string,\n columnName: string,\n ): Promise<void> {\n const table = this.queryRunner.loadedTables.find(\n (table) => this.getTablePath(table) === tablePath,\n )\n if (!table) return\n\n const relatedUniques = table.uniques.filter(\n (unique) =>\n unique.columnNames.length > 1 &&\n unique.columnNames.indexOf(columnName) !== -1,\n )\n if (relatedUniques.length === 0) return\n\n this.connection.logger.logSchemaBuild(\n `dropping related unique constraints of \"${tablePath}\".\"${columnName}\": ${relatedUniques\n .map((unique) => unique.name)\n .join(\", \")}`,\n )\n await this.queryRunner.dropUniqueConstraints(table, relatedUniques)\n }\n\n /**\n * Creates new columns from the given column metadatas.\n */\n protected metadataColumnsToTableColumnOptions(\n columns: ColumnMetadata[],\n ): TableColumnOptions[] {\n return columns.map((columnMetadata) =>\n TableUtils.createTableColumnOptions(\n columnMetadata,\n this.connection.driver,\n ),\n )\n }\n\n /**\n * Creates typeorm service table for storing user defined Views and generate columns.\n */\n protected async createTypeormMetadataTable(queryRunner: QueryRunner) {\n const schema = this.currentSchema\n const database = this.currentDatabase\n const typeormMetadataTable = this.connection.driver.buildTableName(\n this.connection.metadataTableName,\n schema,\n database,\n )\n\n // Spanner requires at least one primary key in a table.\n // Since we don't have unique column in \"typeorm_metadata\" table\n // and we should avoid breaking changes, we mark all columns as primary for Spanner driver.\n const isPrimary = this.connection.driver.options.type === \"spanner\"\n await queryRunner.createTable(\n new Table({\n database: database,\n schema: schema,\n name: typeormMetadataTable,\n columns: [\n {\n name: \"type\",\n type: this.connection.driver.normalizeType({\n type: this.connection.driver.mappedDataTypes\n .metadataType,\n }),\n isNullable: false,\n isPrimary,\n },\n {\n name: \"database\",\n type: this.connection.driver.normalizeType({\n type: this.connection.driver.mappedDataTypes\n .metadataDatabase,\n }),\n isNullable: true,\n isPrimary,\n },\n {\n name: \"schema\",\n type: this.connection.driver.normalizeType({\n type: this.connection.driver.mappedDataTypes\n .metadataSchema,\n }),\n isNullable: true,\n isPrimary,\n },\n {\n name: \"table\",\n type: this.connection.driver.normalizeType({\n type: this.connection.driver.mappedDataTypes\n .metadataTable,\n }),\n isNullable: true,\n isPrimary,\n },\n {\n name: \"name\",\n type: this.connection.driver.normalizeType({\n type: this.connection.driver.mappedDataTypes\n .metadataName,\n }),\n isNullable: true,\n isPrimary,\n },\n {\n name: \"value\",\n type: this.connection.driver.normalizeType({\n type: this.connection.driver.mappedDataTypes\n .metadataValue,\n }),\n isNullable: true,\n isPrimary,\n },\n ],\n }),\n true,\n )\n }\n}\n"],"sourceRoot":".."}
|
|
1
|
+
{"version":3,"sources":["../browser/src/schema-builder/RdbmsSchemaBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,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;oBACF,UAAU,EAAE,IAAI;oBAChB,SAAS;iBACZ;gBACD;oBACI,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,aAAa,CAAC;wBACvC,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,eAAe;6BACvC,YAAY;qBACpB,CAAC;oBACF,UAAU,EAAE,IAAI;oBAChB,SAAS;iBACZ;gBACD;oBACI,IAAI,EAAE,OAAO;oBACb,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,aAAa,CAAC;wBACvC,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,eAAe;6BACvC,aAAa;qBACrB,CAAC;oBACF,UAAU,EAAE,IAAI;oBAChB,SAAS;iBACZ;aACJ;SACJ,CAAC,EACF,IAAI,CACP,CAAA;IACL,CAAC;CACJ","file":"RdbmsSchemaBuilder.js","sourcesContent":["import { Table } from \"./table/Table\"\nimport { TableColumn } from \"./table/TableColumn\"\nimport { TableForeignKey } from \"./table/TableForeignKey\"\nimport { TableIndex } from \"./table/TableIndex\"\nimport { QueryRunner } from \"../query-runner/QueryRunner\"\nimport { ColumnMetadata } from \"../metadata/ColumnMetadata\"\nimport { EntityMetadata } from \"../metadata/EntityMetadata\"\nimport { DataSource } from \"../data-source/DataSource\"\nimport { SchemaBuilder } from \"./SchemaBuilder\"\nimport { SqlInMemory } from \"../driver/SqlInMemory\"\nimport { TableUtils } from \"./util/TableUtils\"\nimport { TableColumnOptions } from \"./options/TableColumnOptions\"\nimport { TableUnique } from \"./table/TableUnique\"\nimport { TableCheck } from \"./table/TableCheck\"\nimport { TableExclusion } from \"./table/TableExclusion\"\nimport { View } from \"./view/View\"\nimport { ViewUtils } from \"./util/ViewUtils\"\nimport { DriverUtils } from \"../driver/DriverUtils\"\nimport { PostgresQueryRunner } from \"../driver/postgres/PostgresQueryRunner\"\n\n/**\n * Creates complete tables schemas in the database based on the entity metadatas.\n *\n * Steps how schema is being built:\n * 1. load list of all tables with complete column and keys information from the db\n * 2. drop all (old) foreign keys that exist in the table, but does not exist in the metadata\n * 3. create new tables that does not exist in the db, but exist in the metadata\n * 4. drop all columns exist (left old) in the db table, but does not exist in the metadata\n * 5. add columns from metadata which does not exist in the table\n * 6. update all exist columns which metadata has changed\n * 7. update primary keys - update old and create new primary key from changed columns\n * 8. create foreign keys which does not exist in the table yet\n * 9. create indices which are missing in db yet, and drops indices which exist in the db, but does not exist in the metadata anymore\n */\nexport class RdbmsSchemaBuilder implements SchemaBuilder {\n readonly \"@instanceof\" = Symbol.for(\"RdbmsSchemaBuilder\")\n\n /**\n * Used to execute schema creation queries in a single connection.\n */\n protected queryRunner: QueryRunner\n\n private currentDatabase?: string\n\n private currentSchema?: string\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(protected connection: DataSource) {}\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Creates complete schemas for the given entity metadatas.\n */\n async build(): Promise<void> {\n this.queryRunner = this.connection.createQueryRunner()\n\n // this.connection.driver.database || this.currentDatabase;\n this.currentDatabase = this.connection.driver.database\n this.currentSchema = this.connection.driver.schema\n\n // CockroachDB implements asynchronous schema sync operations which can not been executed in transaction.\n // E.g. if you try to DROP column and ADD it again in the same transaction, crdb throws error.\n // In Spanner queries against the INFORMATION_SCHEMA can be used in a read-only transaction,\n // but not in a read-write transaction.\n const isUsingTransactions =\n !(this.connection.driver.options.type === \"cockroachdb\") &&\n !(this.connection.driver.options.type === \"spanner\") &&\n this.connection.options.migrationsTransactionMode !== \"none\"\n\n await this.queryRunner.beforeMigration()\n\n if (isUsingTransactions) {\n await this.queryRunner.startTransaction()\n }\n\n try {\n await this.createMetadataTableIfNecessary(this.queryRunner)\n // Flush the queryrunner table & view cache\n const tablePaths = this.entityToSyncMetadatas.map((metadata) =>\n this.getTablePath(metadata),\n )\n const viewPaths = this.viewEntityToSyncMetadatas.map((metadata) =>\n this.getTablePath(metadata),\n )\n\n await this.queryRunner.getTables(tablePaths)\n await this.queryRunner.getViews(viewPaths)\n\n await this.executeSchemaSyncOperationsInProperOrder()\n\n // if cache is enabled then perform cache-synchronization as well\n if (this.connection.queryResultCache)\n await this.connection.queryResultCache.synchronize(\n this.queryRunner,\n )\n\n if (isUsingTransactions) {\n await this.queryRunner.commitTransaction()\n }\n } catch (error) {\n try {\n // we throw original error even if rollback thrown an error\n if (isUsingTransactions) {\n await this.queryRunner.rollbackTransaction()\n }\n } catch (rollbackError) {}\n throw error\n } finally {\n await this.queryRunner.afterMigration()\n\n await this.queryRunner.release()\n }\n }\n\n /**\n * Create the typeorm_metadata table if necessary.\n */\n async createMetadataTableIfNecessary(\n queryRunner: QueryRunner,\n ): Promise<void> {\n if (\n this.viewEntityToSyncMetadatas.length > 0 ||\n this.hasGeneratedColumns()\n ) {\n await this.createTypeormMetadataTable(queryRunner)\n }\n }\n\n /**\n * Returns sql queries to be executed by schema builder.\n */\n async log(): Promise<SqlInMemory> {\n this.queryRunner = this.connection.createQueryRunner()\n try {\n // Flush the queryrunner table & view cache\n const tablePaths = this.entityToSyncMetadatas.map((metadata) =>\n this.getTablePath(metadata),\n )\n const viewPaths = this.viewEntityToSyncMetadatas.map((metadata) =>\n this.getTablePath(metadata),\n )\n await this.queryRunner.getTables(tablePaths)\n await this.queryRunner.getViews(viewPaths)\n\n this.queryRunner.enableSqlMemory()\n await this.executeSchemaSyncOperationsInProperOrder()\n\n // if cache is enabled then perform cache-synchronization as well\n if (this.connection.queryResultCache)\n // todo: check this functionality\n await this.connection.queryResultCache.synchronize(\n this.queryRunner,\n )\n\n return this.queryRunner.getMemorySql()\n } finally {\n // its important to disable this mode despite the fact we are release query builder\n // because there exist drivers which reuse same query runner. Also its important to disable\n // sql memory after call of getMemorySql() method because last one flushes sql memory.\n this.queryRunner.disableSqlMemory()\n await this.queryRunner.release()\n }\n }\n\n // -------------------------------------------------------------------------\n // Protected Methods\n // -------------------------------------------------------------------------\n\n /**\n * Returns only entities that should be synced in the database.\n */\n protected get entityToSyncMetadatas(): EntityMetadata[] {\n return this.connection.entityMetadatas.filter(\n (metadata) =>\n metadata.synchronize &&\n metadata.tableType !== \"entity-child\" &&\n metadata.tableType !== \"view\",\n )\n }\n\n /**\n * Returns only entities that should be synced in the database.\n */\n protected get viewEntityToSyncMetadatas(): EntityMetadata[] {\n return (\n this.connection.entityMetadatas\n .filter(\n (metadata) =>\n metadata.tableType === \"view\" && metadata.synchronize,\n )\n // sort views in creation order by dependencies\n .sort(ViewUtils.viewMetadataCmp)\n )\n }\n\n /**\n * Checks if there are at least one generated column.\n */\n protected hasGeneratedColumns(): boolean {\n return this.connection.entityMetadatas.some((entityMetadata) => {\n return entityMetadata.columns.some((column) => column.generatedType)\n })\n }\n\n /**\n * Executes schema sync operations in a proper order.\n * Order of operations matter here.\n */\n protected async executeSchemaSyncOperationsInProperOrder(): Promise<void> {\n await this.dropOldViews()\n await this.dropOldForeignKeys()\n await this.dropOldIndices()\n await this.dropOldChecks()\n await this.dropOldExclusions()\n await this.dropCompositeUniqueConstraints()\n // await this.renameTables();\n await this.renameColumns()\n await this.createNewTables()\n await this.dropRemovedColumns()\n await this.addNewColumns()\n await this.updatePrimaryKeys()\n await this.updateExistColumns()\n await this.createNewIndices()\n await this.createNewChecks()\n await this.createNewExclusions()\n await this.createCompositeUniqueConstraints()\n await this.createForeignKeys()\n await this.createViews()\n await this.createNewViewIndices()\n }\n\n private getTablePath(\n target: EntityMetadata | Table | View | TableForeignKey | string,\n ): string {\n const parsed = this.connection.driver.parseTableName(target)\n\n return this.connection.driver.buildTableName(\n parsed.tableName,\n parsed.schema || this.currentSchema,\n parsed.database || this.currentDatabase,\n )\n }\n\n /**\n * Drops all (old) foreign keys that exist in the tables, but do not exist in the entity metadata.\n */\n protected async dropOldForeignKeys(): Promise<void> {\n for (const metadata of this.entityToSyncMetadatas) {\n const table = this.queryRunner.loadedTables.find(\n (table) =>\n this.getTablePath(table) === this.getTablePath(metadata),\n )\n if (!table) continue\n\n // find foreign keys that exist in the schemas but does not exist in the entity metadata\n const tableForeignKeysToDrop = table.foreignKeys.filter(\n (tableForeignKey) => {\n const metadataFK = metadata.foreignKeys.find(\n (metadataForeignKey) =>\n tableForeignKey.name === metadataForeignKey.name &&\n this.getTablePath(tableForeignKey) ===\n this.getTablePath(\n metadataForeignKey.referencedEntityMetadata,\n ),\n )\n return (\n !metadataFK ||\n (metadataFK.onDelete &&\n metadataFK.onDelete !== tableForeignKey.onDelete) ||\n (metadataFK.onUpdate &&\n metadataFK.onUpdate !== tableForeignKey.onUpdate)\n )\n },\n )\n if (tableForeignKeysToDrop.length === 0) continue\n\n this.connection.logger.logSchemaBuild(\n `dropping old foreign keys of ${\n table.name\n }: ${tableForeignKeysToDrop\n .map((dbForeignKey) => dbForeignKey.name)\n .join(\", \")}`,\n )\n\n // drop foreign keys from the database\n await this.queryRunner.dropForeignKeys(\n table,\n tableForeignKeysToDrop,\n )\n }\n }\n\n /**\n * Rename tables\n */\n protected async renameTables(): Promise<void> {\n // for (const metadata of this.entityToSyncMetadatas) {\n // const table = this.queryRunner.loadedTables.find(table => this.getTablePath(table) === this.getTablePath(metadata));\n // }\n }\n\n /**\n * Renames columns.\n * Works if only one column per table was changed.\n * Changes only column name. If something besides name was changed, these changes will be ignored.\n */\n protected async renameColumns(): Promise<void> {\n for (const metadata of this.entityToSyncMetadatas) {\n const table = this.queryRunner.loadedTables.find(\n (table) =>\n this.getTablePath(table) === this.getTablePath(metadata),\n )\n if (!table) continue\n\n if (metadata.columns.length !== table.columns.length) continue\n\n const renamedMetadataColumns = metadata.columns\n .filter((c) => !c.isVirtualProperty)\n .filter((column) => {\n return !table.columns.find((tableColumn) => {\n return (\n tableColumn.name === column.databaseName &&\n tableColumn.type ===\n this.connection.driver.normalizeType(column) &&\n tableColumn.isNullable === column.isNullable &&\n tableColumn.isUnique ===\n this.connection.driver.normalizeIsUnique(column)\n )\n })\n })\n\n if (\n renamedMetadataColumns.length === 0 ||\n renamedMetadataColumns.length > 1\n )\n continue\n\n const renamedTableColumns = table.columns.filter((tableColumn) => {\n return !metadata.columns.find((column) => {\n return (\n !column.isVirtualProperty &&\n column.databaseName === tableColumn.name &&\n this.connection.driver.normalizeType(column) ===\n tableColumn.type &&\n column.isNullable === tableColumn.isNullable &&\n this.connection.driver.normalizeIsUnique(column) ===\n tableColumn.isUnique\n )\n })\n })\n\n if (\n renamedTableColumns.length === 0 ||\n renamedTableColumns.length > 1\n )\n continue\n\n const renamedColumn = renamedTableColumns[0].clone()\n renamedColumn.name = renamedMetadataColumns[0].databaseName\n\n this.connection.logger.logSchemaBuild(\n `renaming column \"${renamedTableColumns[0].name}\" in \"${table.name}\" to \"${renamedColumn.name}\"`,\n )\n await this.queryRunner.renameColumn(\n table,\n renamedTableColumns[0],\n renamedColumn,\n )\n }\n }\n\n protected async dropOldIndices(): Promise<void> {\n for (const metadata of this.entityToSyncMetadatas) {\n const table = this.queryRunner.loadedTables.find(\n (table) =>\n this.getTablePath(table) === this.getTablePath(metadata),\n )\n if (!table) continue\n\n const dropQueries = table.indices\n .filter((tableIndex) => {\n const indexMetadata = metadata.indices.find(\n (index) => index.name === tableIndex.name,\n )\n if (indexMetadata) {\n if (indexMetadata.synchronize === false) return false\n\n if (indexMetadata.isUnique !== tableIndex.isUnique)\n return true\n\n if (indexMetadata.isSpatial !== tableIndex.isSpatial)\n return true\n\n if (\n this.connection.driver.isFullTextColumnTypeSupported() &&\n indexMetadata.isFulltext !== tableIndex.isFulltext\n )\n return true\n\n if (\n indexMetadata.columns.length !==\n tableIndex.columnNames.length\n )\n return true\n\n return !indexMetadata.columns.every(\n (column) =>\n tableIndex.columnNames.indexOf(\n column.databaseName,\n ) !== -1,\n )\n }\n\n return true\n })\n .map(async (tableIndex) => {\n this.connection.logger.logSchemaBuild(\n `dropping an index: \"${tableIndex.name}\" from table ${table.name}`,\n )\n await this.queryRunner.dropIndex(table, tableIndex)\n })\n\n await Promise.all(dropQueries)\n }\n if (this.connection.options.type === \"postgres\") {\n const postgresQueryRunner: PostgresQueryRunner = <\n PostgresQueryRunner\n >this.queryRunner\n for (const metadata of this.viewEntityToSyncMetadatas) {\n const view = this.queryRunner.loadedViews.find(\n (view) =>\n this.getTablePath(view) === this.getTablePath(metadata),\n )\n if (!view) continue\n\n const dropQueries = view.indices\n .filter((tableIndex) => {\n const indexMetadata = metadata.indices.find(\n (index) => index.name === tableIndex.name,\n )\n if (indexMetadata) {\n if (indexMetadata.synchronize === false)\n return false\n\n if (indexMetadata.isUnique !== tableIndex.isUnique)\n return true\n\n if (\n indexMetadata.isSpatial !== tableIndex.isSpatial\n )\n return true\n\n if (\n this.connection.driver.isFullTextColumnTypeSupported() &&\n indexMetadata.isFulltext !==\n tableIndex.isFulltext\n )\n return true\n\n if (\n indexMetadata.columns.length !==\n tableIndex.columnNames.length\n )\n return true\n\n return !indexMetadata.columns.every(\n (column) =>\n tableIndex.columnNames.indexOf(\n column.databaseName,\n ) !== -1,\n )\n }\n\n return true\n })\n .map(async (tableIndex) => {\n this.connection.logger.logSchemaBuild(\n `dropping an index: \"${tableIndex.name}\" from view ${view.name}`,\n )\n await postgresQueryRunner.dropViewIndex(\n view,\n tableIndex,\n )\n })\n\n await Promise.all(dropQueries)\n }\n }\n }\n\n protected async dropOldChecks(): Promise<void> {\n // Mysql does not support check constraints\n if (\n DriverUtils.isMySQLFamily(this.connection.driver) ||\n this.connection.driver.options.type === \"aurora-mysql\"\n )\n return\n\n for (const metadata of this.entityToSyncMetadatas) {\n const table = this.queryRunner.loadedTables.find(\n (table) =>\n this.getTablePath(table) === this.getTablePath(metadata),\n )\n if (!table) continue\n\n const oldChecks = table.checks.filter((tableCheck) => {\n return !metadata.checks.find(\n (checkMetadata) => checkMetadata.name === tableCheck.name,\n )\n })\n\n if (oldChecks.length === 0) continue\n\n this.connection.logger.logSchemaBuild(\n `dropping old check constraint: ${oldChecks\n .map((check) => `\"${check.name}\"`)\n .join(\", \")} from table \"${table.name}\"`,\n )\n await this.queryRunner.dropCheckConstraints(table, oldChecks)\n }\n }\n\n protected async dropCompositeUniqueConstraints(): Promise<void> {\n for (const metadata of this.entityToSyncMetadatas) {\n const table = this.queryRunner.loadedTables.find(\n (table) =>\n this.getTablePath(table) === this.getTablePath(metadata),\n )\n if (!table) continue\n\n const compositeUniques = table.uniques.filter((tableUnique) => {\n return (\n tableUnique.columnNames.length > 1 &&\n !metadata.uniques.find(\n (uniqueMetadata) =>\n uniqueMetadata.name === tableUnique.name,\n )\n )\n })\n\n if (compositeUniques.length === 0) continue\n\n this.connection.logger.logSchemaBuild(\n `dropping old unique constraint: ${compositeUniques\n .map((unique) => `\"${unique.name}\"`)\n .join(\", \")} from table \"${table.name}\"`,\n )\n await this.queryRunner.dropUniqueConstraints(\n table,\n compositeUniques,\n )\n }\n }\n\n protected async dropOldExclusions(): Promise<void> {\n // Only PostgreSQL supports exclusion constraints\n if (!(this.connection.driver.options.type === \"postgres\")) return\n\n for (const metadata of this.entityToSyncMetadatas) {\n const table = this.queryRunner.loadedTables.find(\n (table) =>\n this.getTablePath(table) === this.getTablePath(metadata),\n )\n if (!table) continue\n\n const oldExclusions = table.exclusions.filter((tableExclusion) => {\n return !metadata.exclusions.find(\n (exclusionMetadata) =>\n exclusionMetadata.name === tableExclusion.name,\n )\n })\n\n if (oldExclusions.length === 0) continue\n\n this.connection.logger.logSchemaBuild(\n `dropping old exclusion constraint: ${oldExclusions\n .map((exclusion) => `\"${exclusion.name}\"`)\n .join(\", \")} from table \"${table.name}\"`,\n )\n await this.queryRunner.dropExclusionConstraints(\n table,\n oldExclusions,\n )\n }\n }\n\n /**\n * Creates tables that do not exist in the database yet.\n * New tables are created without foreign and primary keys.\n * Primary key only can be created in conclusion with auto generated column.\n */\n protected async createNewTables(): Promise<void> {\n for (const metadata of this.entityToSyncMetadatas) {\n // check if table does not exist yet\n const existTable = this.queryRunner.loadedTables.find(\n (table) =>\n this.getTablePath(table) === this.getTablePath(metadata),\n )\n if (existTable) continue\n\n this.connection.logger.logSchemaBuild(\n `creating a new table: ${this.getTablePath(metadata)}`,\n )\n\n // create a new table and sync it in the database\n const table = Table.create(metadata, this.connection.driver)\n await this.queryRunner.createTable(table, false, false)\n this.queryRunner.loadedTables.push(table)\n }\n }\n\n protected async createViews(): Promise<void> {\n for (const metadata of this.viewEntityToSyncMetadatas) {\n // check if view does not exist yet\n const existView = this.queryRunner.loadedViews.find((view) => {\n const viewExpression =\n typeof view.expression === \"string\"\n ? view.expression.trim()\n : view.expression(this.connection).getQuery()\n const metadataExpression =\n typeof metadata.expression === \"string\"\n ? metadata.expression.trim()\n : metadata.expression!(this.connection).getQuery()\n return (\n this.getTablePath(view) === this.getTablePath(metadata) &&\n viewExpression === metadataExpression\n )\n })\n if (existView) continue\n\n this.connection.logger.logSchemaBuild(\n `creating a new view: ${this.getTablePath(metadata)}`,\n )\n\n // create a new view and sync it in the database\n const view = View.create(metadata, this.connection.driver)\n await this.queryRunner.createView(view, true)\n this.queryRunner.loadedViews.push(view)\n }\n }\n\n protected async dropOldViews(): Promise<void> {\n const droppedViews: Array<View> = []\n const viewEntityToSyncMetadatas = this.viewEntityToSyncMetadatas\n // BuIld lookup cache for finding views metadata\n const viewToMetadata = new Map<View, EntityMetadata>()\n for (const view of this.queryRunner.loadedViews) {\n const viewMetadata = viewEntityToSyncMetadatas.find((metadata) => {\n return this.getTablePath(view) === this.getTablePath(metadata)\n })\n if (viewMetadata) {\n viewToMetadata.set(view, viewMetadata)\n }\n }\n // Gather all changed view, that need a drop\n for (const view of this.queryRunner.loadedViews) {\n const viewMetadata = viewToMetadata.get(view)\n if (!viewMetadata) {\n continue\n }\n const viewExpression =\n typeof view.expression === \"string\"\n ? view.expression.trim()\n : view.expression(this.connection).getQuery()\n const metadataExpression =\n typeof viewMetadata.expression === \"string\"\n ? viewMetadata.expression.trim()\n : viewMetadata.expression!(this.connection).getQuery()\n\n if (viewExpression === metadataExpression) continue\n\n this.connection.logger.logSchemaBuild(\n `dropping an old view: ${view.name}`,\n )\n\n // Collect view to be dropped\n droppedViews.push(view)\n }\n\n // Helper function that for a given view, will recursively return list of the view and all views that depend on it\n const viewDependencyChain = (view: View): View[] => {\n // Get the view metadata\n const viewMetadata = viewToMetadata.get(view)\n let viewWithDependencies = [view]\n // If no metadata is known for the view, simply return the view itself\n if (!viewMetadata) {\n return viewWithDependencies\n }\n // Iterate over all known views\n for (const [\n currentView,\n currentMetadata,\n ] of viewToMetadata.entries()) {\n // Ignore self reference\n if (currentView === view) {\n continue\n }\n // If the currently iterated view depends on the passed in view\n if (\n currentMetadata.dependsOn &&\n (currentMetadata.dependsOn.has(viewMetadata.target) ||\n currentMetadata.dependsOn.has(viewMetadata.name))\n ) {\n // Recursively add currently iterate view and its dependents\n viewWithDependencies = viewWithDependencies.concat(\n viewDependencyChain(currentView),\n )\n }\n }\n // Return all collected views\n return viewWithDependencies\n }\n\n // Collect final list of views to be dropped in a Set so there are no duplicates\n const droppedViewsWithDependencies: Set<View> = new Set(\n // Collect all dropped views, and their dependencies\n droppedViews\n .map((view) => viewDependencyChain(view))\n // Flattened to single Array ( can be replaced with flatMap, once supported)\n .reduce((all, segment) => {\n return all.concat(segment)\n }, [])\n // Sort the views to be dropped in creation order\n .sort((a, b) => {\n return ViewUtils.viewMetadataCmp(\n viewToMetadata.get(a),\n viewToMetadata.get(b),\n )\n })\n // reverse order to get drop order\n .reverse(),\n )\n\n // Finally emit all drop views\n for (const view of droppedViewsWithDependencies) {\n await this.queryRunner.dropView(view)\n }\n this.queryRunner.loadedViews = this.queryRunner.loadedViews.filter(\n (view) => !droppedViewsWithDependencies.has(view),\n )\n }\n\n /**\n * Drops all columns that exist in the table, but does not exist in the metadata (left old).\n * We drop their keys too, since it should be safe.\n */\n protected async dropRemovedColumns(): Promise<void> {\n for (const metadata of this.entityToSyncMetadatas) {\n const table = this.queryRunner.loadedTables.find(\n (table) =>\n this.getTablePath(table) === this.getTablePath(metadata),\n )\n if (!table) continue\n\n // find columns that exist in the database but does not exist in the metadata\n const droppedTableColumns = table.columns.filter((tableColumn) => {\n return !metadata.columns.find(\n (columnMetadata) =>\n columnMetadata.isVirtualProperty ||\n columnMetadata.databaseName === tableColumn.name,\n )\n })\n if (droppedTableColumns.length === 0) continue\n\n this.connection.logger.logSchemaBuild(\n `columns dropped in ${table.name}: ` +\n droppedTableColumns.map((column) => column.name).join(\", \"),\n )\n\n // drop columns from the database\n await this.queryRunner.dropColumns(table, droppedTableColumns)\n }\n }\n\n /**\n * Adds columns from metadata which does not exist in the table.\n * Columns are created without keys.\n */\n protected async addNewColumns(): Promise<void> {\n for (const metadata of this.entityToSyncMetadatas) {\n const table = this.queryRunner.loadedTables.find(\n (table) =>\n this.getTablePath(table) === this.getTablePath(metadata),\n )\n if (!table) continue\n\n // find which columns are new\n const newColumnMetadatas = metadata.columns.filter(\n (columnMetadata) => {\n return (\n !columnMetadata.isVirtualProperty &&\n !table.columns.find(\n (tableColumn) =>\n tableColumn.name ===\n columnMetadata.databaseName,\n )\n )\n },\n )\n if (newColumnMetadatas.length === 0) continue\n\n // create columns in the database\n const newTableColumnOptions =\n this.metadataColumnsToTableColumnOptions(newColumnMetadatas)\n const newTableColumns = newTableColumnOptions.map(\n (option) => new TableColumn(option),\n )\n\n if (newTableColumns.length === 0) continue\n\n this.connection.logger.logSchemaBuild(\n `new columns added: ` +\n newColumnMetadatas\n .map((column) => column.databaseName)\n .join(\", \"),\n )\n await this.queryRunner.addColumns(table, newTableColumns)\n }\n }\n\n /**\n * Updates composite primary keys.\n */\n protected async updatePrimaryKeys(): Promise<void> {\n for (const metadata of this.entityToSyncMetadatas) {\n const table = this.queryRunner.loadedTables.find(\n (table) =>\n this.getTablePath(table) === this.getTablePath(metadata),\n )\n if (!table) continue\n\n const primaryMetadataColumns = metadata.columns.filter(\n (column) => column.isPrimary,\n )\n const primaryTableColumns = table.columns.filter(\n (column) => column.isPrimary,\n )\n if (\n primaryTableColumns.length !== primaryMetadataColumns.length &&\n primaryMetadataColumns.length > 1\n ) {\n const changedPrimaryColumns = primaryMetadataColumns.map(\n (primaryMetadataColumn) => {\n return new TableColumn(\n TableUtils.createTableColumnOptions(\n primaryMetadataColumn,\n this.connection.driver,\n ),\n )\n },\n )\n await this.queryRunner.updatePrimaryKeys(\n table,\n changedPrimaryColumns,\n )\n }\n }\n }\n\n /**\n * Update all exist columns which metadata has changed.\n * Still don't create keys. Also we don't touch foreign keys of the changed columns.\n */\n protected async updateExistColumns(): Promise<void> {\n for (const metadata of this.entityToSyncMetadatas) {\n const table = this.queryRunner.loadedTables.find(\n (table) =>\n this.getTablePath(table) === this.getTablePath(metadata),\n )\n if (!table) continue\n\n const changedColumns = this.connection.driver.findChangedColumns(\n table.columns,\n metadata.columns,\n )\n if (changedColumns.length === 0) continue\n\n // drop all foreign keys that point to this column\n for (const changedColumn of changedColumns) {\n await this.dropColumnReferencedForeignKeys(\n this.getTablePath(metadata),\n changedColumn.databaseName,\n )\n }\n\n // drop all composite indices related to this column\n for (const changedColumn of changedColumns) {\n await this.dropColumnCompositeIndices(\n this.getTablePath(metadata),\n changedColumn.databaseName,\n )\n }\n\n // drop all composite uniques related to this column\n // Mysql does not support unique constraints.\n if (\n !(\n DriverUtils.isMySQLFamily(this.connection.driver) ||\n this.connection.driver.options.type === \"aurora-mysql\" ||\n this.connection.driver.options.type === \"spanner\"\n )\n ) {\n for (const changedColumn of changedColumns) {\n await this.dropColumnCompositeUniques(\n this.getTablePath(metadata),\n changedColumn.databaseName,\n )\n }\n }\n\n // generate a map of new/old columns\n const newAndOldTableColumns = changedColumns.map(\n (changedColumn) => {\n const oldTableColumn = table.columns.find(\n (column) => column.name === changedColumn.databaseName,\n )!\n const newTableColumnOptions =\n TableUtils.createTableColumnOptions(\n changedColumn,\n this.connection.driver,\n )\n const newTableColumn = new TableColumn(\n newTableColumnOptions,\n )\n\n return {\n oldColumn: oldTableColumn,\n newColumn: newTableColumn,\n }\n },\n )\n\n if (newAndOldTableColumns.length === 0) continue\n\n this.connection.logger.logSchemaBuild(\n `columns changed in \"${table.name}\". updating: ` +\n changedColumns\n .map((column) => column.databaseName)\n .join(\", \"),\n )\n await this.queryRunner.changeColumns(table, newAndOldTableColumns)\n }\n }\n\n /**\n * Creates composite indices which are missing in db yet.\n */\n protected async createNewIndices(): Promise<void> {\n for (const metadata of this.entityToSyncMetadatas) {\n const table = this.queryRunner.loadedTables.find(\n (table) =>\n this.getTablePath(table) === this.getTablePath(metadata),\n )\n if (!table) continue\n\n const newIndices = metadata.indices\n .filter(\n (indexMetadata) =>\n !table.indices.find(\n (tableIndex) =>\n tableIndex.name === indexMetadata.name,\n ) && indexMetadata.synchronize === true,\n )\n .map((indexMetadata) => TableIndex.create(indexMetadata))\n\n if (newIndices.length === 0) continue\n\n this.connection.logger.logSchemaBuild(\n `adding new indices ${newIndices\n .map((index) => `\"${index.name}\"`)\n .join(\", \")} in table \"${table.name}\"`,\n )\n await this.queryRunner.createIndices(table, newIndices)\n }\n }\n\n /**\n * Creates indices for materialized views.\n */\n protected async createNewViewIndices(): Promise<void> {\n // Only PostgreSQL supports indices for materialized views.\n if (\n this.connection.options.type !== \"postgres\" ||\n !DriverUtils.isPostgresFamily(this.connection.driver)\n ) {\n return\n }\n const postgresQueryRunner: PostgresQueryRunner = <PostgresQueryRunner>(\n this.queryRunner\n )\n for (const metadata of this.viewEntityToSyncMetadatas) {\n // check if view does not exist yet\n const view = this.queryRunner.loadedViews.find((view) => {\n const viewExpression =\n typeof view.expression === \"string\"\n ? view.expression.trim()\n : view.expression(this.connection).getQuery()\n const metadataExpression =\n typeof metadata.expression === \"string\"\n ? metadata.expression.trim()\n : metadata.expression!(this.connection).getQuery()\n return (\n this.getTablePath(view) === this.getTablePath(metadata) &&\n viewExpression === metadataExpression\n )\n })\n if (!view || !view.materialized) continue\n\n const newIndices = metadata.indices\n .filter(\n (indexMetadata) =>\n !view.indices.find(\n (tableIndex) =>\n tableIndex.name === indexMetadata.name,\n ) && indexMetadata.synchronize === true,\n )\n .map((indexMetadata) => TableIndex.create(indexMetadata))\n\n if (newIndices.length === 0) continue\n\n this.connection.logger.logSchemaBuild(\n `adding new indices ${newIndices\n .map((index) => `\"${index.name}\"`)\n .join(\", \")} in view \"${view.name}\"`,\n )\n await postgresQueryRunner.createViewIndices(view, newIndices)\n }\n }\n\n protected async createNewChecks(): Promise<void> {\n // Mysql does not support check constraints\n if (\n DriverUtils.isMySQLFamily(this.connection.driver) ||\n this.connection.driver.options.type === \"aurora-mysql\"\n )\n return\n\n for (const metadata of this.entityToSyncMetadatas) {\n const table = this.queryRunner.loadedTables.find(\n (table) =>\n this.getTablePath(table) === this.getTablePath(metadata),\n )\n if (!table) continue\n\n const newChecks = metadata.checks\n .filter(\n (checkMetadata) =>\n !table.checks.find(\n (tableCheck) =>\n tableCheck.name === checkMetadata.name,\n ),\n )\n .map((checkMetadata) => TableCheck.create(checkMetadata))\n\n if (newChecks.length === 0) continue\n\n this.connection.logger.logSchemaBuild(\n `adding new check constraints: ${newChecks\n .map((index) => `\"${index.name}\"`)\n .join(\", \")} in table \"${table.name}\"`,\n )\n await this.queryRunner.createCheckConstraints(table, newChecks)\n }\n }\n\n /**\n * Creates composite uniques which are missing in db yet.\n */\n protected async createCompositeUniqueConstraints(): Promise<void> {\n for (const metadata of this.entityToSyncMetadatas) {\n const table = this.queryRunner.loadedTables.find(\n (table) =>\n this.getTablePath(table) === this.getTablePath(metadata),\n )\n if (!table) continue\n\n const compositeUniques = metadata.uniques\n .filter(\n (uniqueMetadata) =>\n uniqueMetadata.columns.length > 1 &&\n !table.uniques.find(\n (tableUnique) =>\n tableUnique.name === uniqueMetadata.name,\n ),\n )\n .map((uniqueMetadata) => TableUnique.create(uniqueMetadata))\n\n if (compositeUniques.length === 0) continue\n\n this.connection.logger.logSchemaBuild(\n `adding new unique constraints: ${compositeUniques\n .map((unique) => `\"${unique.name}\"`)\n .join(\", \")} in table \"${table.name}\"`,\n )\n await this.queryRunner.createUniqueConstraints(\n table,\n compositeUniques,\n )\n }\n }\n\n /**\n * Creates exclusions which are missing in db yet.\n */\n protected async createNewExclusions(): Promise<void> {\n // Only PostgreSQL supports exclusion constraints\n if (!(this.connection.driver.options.type === \"postgres\")) return\n\n for (const metadata of this.entityToSyncMetadatas) {\n const table = this.queryRunner.loadedTables.find(\n (table) =>\n this.getTablePath(table) === this.getTablePath(metadata),\n )\n if (!table) continue\n\n const newExclusions = metadata.exclusions\n .filter(\n (exclusionMetadata) =>\n !table.exclusions.find(\n (tableExclusion) =>\n tableExclusion.name === exclusionMetadata.name,\n ),\n )\n .map((exclusionMetadata) =>\n TableExclusion.create(exclusionMetadata),\n )\n\n if (newExclusions.length === 0) continue\n\n this.connection.logger.logSchemaBuild(\n `adding new exclusion constraints: ${newExclusions\n .map((exclusion) => `\"${exclusion.name}\"`)\n .join(\", \")} in table \"${table.name}\"`,\n )\n await this.queryRunner.createExclusionConstraints(\n table,\n newExclusions,\n )\n }\n }\n\n /**\n * Creates foreign keys which does not exist in the table yet.\n */\n protected async createForeignKeys(): Promise<void> {\n for (const metadata of this.entityToSyncMetadatas) {\n const table = this.queryRunner.loadedTables.find(\n (table) =>\n this.getTablePath(table) === this.getTablePath(metadata),\n )\n if (!table) continue\n\n const newKeys = metadata.foreignKeys.filter((foreignKey) => {\n return !table.foreignKeys.find(\n (dbForeignKey) =>\n dbForeignKey.name === foreignKey.name &&\n this.getTablePath(dbForeignKey) ===\n this.getTablePath(\n foreignKey.referencedEntityMetadata,\n ),\n )\n })\n if (newKeys.length === 0) continue\n\n const dbForeignKeys = newKeys.map((foreignKeyMetadata) =>\n TableForeignKey.create(\n foreignKeyMetadata,\n this.connection.driver,\n ),\n )\n this.connection.logger.logSchemaBuild(\n `creating a foreign keys: ${newKeys\n .map((key) => key.name)\n .join(\", \")} on table \"${table.name}\"`,\n )\n await this.queryRunner.createForeignKeys(table, dbForeignKeys)\n }\n }\n\n /**\n * Drops all foreign keys where given column of the given table is being used.\n */\n protected async dropColumnReferencedForeignKeys(\n tablePath: string,\n columnName: string,\n ): Promise<void> {\n const table = this.queryRunner.loadedTables.find(\n (table) => this.getTablePath(table) === tablePath,\n )\n if (!table) return\n\n const tablesWithFK: Table[] = []\n const columnForeignKey = table.foreignKeys.find(\n (foreignKey) => foreignKey.columnNames.indexOf(columnName) !== -1,\n )\n if (columnForeignKey) {\n const clonedTable = table.clone()\n clonedTable.foreignKeys = [columnForeignKey]\n tablesWithFK.push(clonedTable)\n table.removeForeignKey(columnForeignKey)\n }\n\n for (const loadedTable of this.queryRunner.loadedTables) {\n const dependForeignKeys = loadedTable.foreignKeys.filter(\n (foreignKey) => {\n return (\n this.getTablePath(foreignKey) === tablePath &&\n foreignKey.referencedColumnNames.indexOf(columnName) !==\n -1\n )\n },\n )\n\n if (dependForeignKeys.length > 0) {\n const clonedTable = loadedTable.clone()\n clonedTable.foreignKeys = dependForeignKeys\n tablesWithFK.push(clonedTable)\n dependForeignKeys.forEach((dependForeignKey) =>\n loadedTable.removeForeignKey(dependForeignKey),\n )\n }\n }\n\n if (tablesWithFK.length > 0) {\n for (const tableWithFK of tablesWithFK) {\n this.connection.logger.logSchemaBuild(\n `dropping related foreign keys of ${\n tableWithFK.name\n }: ${tableWithFK.foreignKeys\n .map((foreignKey) => foreignKey.name)\n .join(\", \")}`,\n )\n await this.queryRunner.dropForeignKeys(\n tableWithFK,\n tableWithFK.foreignKeys,\n )\n }\n }\n }\n\n /**\n * Drops all composite indices, related to given column.\n */\n protected async dropColumnCompositeIndices(\n tablePath: string,\n columnName: string,\n ): Promise<void> {\n const table = this.queryRunner.loadedTables.find(\n (table) => this.getTablePath(table) === tablePath,\n )\n if (!table) return\n\n const relatedIndices = table.indices.filter(\n (index) =>\n index.columnNames.length > 1 &&\n index.columnNames.indexOf(columnName) !== -1,\n )\n if (relatedIndices.length === 0) return\n\n this.connection.logger.logSchemaBuild(\n `dropping related indices of \"${tablePath}\".\"${columnName}\": ${relatedIndices\n .map((index) => index.name)\n .join(\", \")}`,\n )\n await this.queryRunner.dropIndices(table, relatedIndices)\n }\n\n /**\n * Drops all composite uniques, related to given column.\n */\n protected async dropColumnCompositeUniques(\n tablePath: string,\n columnName: string,\n ): Promise<void> {\n const table = this.queryRunner.loadedTables.find(\n (table) => this.getTablePath(table) === tablePath,\n )\n if (!table) return\n\n const relatedUniques = table.uniques.filter(\n (unique) =>\n unique.columnNames.length > 1 &&\n unique.columnNames.indexOf(columnName) !== -1,\n )\n if (relatedUniques.length === 0) return\n\n this.connection.logger.logSchemaBuild(\n `dropping related unique constraints of \"${tablePath}\".\"${columnName}\": ${relatedUniques\n .map((unique) => unique.name)\n .join(\", \")}`,\n )\n await this.queryRunner.dropUniqueConstraints(table, relatedUniques)\n }\n\n /**\n * Creates new columns from the given column metadatas.\n */\n protected metadataColumnsToTableColumnOptions(\n columns: ColumnMetadata[],\n ): TableColumnOptions[] {\n return columns.map((columnMetadata) =>\n TableUtils.createTableColumnOptions(\n columnMetadata,\n this.connection.driver,\n ),\n )\n }\n\n /**\n * Creates typeorm service table for storing user defined Views and generate columns.\n */\n protected async createTypeormMetadataTable(queryRunner: QueryRunner) {\n const schema = this.currentSchema\n const database = this.currentDatabase\n const typeormMetadataTable = this.connection.driver.buildTableName(\n this.connection.metadataTableName,\n schema,\n database,\n )\n\n // Spanner requires at least one primary key in a table.\n // Since we don't have unique column in \"typeorm_metadata\" table\n // and we should avoid breaking changes, we mark all columns as primary for Spanner driver.\n const isPrimary = this.connection.driver.options.type === \"spanner\"\n await queryRunner.createTable(\n new Table({\n database: database,\n schema: schema,\n name: typeormMetadataTable,\n columns: [\n {\n name: \"type\",\n type: this.connection.driver.normalizeType({\n type: this.connection.driver.mappedDataTypes\n .metadataType,\n }),\n isNullable: false,\n isPrimary,\n },\n {\n name: \"database\",\n type: this.connection.driver.normalizeType({\n type: this.connection.driver.mappedDataTypes\n .metadataDatabase,\n }),\n isNullable: true,\n isPrimary,\n },\n {\n name: \"schema\",\n type: this.connection.driver.normalizeType({\n type: this.connection.driver.mappedDataTypes\n .metadataSchema,\n }),\n isNullable: true,\n isPrimary,\n },\n {\n name: \"table\",\n type: this.connection.driver.normalizeType({\n type: this.connection.driver.mappedDataTypes\n .metadataTable,\n }),\n isNullable: true,\n isPrimary,\n },\n {\n name: \"name\",\n type: this.connection.driver.normalizeType({\n type: this.connection.driver.mappedDataTypes\n .metadataName,\n }),\n isNullable: true,\n isPrimary,\n },\n {\n name: \"value\",\n type: this.connection.driver.normalizeType({\n type: this.connection.driver.mappedDataTypes\n .metadataValue,\n }),\n isNullable: true,\n isPrimary,\n },\n ],\n }),\n true,\n )\n }\n}\n"],"sourceRoot":".."}
|
|
@@ -24,7 +24,7 @@ export declare class DbQueryResultCache implements QueryResultCache {
|
|
|
24
24
|
*/
|
|
25
25
|
synchronize(queryRunner?: QueryRunner): Promise<void>;
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
27
|
+
* Get data from cache.
|
|
28
28
|
* Returns cache result if found.
|
|
29
29
|
* Returns undefined if result is not cached.
|
|
30
30
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/cache/DbQueryResultCache.ts"],"names":[],"mappings":";;;AAEA,uEAAmE;AAEnE,yDAAqD;AAGrD,+BAAmC;AAEnC;;GAEG;AACH,MAAa,kBAAkB;IAW3B,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,YAAsB,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;QACxC,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,MAAM,YAAY,GACd,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,KAAK,QAAQ;YAC7C,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK;YAC/B,CAAC,CAAC,EAAE,CAAA;QACZ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,IAAI,CAAC,UAAU,CAAC,iBAAiB,EAAE,CAAA;IAC9C,CAAC;CACJ;AA/TD,gDA+TC","file":"DbQueryResultCache.js","sourcesContent":["import { ObjectLiteral } from \"../common/ObjectLiteral\"\nimport { DataSource } from \"../data-source/DataSource\"\nimport { MssqlParameter } from \"../driver/sqlserver/MssqlParameter\"\nimport { QueryRunner } from \"../query-runner/QueryRunner\"\nimport { Table } from \"../schema-builder/table/Table\"\nimport { QueryResultCache } from \"./QueryResultCache\"\nimport { QueryResultCacheOptions } from \"./QueryResultCacheOptions\"\nimport { v4 as uuidv4 } from \"uuid\"\n\n/**\n * Caches query result into current database, into separate table called \"query-result-cache\".\n */\nexport class DbQueryResultCache implements QueryResultCache {\n // -------------------------------------------------------------------------\n // Private properties\n // -------------------------------------------------------------------------\n\n private queryResultCacheTable: string\n\n private queryResultCacheDatabase?: string\n\n private queryResultCacheSchema?: string\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(protected connection: DataSource) {\n const { schema } = this.connection.driver.options as any\n const database = this.connection.driver.database\n const cacheOptions =\n typeof this.connection.options.cache === \"object\"\n ? this.connection.options.cache\n : {}\n const cacheTableName = cacheOptions.tableName || \"query-result-cache\"\n\n this.queryResultCacheDatabase = database\n this.queryResultCacheSchema = schema\n this.queryResultCacheTable = this.connection.driver.buildTableName(\n cacheTableName,\n schema,\n database,\n )\n }\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Creates a connection with given cache provider.\n */\n async connect(): Promise<void> {}\n\n /**\n * Disconnects with given cache provider.\n */\n async disconnect(): Promise<void> {}\n\n /**\n * Creates table for storing cache if it does not exist yet.\n */\n async synchronize(queryRunner?: QueryRunner): Promise<void> {\n queryRunner = this.getQueryRunner(queryRunner)\n const driver = this.connection.driver\n const tableExist = await queryRunner.hasTable(\n this.queryResultCacheTable,\n ) // todo: table name should be configurable\n if (tableExist) return\n\n await queryRunner.createTable(\n new Table({\n database: this.queryResultCacheDatabase,\n schema: this.queryResultCacheSchema,\n name: this.queryResultCacheTable,\n columns: [\n {\n name: \"id\",\n isPrimary: true,\n isNullable: false,\n type: driver.normalizeType({\n type: driver.mappedDataTypes.cacheId,\n }),\n generationStrategy:\n driver.options.type === \"spanner\"\n ? \"uuid\"\n : \"increment\",\n isGenerated: true,\n },\n {\n name: \"identifier\",\n type: driver.normalizeType({\n type: driver.mappedDataTypes.cacheIdentifier,\n }),\n isNullable: true,\n },\n {\n name: \"time\",\n type: driver.normalizeType({\n type: driver.mappedDataTypes.cacheTime,\n }),\n isPrimary: false,\n isNullable: false,\n },\n {\n name: \"duration\",\n type: driver.normalizeType({\n type: driver.mappedDataTypes.cacheDuration,\n }),\n isPrimary: false,\n isNullable: false,\n },\n {\n name: \"query\",\n type: driver.normalizeType({\n type: driver.mappedDataTypes.cacheQuery,\n }),\n isPrimary: false,\n isNullable: false,\n },\n {\n name: \"result\",\n type: driver.normalizeType({\n type: driver.mappedDataTypes.cacheResult,\n }),\n isNullable: false,\n },\n ],\n }),\n )\n }\n\n /**\n * Caches given query result.\n * Returns cache result if found.\n * Returns undefined if result is not cached.\n */\n getFromCache(\n options: QueryResultCacheOptions,\n queryRunner?: QueryRunner,\n ): Promise<QueryResultCacheOptions | undefined> {\n queryRunner = this.getQueryRunner(queryRunner)\n const qb = this.connection\n .createQueryBuilder(queryRunner)\n .select()\n .from(this.queryResultCacheTable, \"cache\")\n\n if (options.identifier) {\n return qb\n .where(\n `${qb.escape(\"cache\")}.${qb.escape(\n \"identifier\",\n )} = :identifier`,\n )\n .setParameters({\n identifier:\n this.connection.driver.options.type === \"mssql\"\n ? new MssqlParameter(options.identifier, \"nvarchar\")\n : options.identifier,\n })\n .getRawOne()\n } else if (options.query) {\n if (this.connection.driver.options.type === \"oracle\") {\n return qb\n .where(\n `dbms_lob.compare(${qb.escape(\"cache\")}.${qb.escape(\n \"query\",\n )}, :query) = 0`,\n { query: options.query },\n )\n .getRawOne()\n }\n\n return qb\n .where(`${qb.escape(\"cache\")}.${qb.escape(\"query\")} = :query`)\n .setParameters({\n query:\n this.connection.driver.options.type === \"mssql\"\n ? new MssqlParameter(options.query, \"nvarchar\")\n : options.query,\n })\n .getRawOne()\n }\n\n return Promise.resolve(undefined)\n }\n\n /**\n * Checks if cache is expired or not.\n */\n isExpired(savedCache: QueryResultCacheOptions): boolean {\n const duration =\n typeof savedCache.duration === \"string\"\n ? parseInt(savedCache.duration)\n : savedCache.duration\n return (\n (typeof savedCache.time === \"string\"\n ? parseInt(savedCache.time as any)\n : savedCache.time)! +\n duration <\n new Date().getTime()\n )\n }\n\n /**\n * Stores given query result in the cache.\n */\n async storeInCache(\n options: QueryResultCacheOptions,\n savedCache: QueryResultCacheOptions | undefined,\n queryRunner?: QueryRunner,\n ): Promise<void> {\n const shouldCreateQueryRunner =\n queryRunner === undefined ||\n queryRunner?.getReplicationMode() === \"slave\"\n\n if (queryRunner === undefined || shouldCreateQueryRunner) {\n queryRunner = this.connection.createQueryRunner(\"master\")\n }\n\n let insertedValues: ObjectLiteral = options\n if (this.connection.driver.options.type === \"mssql\") {\n // todo: bad abstraction, re-implement this part, probably better if we create an entity metadata for cache table\n insertedValues = {\n identifier: new MssqlParameter(options.identifier, \"nvarchar\"),\n time: new MssqlParameter(options.time, \"bigint\"),\n duration: new MssqlParameter(options.duration, \"int\"),\n query: new MssqlParameter(options.query, \"nvarchar\"),\n result: new MssqlParameter(options.result, \"nvarchar\"),\n }\n }\n\n if (savedCache && savedCache.identifier) {\n // if exist then update\n const qb = queryRunner.manager\n .createQueryBuilder()\n .update(this.queryResultCacheTable)\n .set(insertedValues)\n\n qb.where(`${qb.escape(\"identifier\")} = :condition`, {\n condition: insertedValues.identifier,\n })\n await qb.execute()\n } else if (savedCache && savedCache.query) {\n // if exist then update\n const qb = queryRunner.manager\n .createQueryBuilder()\n .update(this.queryResultCacheTable)\n .set(insertedValues)\n\n if (this.connection.driver.options.type === \"oracle\") {\n qb.where(`dbms_lob.compare(\"query\", :condition) = 0`, {\n condition: insertedValues.query,\n })\n } else {\n qb.where(`${qb.escape(\"query\")} = :condition`, {\n condition: insertedValues.query,\n })\n }\n\n await qb.execute()\n } else {\n // Spanner does not support auto-generated columns\n if (\n this.connection.driver.options.type === \"spanner\" &&\n !insertedValues.id\n ) {\n insertedValues.id = uuidv4()\n }\n\n // otherwise insert\n await queryRunner.manager\n .createQueryBuilder()\n .insert()\n .into(this.queryResultCacheTable)\n .values(insertedValues)\n .execute()\n }\n\n if (shouldCreateQueryRunner) {\n await queryRunner.release()\n }\n }\n\n /**\n * Clears everything stored in the cache.\n */\n async clear(queryRunner: QueryRunner): Promise<void> {\n return this.getQueryRunner(queryRunner).clearTable(\n this.queryResultCacheTable,\n )\n }\n\n /**\n * Removes all cached results by given identifiers from cache.\n */\n async remove(\n identifiers: string[],\n queryRunner?: QueryRunner,\n ): Promise<void> {\n let _queryRunner: QueryRunner = queryRunner || this.getQueryRunner()\n await Promise.all(\n identifiers.map((identifier) => {\n const qb = _queryRunner.manager.createQueryBuilder()\n return qb\n .delete()\n .from(this.queryResultCacheTable)\n .where(`${qb.escape(\"identifier\")} = :identifier`, {\n identifier,\n })\n .execute()\n }),\n )\n\n if (!queryRunner) {\n await _queryRunner.release()\n }\n }\n\n // -------------------------------------------------------------------------\n // Protected Methods\n // -------------------------------------------------------------------------\n\n /**\n * Gets a query runner to work with.\n */\n protected getQueryRunner(queryRunner?: QueryRunner): QueryRunner {\n if (queryRunner) return queryRunner\n\n return this.connection.createQueryRunner()\n }\n}\n"],"sourceRoot":".."}
|
|
1
|
+
{"version":3,"sources":["../../src/cache/DbQueryResultCache.ts"],"names":[],"mappings":";;;AAEA,uEAAmE;AAEnE,yDAAqD;AAGrD,+BAAmC;AAEnC;;GAEG;AACH,MAAa,kBAAkB;IAW3B,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,YAAsB,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;QACxC,MAAM,EAA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CAAC,gBAAgB,EAAE;gBAC/C,UAAU;aACb,CAAC;iBACD,OAAO,EAAE,CAAA;QAClB,CAAC,CAAC,CACL,CAAA;QAED,IAAI,CAAC,WAAW,EAAE;YACd,MAAM,YAAY,CAAC,OAAO,EAAE,CAAA;SAC/B;IACL,CAAC;IAED,4EAA4E;IAC5E,oBAAoB;IACpB,4EAA4E;IAE5E;;OAEG;IACO,cAAc,CAAC,WAAyB;QAC9C,IAAI,WAAW;YAAE,OAAO,WAAW,CAAA;QAEnC,OAAO,IAAI,CAAC,UAAU,CAAC,iBAAiB,EAAE,CAAA;IAC9C,CAAC;CACJ;AA/TD,gDA+TC","file":"DbQueryResultCache.js","sourcesContent":["import { ObjectLiteral } from \"../common/ObjectLiteral\"\nimport { DataSource } from \"../data-source/DataSource\"\nimport { MssqlParameter } from \"../driver/sqlserver/MssqlParameter\"\nimport { QueryRunner } from \"../query-runner/QueryRunner\"\nimport { Table } from \"../schema-builder/table/Table\"\nimport { QueryResultCache } from \"./QueryResultCache\"\nimport { QueryResultCacheOptions } from \"./QueryResultCacheOptions\"\nimport { v4 as uuidv4 } from \"uuid\"\n\n/**\n * Caches query result into current database, into separate table called \"query-result-cache\".\n */\nexport class DbQueryResultCache implements QueryResultCache {\n // -------------------------------------------------------------------------\n // Private properties\n // -------------------------------------------------------------------------\n\n private queryResultCacheTable: string\n\n private queryResultCacheDatabase?: string\n\n private queryResultCacheSchema?: string\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(protected connection: DataSource) {\n const { schema } = this.connection.driver.options as any\n const database = this.connection.driver.database\n const cacheOptions =\n typeof this.connection.options.cache === \"object\"\n ? this.connection.options.cache\n : {}\n const cacheTableName = cacheOptions.tableName || \"query-result-cache\"\n\n this.queryResultCacheDatabase = database\n this.queryResultCacheSchema = schema\n this.queryResultCacheTable = this.connection.driver.buildTableName(\n cacheTableName,\n schema,\n database,\n )\n }\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Creates a connection with given cache provider.\n */\n async connect(): Promise<void> {}\n\n /**\n * Disconnects with given cache provider.\n */\n async disconnect(): Promise<void> {}\n\n /**\n * Creates table for storing cache if it does not exist yet.\n */\n async synchronize(queryRunner?: QueryRunner): Promise<void> {\n queryRunner = this.getQueryRunner(queryRunner)\n const driver = this.connection.driver\n const tableExist = await queryRunner.hasTable(\n this.queryResultCacheTable,\n ) // todo: table name should be configurable\n if (tableExist) return\n\n await queryRunner.createTable(\n new Table({\n database: this.queryResultCacheDatabase,\n schema: this.queryResultCacheSchema,\n name: this.queryResultCacheTable,\n columns: [\n {\n name: \"id\",\n isPrimary: true,\n isNullable: false,\n type: driver.normalizeType({\n type: driver.mappedDataTypes.cacheId,\n }),\n generationStrategy:\n driver.options.type === \"spanner\"\n ? \"uuid\"\n : \"increment\",\n isGenerated: true,\n },\n {\n name: \"identifier\",\n type: driver.normalizeType({\n type: driver.mappedDataTypes.cacheIdentifier,\n }),\n isNullable: true,\n },\n {\n name: \"time\",\n type: driver.normalizeType({\n type: driver.mappedDataTypes.cacheTime,\n }),\n isPrimary: false,\n isNullable: false,\n },\n {\n name: \"duration\",\n type: driver.normalizeType({\n type: driver.mappedDataTypes.cacheDuration,\n }),\n isPrimary: false,\n isNullable: false,\n },\n {\n name: \"query\",\n type: driver.normalizeType({\n type: driver.mappedDataTypes.cacheQuery,\n }),\n isPrimary: false,\n isNullable: false,\n },\n {\n name: \"result\",\n type: driver.normalizeType({\n type: driver.mappedDataTypes.cacheResult,\n }),\n isNullable: false,\n },\n ],\n }),\n )\n }\n\n /**\n * Get data from cache.\n * Returns cache result if found.\n * Returns undefined if result is not cached.\n */\n getFromCache(\n options: QueryResultCacheOptions,\n queryRunner?: QueryRunner,\n ): Promise<QueryResultCacheOptions | undefined> {\n queryRunner = this.getQueryRunner(queryRunner)\n const qb = this.connection\n .createQueryBuilder(queryRunner)\n .select()\n .from(this.queryResultCacheTable, \"cache\")\n\n if (options.identifier) {\n return qb\n .where(\n `${qb.escape(\"cache\")}.${qb.escape(\n \"identifier\",\n )} = :identifier`,\n )\n .setParameters({\n identifier:\n this.connection.driver.options.type === \"mssql\"\n ? new MssqlParameter(options.identifier, \"nvarchar\")\n : options.identifier,\n })\n .getRawOne()\n } else if (options.query) {\n if (this.connection.driver.options.type === \"oracle\") {\n return qb\n .where(\n `dbms_lob.compare(${qb.escape(\"cache\")}.${qb.escape(\n \"query\",\n )}, :query) = 0`,\n { query: options.query },\n )\n .getRawOne()\n }\n\n return qb\n .where(`${qb.escape(\"cache\")}.${qb.escape(\"query\")} = :query`)\n .setParameters({\n query:\n this.connection.driver.options.type === \"mssql\"\n ? new MssqlParameter(options.query, \"nvarchar\")\n : options.query,\n })\n .getRawOne()\n }\n\n return Promise.resolve(undefined)\n }\n\n /**\n * Checks if cache is expired or not.\n */\n isExpired(savedCache: QueryResultCacheOptions): boolean {\n const duration =\n typeof savedCache.duration === \"string\"\n ? parseInt(savedCache.duration)\n : savedCache.duration\n return (\n (typeof savedCache.time === \"string\"\n ? parseInt(savedCache.time as any)\n : savedCache.time)! +\n duration <\n new Date().getTime()\n )\n }\n\n /**\n * Stores given query result in the cache.\n */\n async storeInCache(\n options: QueryResultCacheOptions,\n savedCache: QueryResultCacheOptions | undefined,\n queryRunner?: QueryRunner,\n ): Promise<void> {\n const shouldCreateQueryRunner =\n queryRunner === undefined ||\n queryRunner?.getReplicationMode() === \"slave\"\n\n if (queryRunner === undefined || shouldCreateQueryRunner) {\n queryRunner = this.connection.createQueryRunner(\"master\")\n }\n\n let insertedValues: ObjectLiteral = options\n if (this.connection.driver.options.type === \"mssql\") {\n // todo: bad abstraction, re-implement this part, probably better if we create an entity metadata for cache table\n insertedValues = {\n identifier: new MssqlParameter(options.identifier, \"nvarchar\"),\n time: new MssqlParameter(options.time, \"bigint\"),\n duration: new MssqlParameter(options.duration, \"int\"),\n query: new MssqlParameter(options.query, \"nvarchar\"),\n result: new MssqlParameter(options.result, \"nvarchar\"),\n }\n }\n\n if (savedCache && savedCache.identifier) {\n // if exist then update\n const qb = queryRunner.manager\n .createQueryBuilder()\n .update(this.queryResultCacheTable)\n .set(insertedValues)\n\n qb.where(`${qb.escape(\"identifier\")} = :condition`, {\n condition: insertedValues.identifier,\n })\n await qb.execute()\n } else if (savedCache && savedCache.query) {\n // if exist then update\n const qb = queryRunner.manager\n .createQueryBuilder()\n .update(this.queryResultCacheTable)\n .set(insertedValues)\n\n if (this.connection.driver.options.type === \"oracle\") {\n qb.where(`dbms_lob.compare(\"query\", :condition) = 0`, {\n condition: insertedValues.query,\n })\n } else {\n qb.where(`${qb.escape(\"query\")} = :condition`, {\n condition: insertedValues.query,\n })\n }\n\n await qb.execute()\n } else {\n // Spanner does not support auto-generated columns\n if (\n this.connection.driver.options.type === \"spanner\" &&\n !insertedValues.id\n ) {\n insertedValues.id = uuidv4()\n }\n\n // otherwise insert\n await queryRunner.manager\n .createQueryBuilder()\n .insert()\n .into(this.queryResultCacheTable)\n .values(insertedValues)\n .execute()\n }\n\n if (shouldCreateQueryRunner) {\n await queryRunner.release()\n }\n }\n\n /**\n * Clears everything stored in the cache.\n */\n async clear(queryRunner: QueryRunner): Promise<void> {\n return this.getQueryRunner(queryRunner).clearTable(\n this.queryResultCacheTable,\n )\n }\n\n /**\n * Removes all cached results by given identifiers from cache.\n */\n async remove(\n identifiers: string[],\n queryRunner?: QueryRunner,\n ): Promise<void> {\n let _queryRunner: QueryRunner = queryRunner || this.getQueryRunner()\n await Promise.all(\n identifiers.map((identifier) => {\n const qb = _queryRunner.manager.createQueryBuilder()\n return qb\n .delete()\n .from(this.queryResultCacheTable)\n .where(`${qb.escape(\"identifier\")} = :identifier`, {\n identifier,\n })\n .execute()\n }),\n )\n\n if (!queryRunner) {\n await _queryRunner.release()\n }\n }\n\n // -------------------------------------------------------------------------\n // Protected Methods\n // -------------------------------------------------------------------------\n\n /**\n * Gets a query runner to work with.\n */\n protected getQueryRunner(queryRunner?: QueryRunner): QueryRunner {\n if (queryRunner) return queryRunner\n\n return this.connection.createQueryRunner()\n }\n}\n"],"sourceRoot":".."}
|
|
@@ -6,7 +6,7 @@ export interface QueryResultCacheOptions {
|
|
|
6
6
|
* Cache identifier set by user.
|
|
7
7
|
* Can be empty.
|
|
8
8
|
*/
|
|
9
|
-
identifier
|
|
9
|
+
identifier?: string;
|
|
10
10
|
/**
|
|
11
11
|
* Time, when cache was created.
|
|
12
12
|
*/
|
|
@@ -18,7 +18,7 @@ export interface QueryResultCacheOptions {
|
|
|
18
18
|
/**
|
|
19
19
|
* Cached query.
|
|
20
20
|
*/
|
|
21
|
-
query
|
|
21
|
+
query?: string;
|
|
22
22
|
/**
|
|
23
23
|
* Query result that will be cached.
|
|
24
24
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/cache/QueryResultCacheOptions.ts"],"names":[],"mappings":"","file":"QueryResultCacheOptions.js","sourcesContent":["/**\n * Options passed to QueryResultCache class.\n */\nexport interface QueryResultCacheOptions {\n /**\n * Cache identifier set by user.\n * Can be empty.\n */\n identifier
|
|
1
|
+
{"version":3,"sources":["../../src/cache/QueryResultCacheOptions.ts"],"names":[],"mappings":"","file":"QueryResultCacheOptions.js","sourcesContent":["/**\n * Options passed to QueryResultCache class.\n */\nexport interface QueryResultCacheOptions {\n /**\n * Cache identifier set by user.\n * Can be empty.\n */\n identifier?: string\n\n /**\n * Time, when cache was created.\n */\n time?: number\n\n /**\n * Duration in milliseconds during which results will be returned from cache.\n */\n duration: number\n\n /**\n * Cached query.\n */\n query?: string\n\n /**\n * Query result that will be cached.\n */\n result?: any\n}\n"],"sourceRoot":".."}
|
|
@@ -33,7 +33,7 @@ export declare class RedisQueryResultCache implements QueryResultCache {
|
|
|
33
33
|
*/
|
|
34
34
|
synchronize(queryRunner: QueryRunner): Promise<void>;
|
|
35
35
|
/**
|
|
36
|
-
*
|
|
36
|
+
* Get data from cache.
|
|
37
37
|
* Returns cache result if found.
|
|
38
38
|
* Returns undefined if result is not cached.
|
|
39
39
|
*/
|