typeorm 0.3.11-dev.8a837f9 → 0.3.11-dev.cdabaa3
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/decorator/columns/VirtualColumn.d.ts +10 -0
- package/browser/decorator/columns/VirtualColumn.js +46 -0
- package/browser/decorator/columns/VirtualColumn.js.map +1 -0
- package/browser/decorator/options/VirtualColumnOptions.d.ts +27 -0
- package/browser/decorator/options/VirtualColumnOptions.js +3 -0
- package/browser/decorator/options/VirtualColumnOptions.js.map +1 -0
- package/browser/driver/aurora-mysql/AuroraMysqlDriver.js +4 -0
- package/browser/driver/aurora-mysql/AuroraMysqlDriver.js.map +1 -1
- package/browser/driver/aurora-mysql/AuroraMysqlQueryRunner.d.ts +1 -1
- package/browser/driver/aurora-mysql/AuroraMysqlQueryRunner.js +5 -3
- package/browser/driver/aurora-mysql/AuroraMysqlQueryRunner.js.map +1 -1
- package/browser/driver/cockroachdb/CockroachQueryRunner.d.ts +1 -1
- package/browser/driver/cockroachdb/CockroachQueryRunner.js +5 -3
- package/browser/driver/cockroachdb/CockroachQueryRunner.js.map +1 -1
- package/browser/driver/mysql/MysqlDriver.js +8 -0
- package/browser/driver/mysql/MysqlDriver.js.map +1 -1
- package/browser/driver/mysql/MysqlQueryRunner.d.ts +1 -1
- package/browser/driver/mysql/MysqlQueryRunner.js +5 -3
- package/browser/driver/mysql/MysqlQueryRunner.js.map +1 -1
- package/browser/driver/oracle/OracleDriver.js +4 -0
- package/browser/driver/oracle/OracleDriver.js.map +1 -1
- package/browser/driver/oracle/OracleQueryRunner.d.ts +1 -1
- package/browser/driver/oracle/OracleQueryRunner.js +5 -3
- package/browser/driver/oracle/OracleQueryRunner.js.map +1 -1
- package/browser/driver/postgres/PostgresDriver.js +4 -0
- package/browser/driver/postgres/PostgresDriver.js.map +1 -1
- package/browser/driver/postgres/PostgresQueryRunner.d.ts +1 -1
- package/browser/driver/postgres/PostgresQueryRunner.js +5 -3
- package/browser/driver/postgres/PostgresQueryRunner.js.map +1 -1
- package/browser/driver/sap/SapDriver.js +4 -0
- package/browser/driver/sap/SapDriver.js.map +1 -1
- package/browser/driver/sap/SapQueryRunner.d.ts +1 -1
- package/browser/driver/sap/SapQueryRunner.js +5 -3
- package/browser/driver/sap/SapQueryRunner.js.map +1 -1
- package/browser/driver/spanner/SpannerDriver.js +4 -0
- package/browser/driver/spanner/SpannerDriver.js.map +1 -1
- package/browser/driver/sqlite-abstract/AbstractSqliteDriver.js +4 -0
- package/browser/driver/sqlite-abstract/AbstractSqliteDriver.js.map +1 -1
- package/browser/driver/sqlite-abstract/AbstractSqliteQueryRunner.d.ts +1 -1
- package/browser/driver/sqlite-abstract/AbstractSqliteQueryRunner.js +5 -3
- package/browser/driver/sqlite-abstract/AbstractSqliteQueryRunner.js.map +1 -1
- package/browser/driver/sqlserver/SqlServerDriver.js +4 -0
- package/browser/driver/sqlserver/SqlServerDriver.js.map +1 -1
- package/browser/driver/sqlserver/SqlServerQueryRunner.d.ts +1 -1
- package/browser/driver/sqlserver/SqlServerQueryRunner.js +5 -3
- package/browser/driver/sqlserver/SqlServerQueryRunner.js.map +1 -1
- package/browser/index.d.ts +1 -0
- package/browser/index.js +1 -0
- package/browser/index.js.map +1 -1
- package/browser/metadata/ColumnMetadata.d.ts +12 -0
- package/browser/metadata/ColumnMetadata.js +13 -0
- package/browser/metadata/ColumnMetadata.js.map +1 -1
- package/browser/metadata-args/types/ColumnMode.d.ts +1 -1
- package/browser/metadata-args/types/ColumnMode.js.map +1 -1
- package/browser/metadata-builder/EntityMetadataValidator.js +9 -5
- package/browser/metadata-builder/EntityMetadataValidator.js.map +1 -1
- package/browser/migration/MigrationExecutor.js +13 -3
- package/browser/migration/MigrationExecutor.js.map +1 -1
- package/browser/query-builder/SelectQueryBuilder.js +22 -3
- package/browser/query-builder/SelectQueryBuilder.js.map +1 -1
- package/browser/query-runner/QueryRunner.d.ts +1 -1
- package/browser/query-runner/QueryRunner.js.map +1 -1
- package/browser/schema-builder/RdbmsSchemaBuilder.js +11 -5
- package/browser/schema-builder/RdbmsSchemaBuilder.js.map +1 -1
- package/browser/schema-builder/table/Table.js +1 -1
- package/browser/schema-builder/table/Table.js.map +1 -1
- package/browser/util/DateUtils.js +2 -1
- package/browser/util/DateUtils.js.map +1 -1
- package/decorator/columns/VirtualColumn.d.ts +10 -0
- package/decorator/columns/VirtualColumn.js +50 -0
- package/decorator/columns/VirtualColumn.js.map +1 -0
- package/decorator/options/VirtualColumnOptions.d.ts +27 -0
- package/decorator/options/VirtualColumnOptions.js +4 -0
- package/decorator/options/VirtualColumnOptions.js.map +1 -0
- package/driver/aurora-mysql/AuroraMysqlDriver.js +4 -0
- package/driver/aurora-mysql/AuroraMysqlDriver.js.map +1 -1
- package/driver/aurora-mysql/AuroraMysqlQueryRunner.d.ts +1 -1
- package/driver/aurora-mysql/AuroraMysqlQueryRunner.js +5 -3
- package/driver/aurora-mysql/AuroraMysqlQueryRunner.js.map +1 -1
- package/driver/cockroachdb/CockroachQueryRunner.d.ts +1 -1
- package/driver/cockroachdb/CockroachQueryRunner.js +5 -3
- package/driver/cockroachdb/CockroachQueryRunner.js.map +1 -1
- package/driver/mysql/MysqlDriver.js +8 -0
- package/driver/mysql/MysqlDriver.js.map +1 -1
- package/driver/mysql/MysqlQueryRunner.d.ts +1 -1
- package/driver/mysql/MysqlQueryRunner.js +5 -3
- package/driver/mysql/MysqlQueryRunner.js.map +1 -1
- package/driver/oracle/OracleDriver.js +4 -0
- package/driver/oracle/OracleDriver.js.map +1 -1
- package/driver/oracle/OracleQueryRunner.d.ts +1 -1
- package/driver/oracle/OracleQueryRunner.js +5 -3
- package/driver/oracle/OracleQueryRunner.js.map +1 -1
- package/driver/postgres/PostgresDriver.js +4 -0
- package/driver/postgres/PostgresDriver.js.map +1 -1
- package/driver/postgres/PostgresQueryRunner.d.ts +1 -1
- package/driver/postgres/PostgresQueryRunner.js +5 -3
- package/driver/postgres/PostgresQueryRunner.js.map +1 -1
- package/driver/sap/SapDriver.js +4 -0
- package/driver/sap/SapDriver.js.map +1 -1
- package/driver/sap/SapQueryRunner.d.ts +1 -1
- package/driver/sap/SapQueryRunner.js +5 -3
- package/driver/sap/SapQueryRunner.js.map +1 -1
- package/driver/spanner/SpannerDriver.js +4 -0
- package/driver/spanner/SpannerDriver.js.map +1 -1
- package/driver/sqlite-abstract/AbstractSqliteDriver.js +4 -0
- package/driver/sqlite-abstract/AbstractSqliteDriver.js.map +1 -1
- package/driver/sqlite-abstract/AbstractSqliteQueryRunner.d.ts +1 -1
- package/driver/sqlite-abstract/AbstractSqliteQueryRunner.js +5 -3
- package/driver/sqlite-abstract/AbstractSqliteQueryRunner.js.map +1 -1
- package/driver/sqlserver/SqlServerDriver.js +4 -0
- package/driver/sqlserver/SqlServerDriver.js.map +1 -1
- package/driver/sqlserver/SqlServerQueryRunner.d.ts +1 -1
- package/driver/sqlserver/SqlServerQueryRunner.js +5 -3
- package/driver/sqlserver/SqlServerQueryRunner.js.map +1 -1
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/index.js.map +1 -1
- package/index.mjs +2 -0
- package/metadata/ColumnMetadata.d.ts +12 -0
- package/metadata/ColumnMetadata.js +13 -0
- package/metadata/ColumnMetadata.js.map +1 -1
- package/metadata-args/types/ColumnMode.d.ts +1 -1
- package/metadata-args/types/ColumnMode.js.map +1 -1
- package/metadata-builder/EntityMetadataValidator.js +9 -5
- package/metadata-builder/EntityMetadataValidator.js.map +1 -1
- package/migration/MigrationExecutor.js +13 -3
- package/migration/MigrationExecutor.js.map +1 -1
- package/package.json +1 -1
- package/query-builder/SelectQueryBuilder.js +22 -3
- package/query-builder/SelectQueryBuilder.js.map +1 -1
- package/query-runner/QueryRunner.d.ts +1 -1
- package/query-runner/QueryRunner.js.map +1 -1
- package/schema-builder/RdbmsSchemaBuilder.js +11 -5
- package/schema-builder/RdbmsSchemaBuilder.js.map +1 -1
- package/schema-builder/table/Table.js +1 -1
- package/schema-builder/table/Table.js.map +1 -1
- package/util/DateUtils.js +2 -1
- package/util/DateUtils.js.map +1 -1
|
@@ -191,7 +191,7 @@ export interface QueryRunner {
|
|
|
191
191
|
/**
|
|
192
192
|
* Creates a new view.
|
|
193
193
|
*/
|
|
194
|
-
createView(view: View, oldView?: View): Promise<void>;
|
|
194
|
+
createView(view: View, syncWithMetadata?: boolean, oldView?: View): Promise<void>;
|
|
195
195
|
/**
|
|
196
196
|
* Drops a view.
|
|
197
197
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/query-runner/QueryRunner.ts"],"names":[],"mappings":"","file":"QueryRunner.js","sourcesContent":["import { TableColumn } from \"../schema-builder/table/TableColumn\"\nimport { Table } from \"../schema-builder/table/Table\"\nimport { TableForeignKey } from \"../schema-builder/table/TableForeignKey\"\nimport { TableIndex } from \"../schema-builder/table/TableIndex\"\nimport { DataSource } from \"../data-source/DataSource\"\nimport { ReadStream } from \"../platform/PlatformTools\"\nimport { EntityManager } from \"../entity-manager/EntityManager\"\nimport { ObjectLiteral } from \"../common/ObjectLiteral\"\nimport { SqlInMemory } from \"../driver/SqlInMemory\"\nimport { TableUnique } from \"../schema-builder/table/TableUnique\"\nimport { View } from \"../schema-builder/view/View\"\nimport { Broadcaster } from \"../subscriber/Broadcaster\"\nimport { TableCheck } from \"../schema-builder/table/TableCheck\"\nimport { IsolationLevel } from \"../driver/types/IsolationLevel\"\nimport { TableExclusion } from \"../schema-builder/table/TableExclusion\"\nimport { QueryResult } from \"./QueryResult\"\nimport { ReplicationMode } from \"../driver/types/ReplicationMode\"\n\n/**\n * Runs queries on a single database connection.\n */\nexport interface QueryRunner {\n /**\n * Connection used by this query runner.\n */\n readonly connection: DataSource\n\n /**\n * Broadcaster used on this query runner to broadcast entity events.\n */\n readonly broadcaster: Broadcaster\n\n /**\n * Entity manager working only with this query runner.\n */\n readonly manager: EntityManager\n\n /**\n * Indicates if connection for this query runner is released.\n * Once its released, query runner cannot run queries anymore.\n */\n readonly isReleased: boolean\n\n /**\n * Indicates if transaction is in progress.\n */\n readonly isTransactionActive: boolean\n\n /**\n * Stores temporarily user data.\n * Useful for sharing data with subscribers.\n */\n data: ObjectLiteral\n\n /**\n * All synchronized tables in the database.\n *\n * @deprecated Call `getTables()`\n */\n loadedTables: Table[]\n\n /**\n * All synchronized views in the database.\n *\n * @deprecated Call `getViews()`\n */\n loadedViews: View[]\n\n /**\n * Creates/uses database connection from the connection pool to perform further operations.\n * Returns obtained database connection.\n */\n connect(): Promise<any>\n\n /**\n * Called before migrations are run.\n */\n beforeMigration(): Promise<void>\n\n /**\n * Called after migrations are run.\n */\n afterMigration(): Promise<void>\n\n /**\n * Releases used database connection.\n * You cannot use query runner methods after connection is released.\n */\n release(): Promise<void>\n\n /**\n * Removes all tables from the currently connected database.\n * Be careful with using this method and avoid using it in production or migrations\n * (because it can clear all your database).\n */\n clearDatabase(database?: string): Promise<void>\n\n /**\n * Starts transaction.\n */\n startTransaction(isolationLevel?: IsolationLevel): Promise<void>\n\n /**\n * Commits transaction.\n * Error will be thrown if transaction was not started.\n */\n commitTransaction(): Promise<void>\n\n /**\n * Rollbacks transaction.\n * Error will be thrown if transaction was not started.\n */\n rollbackTransaction(): Promise<void>\n\n /**\n * Executes a given SQL query and returns raw database results.\n */\n query(\n query: string,\n parameters: any[] | undefined,\n useStructuredResult: true,\n ): Promise<QueryResult>\n\n /**\n * Executes a given SQL query and returns raw database results.\n */\n query(query: string, parameters?: any[]): Promise<any>\n\n /**\n * Returns raw data stream.\n */\n stream(\n query: string,\n parameters?: any[],\n onEnd?: Function,\n onError?: Function,\n ): Promise<ReadStream>\n\n /**\n * Returns all available database names including system databases.\n */\n getDatabases(): Promise<string[]>\n\n /**\n * Returns all available schema names including system schemas.\n * If database parameter specified, returns schemas of that database.\n * Useful for SQLServer and Postgres only.\n */\n getSchemas(database?: string): Promise<string[]>\n\n /**\n * Loads a table by a given name from the database.\n */\n getTable(tablePath: string): Promise<Table | undefined>\n\n /**\n * Loads all tables from the database and returns them.\n */\n getTables(tablePaths?: string[]): Promise<Table[]>\n\n /**\n * Loads a view by a given name from the database.\n */\n getView(viewPath: string): Promise<View | undefined>\n\n /**\n * Loads all views from the database and returns them.\n */\n getViews(viewPaths?: string[]): Promise<View[]>\n\n /**\n * Returns replication mode (ex: `master` or `slave`).\n */\n getReplicationMode(): ReplicationMode\n\n /**\n * Checks if a database with the given name exist.\n */\n hasDatabase(database: string): Promise<boolean>\n\n /**\n * Loads currently using database\n */\n getCurrentDatabase(): Promise<string | undefined>\n\n /**\n * Checks if a schema with the given name exist.\n */\n hasSchema(schema: string): Promise<boolean>\n\n /**\n * Loads currently using database schema\n */\n getCurrentSchema(): Promise<string | undefined>\n\n /**\n * Checks if a table with the given name exist.\n */\n hasTable(table: Table | string): Promise<boolean>\n\n /**\n * Checks if a column exist in the table.\n */\n hasColumn(table: Table | string, columnName: string): Promise<boolean>\n\n /**\n * Creates a new database.\n */\n createDatabase(database: string, ifNotExist?: boolean): Promise<void>\n\n /**\n * Drops database.\n */\n dropDatabase(database: string, ifExist?: boolean): Promise<void>\n\n /**\n * Creates a new table schema.\n */\n createSchema(schemaPath: string, ifNotExist?: boolean): Promise<void>\n\n /**\n * Drops table schema.\n * For SqlServer can accept schema path (e.g. 'dbName.schemaName') as parameter.\n * If schema path passed, it will drop schema in specified database.\n */\n dropSchema(\n schemaPath: string,\n ifExist?: boolean,\n isCascade?: boolean,\n ): Promise<void>\n\n /**\n * Creates a new table.\n */\n createTable(\n table: Table,\n ifNotExist?: boolean,\n createForeignKeys?: boolean,\n createIndices?: boolean,\n ): Promise<void>\n\n /**\n * Drops a table.\n */\n dropTable(\n table: Table | string,\n ifExist?: boolean,\n dropForeignKeys?: boolean,\n dropIndices?: boolean,\n ): Promise<void>\n\n /**\n * Creates a new view.\n */\n createView(view: View, oldView?: View): Promise<void>\n\n /**\n * Drops a view.\n */\n dropView(view: View | string): Promise<void>\n\n /**\n * Renames a table.\n */\n renameTable(\n oldTableOrName: Table | string,\n newTableName: string,\n ): Promise<void>\n\n /**\n * Adds a new column.\n */\n addColumn(table: Table | string, column: TableColumn): Promise<void>\n\n /**\n * Adds new columns.\n */\n addColumns(table: Table | string, columns: TableColumn[]): Promise<void>\n\n /**\n * Renames a column.\n */\n renameColumn(\n table: Table | string,\n oldColumnOrName: TableColumn | string,\n newColumnOrName: TableColumn | string,\n ): Promise<void>\n\n /**\n * Changes a column in the table.\n */\n changeColumn(\n table: Table | string,\n oldColumn: TableColumn | string,\n newColumn: TableColumn,\n ): Promise<void>\n\n /**\n * Changes columns in the table.\n */\n changeColumns(\n table: Table | string,\n changedColumns: { oldColumn: TableColumn; newColumn: TableColumn }[],\n ): Promise<void>\n\n /**\n * Drops a column in the table.\n */\n dropColumn(\n table: Table | string,\n column: TableColumn | string,\n ): Promise<void>\n\n /**\n * Drops columns in the table.\n */\n dropColumns(\n table: Table | string,\n columns: TableColumn[] | string[],\n ): Promise<void>\n\n /**\n * Creates a new primary key.\n */\n createPrimaryKey(\n table: Table | string,\n columnNames: string[],\n constraintName?: string,\n ): Promise<void>\n\n /**\n * Updates composite primary keys.\n */\n updatePrimaryKeys(\n table: Table | string,\n columns: TableColumn[],\n ): Promise<void>\n\n /**\n * Drops a primary key.\n */\n dropPrimaryKey(\n table: Table | string,\n constraintName?: string,\n ): Promise<void>\n\n /**\n * Creates a new unique constraint.\n */\n createUniqueConstraint(\n table: Table | string,\n uniqueConstraint: TableUnique,\n ): Promise<void>\n\n /**\n * Creates new unique constraints.\n */\n createUniqueConstraints(\n table: Table | string,\n uniqueConstraints: TableUnique[],\n ): Promise<void>\n\n /**\n * Drops an unique constraint.\n */\n dropUniqueConstraint(\n table: Table | string,\n uniqueOrName: TableUnique | string,\n ): Promise<void>\n\n /**\n * Drops unique constraints.\n */\n dropUniqueConstraints(\n table: Table | string,\n uniqueConstraints: TableUnique[],\n ): Promise<void>\n\n /**\n * Creates a new check constraint.\n */\n createCheckConstraint(\n table: Table | string,\n checkConstraint: TableCheck,\n ): Promise<void>\n\n /**\n * Creates new check constraints.\n */\n createCheckConstraints(\n table: Table | string,\n checkConstraints: TableCheck[],\n ): Promise<void>\n\n /**\n * Drops a check constraint.\n */\n dropCheckConstraint(\n table: Table | string,\n checkOrName: TableCheck | string,\n ): Promise<void>\n\n /**\n * Drops check constraints.\n */\n dropCheckConstraints(\n table: Table | string,\n checkConstraints: TableCheck[],\n ): Promise<void>\n\n /**\n * Creates a new exclusion constraint.\n */\n createExclusionConstraint(\n table: Table | string,\n exclusionConstraint: TableExclusion,\n ): Promise<void>\n\n /**\n * Creates new exclusion constraints.\n */\n createExclusionConstraints(\n table: Table | string,\n exclusionConstraints: TableExclusion[],\n ): Promise<void>\n\n /**\n * Drops a exclusion constraint.\n */\n dropExclusionConstraint(\n table: Table | string,\n exclusionOrName: TableExclusion | string,\n ): Promise<void>\n\n /**\n * Drops exclusion constraints.\n */\n dropExclusionConstraints(\n table: Table | string,\n exclusionConstraints: TableExclusion[],\n ): Promise<void>\n\n /**\n * Creates a new foreign key.\n */\n createForeignKey(\n table: Table | string,\n foreignKey: TableForeignKey,\n ): Promise<void>\n\n /**\n * Creates new foreign keys.\n */\n createForeignKeys(\n table: Table | string,\n foreignKeys: TableForeignKey[],\n ): Promise<void>\n\n /**\n * Drops a foreign key.\n */\n dropForeignKey(\n table: Table | string,\n foreignKeyOrName: TableForeignKey | string,\n ): Promise<void>\n\n /**\n * Drops foreign keys.\n */\n dropForeignKeys(\n table: Table | string,\n foreignKeys: TableForeignKey[],\n ): Promise<void>\n\n /**\n * Creates a new index.\n */\n createIndex(table: Table | string, index: TableIndex): Promise<void>\n\n /**\n * Creates new indices.\n */\n createIndices(table: Table | string, indices: TableIndex[]): Promise<void>\n\n /**\n * Drops an index.\n */\n dropIndex(table: Table | string, index: TableIndex | string): Promise<void>\n\n /**\n * Drops indices.\n */\n dropIndices(table: Table | string, indices: TableIndex[]): Promise<void>\n\n /**\n * Clears all table contents.\n * Note: this operation uses SQL's TRUNCATE query which cannot be reverted in transactions.\n */\n clearTable(tableName: string): Promise<void>\n\n /**\n * Enables special query runner mode in which sql queries won't be executed,\n * instead they will be memorized into a special variable inside query runner.\n * You can get memorized sql using getMemorySql() method.\n */\n enableSqlMemory(): void\n\n /**\n * Disables special query runner mode in which sql queries won't be executed\n * started by calling enableSqlMemory() method.\n *\n * Previously memorized sql will be flushed.\n */\n disableSqlMemory(): void\n\n /**\n * Flushes all memorized sqls.\n */\n clearSqlMemory(): void\n\n /**\n * Gets sql stored in the memory. Parameters in the sql are already replaced.\n */\n getMemorySql(): SqlInMemory\n\n /**\n * Executes up sql queries.\n */\n executeMemoryUpSql(): Promise<void>\n\n /**\n * Executes down sql queries.\n */\n executeMemoryDownSql(): Promise<void>\n}\n"],"sourceRoot":".."}
|
|
1
|
+
{"version":3,"sources":["../../src/query-runner/QueryRunner.ts"],"names":[],"mappings":"","file":"QueryRunner.js","sourcesContent":["import { TableColumn } from \"../schema-builder/table/TableColumn\"\nimport { Table } from \"../schema-builder/table/Table\"\nimport { TableForeignKey } from \"../schema-builder/table/TableForeignKey\"\nimport { TableIndex } from \"../schema-builder/table/TableIndex\"\nimport { DataSource } from \"../data-source/DataSource\"\nimport { ReadStream } from \"../platform/PlatformTools\"\nimport { EntityManager } from \"../entity-manager/EntityManager\"\nimport { ObjectLiteral } from \"../common/ObjectLiteral\"\nimport { SqlInMemory } from \"../driver/SqlInMemory\"\nimport { TableUnique } from \"../schema-builder/table/TableUnique\"\nimport { View } from \"../schema-builder/view/View\"\nimport { Broadcaster } from \"../subscriber/Broadcaster\"\nimport { TableCheck } from \"../schema-builder/table/TableCheck\"\nimport { IsolationLevel } from \"../driver/types/IsolationLevel\"\nimport { TableExclusion } from \"../schema-builder/table/TableExclusion\"\nimport { QueryResult } from \"./QueryResult\"\nimport { ReplicationMode } from \"../driver/types/ReplicationMode\"\n\n/**\n * Runs queries on a single database connection.\n */\nexport interface QueryRunner {\n /**\n * Connection used by this query runner.\n */\n readonly connection: DataSource\n\n /**\n * Broadcaster used on this query runner to broadcast entity events.\n */\n readonly broadcaster: Broadcaster\n\n /**\n * Entity manager working only with this query runner.\n */\n readonly manager: EntityManager\n\n /**\n * Indicates if connection for this query runner is released.\n * Once its released, query runner cannot run queries anymore.\n */\n readonly isReleased: boolean\n\n /**\n * Indicates if transaction is in progress.\n */\n readonly isTransactionActive: boolean\n\n /**\n * Stores temporarily user data.\n * Useful for sharing data with subscribers.\n */\n data: ObjectLiteral\n\n /**\n * All synchronized tables in the database.\n *\n * @deprecated Call `getTables()`\n */\n loadedTables: Table[]\n\n /**\n * All synchronized views in the database.\n *\n * @deprecated Call `getViews()`\n */\n loadedViews: View[]\n\n /**\n * Creates/uses database connection from the connection pool to perform further operations.\n * Returns obtained database connection.\n */\n connect(): Promise<any>\n\n /**\n * Called before migrations are run.\n */\n beforeMigration(): Promise<void>\n\n /**\n * Called after migrations are run.\n */\n afterMigration(): Promise<void>\n\n /**\n * Releases used database connection.\n * You cannot use query runner methods after connection is released.\n */\n release(): Promise<void>\n\n /**\n * Removes all tables from the currently connected database.\n * Be careful with using this method and avoid using it in production or migrations\n * (because it can clear all your database).\n */\n clearDatabase(database?: string): Promise<void>\n\n /**\n * Starts transaction.\n */\n startTransaction(isolationLevel?: IsolationLevel): Promise<void>\n\n /**\n * Commits transaction.\n * Error will be thrown if transaction was not started.\n */\n commitTransaction(): Promise<void>\n\n /**\n * Rollbacks transaction.\n * Error will be thrown if transaction was not started.\n */\n rollbackTransaction(): Promise<void>\n\n /**\n * Executes a given SQL query and returns raw database results.\n */\n query(\n query: string,\n parameters: any[] | undefined,\n useStructuredResult: true,\n ): Promise<QueryResult>\n\n /**\n * Executes a given SQL query and returns raw database results.\n */\n query(query: string, parameters?: any[]): Promise<any>\n\n /**\n * Returns raw data stream.\n */\n stream(\n query: string,\n parameters?: any[],\n onEnd?: Function,\n onError?: Function,\n ): Promise<ReadStream>\n\n /**\n * Returns all available database names including system databases.\n */\n getDatabases(): Promise<string[]>\n\n /**\n * Returns all available schema names including system schemas.\n * If database parameter specified, returns schemas of that database.\n * Useful for SQLServer and Postgres only.\n */\n getSchemas(database?: string): Promise<string[]>\n\n /**\n * Loads a table by a given name from the database.\n */\n getTable(tablePath: string): Promise<Table | undefined>\n\n /**\n * Loads all tables from the database and returns them.\n */\n getTables(tablePaths?: string[]): Promise<Table[]>\n\n /**\n * Loads a view by a given name from the database.\n */\n getView(viewPath: string): Promise<View | undefined>\n\n /**\n * Loads all views from the database and returns them.\n */\n getViews(viewPaths?: string[]): Promise<View[]>\n\n /**\n * Returns replication mode (ex: `master` or `slave`).\n */\n getReplicationMode(): ReplicationMode\n\n /**\n * Checks if a database with the given name exist.\n */\n hasDatabase(database: string): Promise<boolean>\n\n /**\n * Loads currently using database\n */\n getCurrentDatabase(): Promise<string | undefined>\n\n /**\n * Checks if a schema with the given name exist.\n */\n hasSchema(schema: string): Promise<boolean>\n\n /**\n * Loads currently using database schema\n */\n getCurrentSchema(): Promise<string | undefined>\n\n /**\n * Checks if a table with the given name exist.\n */\n hasTable(table: Table | string): Promise<boolean>\n\n /**\n * Checks if a column exist in the table.\n */\n hasColumn(table: Table | string, columnName: string): Promise<boolean>\n\n /**\n * Creates a new database.\n */\n createDatabase(database: string, ifNotExist?: boolean): Promise<void>\n\n /**\n * Drops database.\n */\n dropDatabase(database: string, ifExist?: boolean): Promise<void>\n\n /**\n * Creates a new table schema.\n */\n createSchema(schemaPath: string, ifNotExist?: boolean): Promise<void>\n\n /**\n * Drops table schema.\n * For SqlServer can accept schema path (e.g. 'dbName.schemaName') as parameter.\n * If schema path passed, it will drop schema in specified database.\n */\n dropSchema(\n schemaPath: string,\n ifExist?: boolean,\n isCascade?: boolean,\n ): Promise<void>\n\n /**\n * Creates a new table.\n */\n createTable(\n table: Table,\n ifNotExist?: boolean,\n createForeignKeys?: boolean,\n createIndices?: boolean,\n ): Promise<void>\n\n /**\n * Drops a table.\n */\n dropTable(\n table: Table | string,\n ifExist?: boolean,\n dropForeignKeys?: boolean,\n dropIndices?: boolean,\n ): Promise<void>\n\n /**\n * Creates a new view.\n */\n createView(\n view: View,\n syncWithMetadata?: boolean,\n oldView?: View,\n ): Promise<void>\n\n /**\n * Drops a view.\n */\n dropView(view: View | string): Promise<void>\n\n /**\n * Renames a table.\n */\n renameTable(\n oldTableOrName: Table | string,\n newTableName: string,\n ): Promise<void>\n\n /**\n * Adds a new column.\n */\n addColumn(table: Table | string, column: TableColumn): Promise<void>\n\n /**\n * Adds new columns.\n */\n addColumns(table: Table | string, columns: TableColumn[]): Promise<void>\n\n /**\n * Renames a column.\n */\n renameColumn(\n table: Table | string,\n oldColumnOrName: TableColumn | string,\n newColumnOrName: TableColumn | string,\n ): Promise<void>\n\n /**\n * Changes a column in the table.\n */\n changeColumn(\n table: Table | string,\n oldColumn: TableColumn | string,\n newColumn: TableColumn,\n ): Promise<void>\n\n /**\n * Changes columns in the table.\n */\n changeColumns(\n table: Table | string,\n changedColumns: { oldColumn: TableColumn; newColumn: TableColumn }[],\n ): Promise<void>\n\n /**\n * Drops a column in the table.\n */\n dropColumn(\n table: Table | string,\n column: TableColumn | string,\n ): Promise<void>\n\n /**\n * Drops columns in the table.\n */\n dropColumns(\n table: Table | string,\n columns: TableColumn[] | string[],\n ): Promise<void>\n\n /**\n * Creates a new primary key.\n */\n createPrimaryKey(\n table: Table | string,\n columnNames: string[],\n constraintName?: string,\n ): Promise<void>\n\n /**\n * Updates composite primary keys.\n */\n updatePrimaryKeys(\n table: Table | string,\n columns: TableColumn[],\n ): Promise<void>\n\n /**\n * Drops a primary key.\n */\n dropPrimaryKey(\n table: Table | string,\n constraintName?: string,\n ): Promise<void>\n\n /**\n * Creates a new unique constraint.\n */\n createUniqueConstraint(\n table: Table | string,\n uniqueConstraint: TableUnique,\n ): Promise<void>\n\n /**\n * Creates new unique constraints.\n */\n createUniqueConstraints(\n table: Table | string,\n uniqueConstraints: TableUnique[],\n ): Promise<void>\n\n /**\n * Drops an unique constraint.\n */\n dropUniqueConstraint(\n table: Table | string,\n uniqueOrName: TableUnique | string,\n ): Promise<void>\n\n /**\n * Drops unique constraints.\n */\n dropUniqueConstraints(\n table: Table | string,\n uniqueConstraints: TableUnique[],\n ): Promise<void>\n\n /**\n * Creates a new check constraint.\n */\n createCheckConstraint(\n table: Table | string,\n checkConstraint: TableCheck,\n ): Promise<void>\n\n /**\n * Creates new check constraints.\n */\n createCheckConstraints(\n table: Table | string,\n checkConstraints: TableCheck[],\n ): Promise<void>\n\n /**\n * Drops a check constraint.\n */\n dropCheckConstraint(\n table: Table | string,\n checkOrName: TableCheck | string,\n ): Promise<void>\n\n /**\n * Drops check constraints.\n */\n dropCheckConstraints(\n table: Table | string,\n checkConstraints: TableCheck[],\n ): Promise<void>\n\n /**\n * Creates a new exclusion constraint.\n */\n createExclusionConstraint(\n table: Table | string,\n exclusionConstraint: TableExclusion,\n ): Promise<void>\n\n /**\n * Creates new exclusion constraints.\n */\n createExclusionConstraints(\n table: Table | string,\n exclusionConstraints: TableExclusion[],\n ): Promise<void>\n\n /**\n * Drops a exclusion constraint.\n */\n dropExclusionConstraint(\n table: Table | string,\n exclusionOrName: TableExclusion | string,\n ): Promise<void>\n\n /**\n * Drops exclusion constraints.\n */\n dropExclusionConstraints(\n table: Table | string,\n exclusionConstraints: TableExclusion[],\n ): Promise<void>\n\n /**\n * Creates a new foreign key.\n */\n createForeignKey(\n table: Table | string,\n foreignKey: TableForeignKey,\n ): Promise<void>\n\n /**\n * Creates new foreign keys.\n */\n createForeignKeys(\n table: Table | string,\n foreignKeys: TableForeignKey[],\n ): Promise<void>\n\n /**\n * Drops a foreign key.\n */\n dropForeignKey(\n table: Table | string,\n foreignKeyOrName: TableForeignKey | string,\n ): Promise<void>\n\n /**\n * Drops foreign keys.\n */\n dropForeignKeys(\n table: Table | string,\n foreignKeys: TableForeignKey[],\n ): Promise<void>\n\n /**\n * Creates a new index.\n */\n createIndex(table: Table | string, index: TableIndex): Promise<void>\n\n /**\n * Creates new indices.\n */\n createIndices(table: Table | string, indices: TableIndex[]): Promise<void>\n\n /**\n * Drops an index.\n */\n dropIndex(table: Table | string, index: TableIndex | string): Promise<void>\n\n /**\n * Drops indices.\n */\n dropIndices(table: Table | string, indices: TableIndex[]): Promise<void>\n\n /**\n * Clears all table contents.\n * Note: this operation uses SQL's TRUNCATE query which cannot be reverted in transactions.\n */\n clearTable(tableName: string): Promise<void>\n\n /**\n * Enables special query runner mode in which sql queries won't be executed,\n * instead they will be memorized into a special variable inside query runner.\n * You can get memorized sql using getMemorySql() method.\n */\n enableSqlMemory(): void\n\n /**\n * Disables special query runner mode in which sql queries won't be executed\n * started by calling enableSqlMemory() method.\n *\n * Previously memorized sql will be flushed.\n */\n disableSqlMemory(): void\n\n /**\n * Flushes all memorized sqls.\n */\n clearSqlMemory(): void\n\n /**\n * Gets sql stored in the memory. Parameters in the sql are already replaced.\n */\n getMemorySql(): SqlInMemory\n\n /**\n * Executes up sql queries.\n */\n executeMemoryUpSql(): Promise<void>\n\n /**\n * Executes down sql queries.\n */\n executeMemoryDownSql(): Promise<void>\n}\n"],"sourceRoot":".."}
|
|
@@ -225,7 +225,9 @@ class RdbmsSchemaBuilder {
|
|
|
225
225
|
continue;
|
|
226
226
|
if (metadata.columns.length !== table.columns.length)
|
|
227
227
|
continue;
|
|
228
|
-
const renamedMetadataColumns = metadata.columns
|
|
228
|
+
const renamedMetadataColumns = metadata.columns
|
|
229
|
+
.filter((c) => !c.isVirtualProperty)
|
|
230
|
+
.filter((column) => {
|
|
229
231
|
return !table.columns.find((tableColumn) => {
|
|
230
232
|
return (tableColumn.name === column.databaseName &&
|
|
231
233
|
tableColumn.type ===
|
|
@@ -240,7 +242,8 @@ class RdbmsSchemaBuilder {
|
|
|
240
242
|
continue;
|
|
241
243
|
const renamedTableColumns = table.columns.filter((tableColumn) => {
|
|
242
244
|
return !metadata.columns.find((column) => {
|
|
243
|
-
return (column.
|
|
245
|
+
return (!column.isVirtualProperty &&
|
|
246
|
+
column.databaseName === tableColumn.name &&
|
|
244
247
|
this.connection.driver.normalizeType(column) ===
|
|
245
248
|
tableColumn.type &&
|
|
246
249
|
column.isNullable === tableColumn.isNullable &&
|
|
@@ -381,7 +384,7 @@ class RdbmsSchemaBuilder {
|
|
|
381
384
|
this.connection.logger.logSchemaBuild(`creating a new view: ${this.getTablePath(metadata)}`);
|
|
382
385
|
// create a new view and sync it in the database
|
|
383
386
|
const view = View_1.View.create(metadata, this.connection.driver);
|
|
384
|
-
await this.queryRunner.createView(view);
|
|
387
|
+
await this.queryRunner.createView(view, true);
|
|
385
388
|
this.queryRunner.loadedViews.push(view);
|
|
386
389
|
}
|
|
387
390
|
}
|
|
@@ -474,7 +477,8 @@ class RdbmsSchemaBuilder {
|
|
|
474
477
|
continue;
|
|
475
478
|
// find columns that exist in the database but does not exist in the metadata
|
|
476
479
|
const droppedTableColumns = table.columns.filter((tableColumn) => {
|
|
477
|
-
return !metadata.columns.find((columnMetadata) => columnMetadata.
|
|
480
|
+
return !metadata.columns.find((columnMetadata) => columnMetadata.isVirtualProperty ||
|
|
481
|
+
columnMetadata.databaseName === tableColumn.name);
|
|
478
482
|
});
|
|
479
483
|
if (droppedTableColumns.length === 0)
|
|
480
484
|
continue;
|
|
@@ -495,7 +499,9 @@ class RdbmsSchemaBuilder {
|
|
|
495
499
|
continue;
|
|
496
500
|
// find which columns are new
|
|
497
501
|
const newColumnMetadatas = metadata.columns.filter((columnMetadata) => {
|
|
498
|
-
return !
|
|
502
|
+
return (!columnMetadata.isVirtualProperty &&
|
|
503
|
+
!table.columns.find((tableColumn) => tableColumn.name ===
|
|
504
|
+
columnMetadata.databaseName));
|
|
499
505
|
});
|
|
500
506
|
if (newColumnMetadatas.length === 0)
|
|
501
507
|
continue;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/schema-builder/RdbmsSchemaBuilder.ts"],"names":[],"mappings":";;;AAAA,yCAAqC;AACrC,qDAAiD;AACjD,6DAAyD;AACzD,mDAA+C;AAO/C,kDAA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AS;iBACZ;gBACD;oBACI,IAAI,EAAE,QAAQ;oBACd,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,aAAa,CAAC;wBACvC,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,eAAe;6BACvC,cAAc;qBACtB,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;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;AA7sCD,gDA6sCC","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\"\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\n await this.queryRunner.getTables(tablePaths)\n await this.queryRunner.getViews([])\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 await this.queryRunner.getTables(tablePaths)\n await this.queryRunner.getViews([])\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 }\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.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.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 }\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)\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.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 !table.columns.find(\n (tableColumn) =>\n tableColumn.name === columnMetadata.databaseName,\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 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":["../../src/schema-builder/RdbmsSchemaBuilder.ts"],"names":[],"mappings":";;;AAAA,yCAAqC;AACrC,qDAAiD;AACjD,6DAAyD;AACzD,mDAA+C;AAO/C,kDAA8C;AAE9C,qDAAiD;AACjD,mDAA+C;AAC/C,2DAAuD;AACvD,sCAAkC;AAClC,gDAA4C;AAC5C,uDAAmD;AAEnD;;;;;;;;;;;;;GAaG;AACH,MAAa,kBAAkB;IAY3B,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,YAAsB,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;QAfnC,mBAAa,GAAG,MAAM,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAA;IAeV,CAAC;IAEhD,4EAA4E;IAC5E,iBAAiB;IACjB,4EAA4E;IAE5E;;OAEG;IACH,KAAK,CAAC,KAAK;QACP,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,UAAU,CAAC,iBAAiB,EAAE,CAAA;QAEtD,2DAA2D;QAC3D,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAA;QACtD,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,CAAA;QAElD,yGAAyG;QACzG,8FAA8F;QAC9F,4FAA4F;QAC5F,uCAAuC;QACvC,MAAM,mBAAmB,GACrB,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,KAAK,aAAa,CAAC;YACxD,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,KAAK,SAAS,CAAC;YACpD,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,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,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;AArtCD,gDAqtCC","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\"\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\n await this.queryRunner.getTables(tablePaths)\n await this.queryRunner.getViews([])\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 await this.queryRunner.getTables(tablePaths)\n await this.queryRunner.getViews([])\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 }\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 }\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 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":".."}
|
|
@@ -276,7 +276,7 @@ class Table {
|
|
|
276
276
|
withoutRowid: entityMetadata.withoutRowid,
|
|
277
277
|
engine: entityMetadata.engine,
|
|
278
278
|
columns: entityMetadata.columns
|
|
279
|
-
.filter((column) => column)
|
|
279
|
+
.filter((column) => column && !column.isVirtualProperty)
|
|
280
280
|
.map((column) => TableUtils_1.TableUtils.createTableColumnOptions(column, driver)),
|
|
281
281
|
indices: entityMetadata.indices
|
|
282
282
|
.filter((index) => index.synchronize === true)
|