taon-typeorm 18.0.19 → 18.0.21
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/assets/shared/shared_folder_info.txt +1 -1
- package/browser/esm2022/lib/typeorm/driver/cordova/CordovaDriver.mjs +1 -1
- package/browser/esm2022/lib/typeorm/driver/cordova/CordovaQueryRunner.mjs +1 -1
- package/browser/esm2022/lib/typeorm/driver/nativescript/NativescriptDriver.mjs +1 -1
- package/browser/esm2022/lib/typeorm/driver/nativescript/NativescriptQueryRunner.mjs +1 -1
- package/browser/esm2022/lib/typeorm/driver/react-native/ReactNativeDriver.mjs +1 -1
- package/browser/esm2022/lib/typeorm/driver/react-native/ReactNativeQueryRunner.mjs +1 -1
- package/browser/esm2022/lib/typeorm/driver/sqljs/SqljsDriver.mjs +1 -1
- package/browser/esm2022/lib/typeorm/driver/sqljs/SqljsQueryRunner.mjs +1 -1
- package/browser/esm2022/lib/typeorm/index.mjs +1 -3
- package/browser/fesm2022/taon-typeorm.mjs.map +1 -1
- package/client/esm2022/lib/typeorm/driver/cordova/CordovaDriver.mjs +1 -1
- package/client/esm2022/lib/typeorm/driver/cordova/CordovaQueryRunner.mjs +1 -1
- package/client/esm2022/lib/typeorm/driver/nativescript/NativescriptDriver.mjs +1 -1
- package/client/esm2022/lib/typeorm/driver/nativescript/NativescriptQueryRunner.mjs +1 -1
- package/client/esm2022/lib/typeorm/driver/react-native/ReactNativeDriver.mjs +1 -1
- package/client/esm2022/lib/typeorm/driver/react-native/ReactNativeQueryRunner.mjs +1 -1
- package/client/esm2022/lib/typeorm/driver/sqljs/SqljsDriver.mjs +1 -1
- package/client/esm2022/lib/typeorm/driver/sqljs/SqljsQueryRunner.mjs +1 -1
- package/client/esm2022/lib/typeorm/index.mjs +1 -3
- package/client/fesm2022/taon-typeorm.mjs.map +1 -1
- package/index.js +15 -2
- package/index.js.map +1 -1
- package/lib/build-info._auto-generated_.js.map +1 -1
- package/lib/index._auto-generated_.d.ts +1 -0
- package/lib/index._auto-generated_.js.map +1 -1
- package/lib/index.js +15 -2
- package/lib/index.js.map +1 -1
- package/lib/typeorm/cache/DbQueryResultCache.js +178 -231
- package/lib/typeorm/cache/DbQueryResultCache.js.map +1 -1
- package/lib/typeorm/cache/QueryResultCache.js.map +1 -1
- package/lib/typeorm/cache/QueryResultCacheFactory.js +11 -11
- package/lib/typeorm/cache/QueryResultCacheFactory.js.map +1 -1
- package/lib/typeorm/cache/QueryResultCacheOptions.js.map +1 -1
- package/lib/typeorm/cache/RedisQueryResultCache.js +121 -149
- package/lib/typeorm/cache/RedisQueryResultCache.js.map +1 -1
- package/lib/typeorm/cli-ts-node-commonjs.js.map +1 -1
- package/lib/typeorm/cli-ts-node-esm.js +7 -5
- package/lib/typeorm/cli-ts-node-esm.js.map +1 -1
- package/lib/typeorm/cli.d.ts +1 -1
- package/lib/typeorm/cli.js +15 -16
- package/lib/typeorm/cli.js.map +1 -1
- package/lib/typeorm/commands/CacheClearCommand.js +37 -65
- package/lib/typeorm/commands/CacheClearCommand.js.map +1 -1
- package/lib/typeorm/commands/CommandUtils.js +57 -112
- package/lib/typeorm/commands/CommandUtils.js.map +1 -1
- package/lib/typeorm/commands/EntityCreateCommand.js +35 -47
- package/lib/typeorm/commands/EntityCreateCommand.js.map +1 -1
- package/lib/typeorm/commands/InitCommand.js +397 -168
- package/lib/typeorm/commands/InitCommand.js.map +1 -1
- package/lib/typeorm/commands/MigrationCreateCommand.js +58 -52
- package/lib/typeorm/commands/MigrationCreateCommand.js.map +1 -1
- package/lib/typeorm/commands/MigrationGenerateCommand.js +141 -138
- package/lib/typeorm/commands/MigrationGenerateCommand.js.map +1 -1
- package/lib/typeorm/commands/MigrationRevertCommand.js +49 -77
- package/lib/typeorm/commands/MigrationRevertCommand.js.map +1 -1
- package/lib/typeorm/commands/MigrationRunCommand.js +52 -82
- package/lib/typeorm/commands/MigrationRunCommand.js.map +1 -1
- package/lib/typeorm/commands/MigrationShowCommand.js +32 -60
- package/lib/typeorm/commands/MigrationShowCommand.js.map +1 -1
- package/lib/typeorm/commands/QueryCommand.js +47 -83
- package/lib/typeorm/commands/QueryCommand.js.map +1 -1
- package/lib/typeorm/commands/SchemaDropCommand.js +33 -61
- package/lib/typeorm/commands/SchemaDropCommand.js.map +1 -1
- package/lib/typeorm/commands/SchemaLogCommand.js +57 -81
- package/lib/typeorm/commands/SchemaLogCommand.js.map +1 -1
- package/lib/typeorm/commands/SchemaSyncCommand.js +33 -61
- package/lib/typeorm/commands/SchemaSyncCommand.js.map +1 -1
- package/lib/typeorm/commands/SubscriberCreateCommand.js +35 -47
- package/lib/typeorm/commands/SubscriberCreateCommand.js.map +1 -1
- package/lib/typeorm/commands/VersionCommand.js +38 -54
- package/lib/typeorm/commands/VersionCommand.js.map +1 -1
- package/lib/typeorm/common/DeepPartial.js.map +1 -1
- package/lib/typeorm/common/EntityTarget.js.map +1 -1
- package/lib/typeorm/common/MixedList.js.map +1 -1
- package/lib/typeorm/common/NonNever.js.map +1 -1
- package/lib/typeorm/common/ObjectLiteral.js.map +1 -1
- package/lib/typeorm/common/ObjectType.js.map +1 -1
- package/lib/typeorm/common/RelationType.js.map +1 -1
- package/lib/typeorm/connection/BaseConnectionOptions.js.map +1 -1
- package/lib/typeorm/connection/Connection.js +3 -9
- package/lib/typeorm/connection/Connection.js.map +1 -1
- package/lib/typeorm/connection/ConnectionManager.js +23 -31
- package/lib/typeorm/connection/ConnectionManager.js.map +1 -1
- package/lib/typeorm/connection/ConnectionMetadataBuilder.js +48 -78
- package/lib/typeorm/connection/ConnectionMetadataBuilder.js.map +1 -1
- package/lib/typeorm/connection/ConnectionOptions.js.map +1 -1
- package/lib/typeorm/connection/ConnectionOptionsReader.js +146 -214
- package/lib/typeorm/connection/ConnectionOptionsReader.js.map +1 -1
- package/lib/typeorm/connection/options-reader/ConnectionOptionsEnvReader.js +50 -58
- package/lib/typeorm/connection/options-reader/ConnectionOptionsEnvReader.js.map +1 -1
- package/lib/typeorm/connection/options-reader/ConnectionOptionsXmlReader.js +45 -58
- package/lib/typeorm/connection/options-reader/ConnectionOptionsXmlReader.js.map +1 -1
- package/lib/typeorm/connection/options-reader/ConnectionOptionsYmlReader.js +14 -23
- package/lib/typeorm/connection/options-reader/ConnectionOptionsYmlReader.js.map +1 -1
- package/lib/typeorm/constants.js.map +1 -1
- package/lib/typeorm/container.js +9 -12
- package/lib/typeorm/container.js.map +1 -1
- package/lib/typeorm/data-source/BaseDataSourceOptions.js.map +1 -1
- package/lib/typeorm/data-source/DataSource.js +320 -478
- package/lib/typeorm/data-source/DataSource.js.map +1 -1
- package/lib/typeorm/data-source/DataSourceOptions.js.map +1 -1
- package/lib/typeorm/data-source/index.js +16 -3
- package/lib/typeorm/data-source/index.js.map +1 -1
- package/lib/typeorm/decorator/Check.js +5 -5
- package/lib/typeorm/decorator/Check.js.map +1 -1
- package/lib/typeorm/decorator/EntityRepository.js +1 -1
- package/lib/typeorm/decorator/EntityRepository.js.map +1 -1
- package/lib/typeorm/decorator/Exclusion.js +5 -5
- package/lib/typeorm/decorator/Exclusion.js.map +1 -1
- package/lib/typeorm/decorator/Generated.js +2 -3
- package/lib/typeorm/decorator/Generated.js.map +1 -1
- package/lib/typeorm/decorator/Index.js +5 -5
- package/lib/typeorm/decorator/Index.js.map +1 -1
- package/lib/typeorm/decorator/Unique.js +8 -8
- package/lib/typeorm/decorator/Unique.js.map +1 -1
- package/lib/typeorm/decorator/columns/Column.js +4 -4
- package/lib/typeorm/decorator/columns/Column.js.map +1 -1
- package/lib/typeorm/decorator/columns/CreateDateColumn.js +1 -1
- package/lib/typeorm/decorator/columns/CreateDateColumn.js.map +1 -1
- package/lib/typeorm/decorator/columns/DeleteDateColumn.js +1 -1
- package/lib/typeorm/decorator/columns/DeleteDateColumn.js.map +1 -1
- package/lib/typeorm/decorator/columns/ObjectIdColumn.js +1 -1
- package/lib/typeorm/decorator/columns/ObjectIdColumn.js.map +1 -1
- package/lib/typeorm/decorator/columns/PrimaryColumn.js +5 -5
- package/lib/typeorm/decorator/columns/PrimaryColumn.js.map +1 -1
- package/lib/typeorm/decorator/columns/PrimaryGeneratedColumn.js +4 -4
- package/lib/typeorm/decorator/columns/PrimaryGeneratedColumn.js.map +1 -1
- package/lib/typeorm/decorator/columns/UpdateDateColumn.js +1 -1
- package/lib/typeorm/decorator/columns/UpdateDateColumn.js.map +1 -1
- package/lib/typeorm/decorator/columns/VersionColumn.js +1 -1
- package/lib/typeorm/decorator/columns/VersionColumn.js.map +1 -1
- package/lib/typeorm/decorator/columns/ViewColumn.js +1 -1
- package/lib/typeorm/decorator/columns/ViewColumn.js.map +1 -1
- package/lib/typeorm/decorator/columns/VirtualColumn.js +5 -5
- package/lib/typeorm/decorator/columns/VirtualColumn.js.map +1 -1
- package/lib/typeorm/decorator/entity/ChildEntity.js +1 -1
- package/lib/typeorm/decorator/entity/ChildEntity.js.map +1 -1
- package/lib/typeorm/decorator/entity/Entity.js +4 -4
- package/lib/typeorm/decorator/entity/Entity.js.map +1 -1
- package/lib/typeorm/decorator/entity/TableInheritance.js +1 -1
- package/lib/typeorm/decorator/entity/TableInheritance.js.map +1 -1
- package/lib/typeorm/decorator/entity-view/ViewEntity.js +4 -4
- package/lib/typeorm/decorator/entity-view/ViewEntity.js.map +1 -1
- package/lib/typeorm/decorator/listeners/AfterInsert.js +2 -2
- package/lib/typeorm/decorator/listeners/AfterInsert.js.map +1 -1
- package/lib/typeorm/decorator/listeners/AfterLoad.js +2 -2
- package/lib/typeorm/decorator/listeners/AfterLoad.js.map +1 -1
- package/lib/typeorm/decorator/listeners/AfterRecover.js +2 -2
- package/lib/typeorm/decorator/listeners/AfterRecover.js.map +1 -1
- package/lib/typeorm/decorator/listeners/AfterRemove.js +2 -2
- package/lib/typeorm/decorator/listeners/AfterRemove.js.map +1 -1
- package/lib/typeorm/decorator/listeners/AfterSoftRemove.js +2 -2
- package/lib/typeorm/decorator/listeners/AfterSoftRemove.js.map +1 -1
- package/lib/typeorm/decorator/listeners/AfterUpdate.js +2 -2
- package/lib/typeorm/decorator/listeners/AfterUpdate.js.map +1 -1
- package/lib/typeorm/decorator/listeners/BeforeInsert.js +2 -2
- package/lib/typeorm/decorator/listeners/BeforeInsert.js.map +1 -1
- package/lib/typeorm/decorator/listeners/BeforeRecover.js +2 -2
- package/lib/typeorm/decorator/listeners/BeforeRecover.js.map +1 -1
- package/lib/typeorm/decorator/listeners/BeforeRemove.js +2 -2
- package/lib/typeorm/decorator/listeners/BeforeRemove.js.map +1 -1
- package/lib/typeorm/decorator/listeners/BeforeSoftRemove.js +2 -2
- package/lib/typeorm/decorator/listeners/BeforeSoftRemove.js.map +1 -1
- package/lib/typeorm/decorator/listeners/BeforeUpdate.js +2 -2
- package/lib/typeorm/decorator/listeners/BeforeUpdate.js.map +1 -1
- package/lib/typeorm/decorator/listeners/EventSubscriber.js +1 -1
- package/lib/typeorm/decorator/listeners/EventSubscriber.js.map +1 -1
- package/lib/typeorm/decorator/options/ColumnCommonOptions.js.map +1 -1
- package/lib/typeorm/decorator/options/ColumnEmbeddedOptions.js.map +1 -1
- package/lib/typeorm/decorator/options/ColumnEnumOptions.js.map +1 -1
- package/lib/typeorm/decorator/options/ColumnHstoreOptions.js.map +1 -1
- package/lib/typeorm/decorator/options/ColumnNumericOptions.js.map +1 -1
- package/lib/typeorm/decorator/options/ColumnOptions.js.map +1 -1
- package/lib/typeorm/decorator/options/ColumnWithLengthOptions.js.map +1 -1
- package/lib/typeorm/decorator/options/ColumnWithWidthOptions.js.map +1 -1
- package/lib/typeorm/decorator/options/EntityOptions.js.map +1 -1
- package/lib/typeorm/decorator/options/IndexOptions.js.map +1 -1
- package/lib/typeorm/decorator/options/JoinColumnOptions.js.map +1 -1
- package/lib/typeorm/decorator/options/JoinTableMultipleColumnsOptions.js.map +1 -1
- package/lib/typeorm/decorator/options/JoinTableOptions.js.map +1 -1
- package/lib/typeorm/decorator/options/PrimaryGeneratedColumnIdentityOptions.js.map +1 -1
- package/lib/typeorm/decorator/options/PrimaryGeneratedColumnNumericOptions.js.map +1 -1
- package/lib/typeorm/decorator/options/PrimaryGeneratedColumnUUIDOptions.js.map +1 -1
- package/lib/typeorm/decorator/options/RelationOptions.js.map +1 -1
- package/lib/typeorm/decorator/options/SpatialColumnOptions.js.map +1 -1
- package/lib/typeorm/decorator/options/TransactionOptions.js.map +1 -1
- package/lib/typeorm/decorator/options/UniqueOptions.js.map +1 -1
- package/lib/typeorm/decorator/options/ValueTransformer.js.map +1 -1
- package/lib/typeorm/decorator/options/ViewColumnOptions.js.map +1 -1
- package/lib/typeorm/decorator/options/ViewEntityOptions.js.map +1 -1
- package/lib/typeorm/decorator/options/VirtualColumnOptions.js.map +1 -1
- package/lib/typeorm/decorator/relations/JoinColumn.js +3 -3
- package/lib/typeorm/decorator/relations/JoinColumn.js.map +1 -1
- package/lib/typeorm/decorator/relations/JoinTable.js +1 -1
- package/lib/typeorm/decorator/relations/JoinTable.js.map +1 -1
- package/lib/typeorm/decorator/relations/ManyToMany.js +5 -5
- package/lib/typeorm/decorator/relations/ManyToMany.js.map +1 -1
- package/lib/typeorm/decorator/relations/ManyToOne.js +5 -5
- package/lib/typeorm/decorator/relations/ManyToOne.js.map +1 -1
- package/lib/typeorm/decorator/relations/OneToMany.js +3 -3
- package/lib/typeorm/decorator/relations/OneToMany.js.map +1 -1
- package/lib/typeorm/decorator/relations/OneToOne.js +5 -5
- package/lib/typeorm/decorator/relations/OneToOne.js.map +1 -1
- package/lib/typeorm/decorator/relations/RelationCount.js +1 -1
- package/lib/typeorm/decorator/relations/RelationCount.js.map +1 -1
- package/lib/typeorm/decorator/relations/RelationId.js +1 -1
- package/lib/typeorm/decorator/relations/RelationId.js.map +1 -1
- package/lib/typeorm/decorator/tree/Tree.js +1 -1
- package/lib/typeorm/decorator/tree/Tree.js.map +1 -1
- package/lib/typeorm/decorator/tree/TreeChildren.js +4 -4
- package/lib/typeorm/decorator/tree/TreeChildren.js.map +1 -1
- package/lib/typeorm/decorator/tree/TreeLevelColumn.js +1 -1
- package/lib/typeorm/decorator/tree/TreeLevelColumn.js.map +1 -1
- package/lib/typeorm/decorator/tree/TreeParent.js +4 -4
- package/lib/typeorm/decorator/tree/TreeParent.js.map +1 -1
- package/lib/typeorm/driver/Driver.js.map +1 -1
- package/lib/typeorm/driver/DriverFactory.js +24 -27
- package/lib/typeorm/driver/DriverFactory.js.map +1 -1
- package/lib/typeorm/driver/DriverUtils.js +78 -126
- package/lib/typeorm/driver/DriverUtils.js.map +1 -1
- package/lib/typeorm/driver/Query.js +6 -5
- package/lib/typeorm/driver/Query.js.map +1 -1
- package/lib/typeorm/driver/SqlInMemory.js +4 -7
- package/lib/typeorm/driver/SqlInMemory.js.map +1 -1
- package/lib/typeorm/driver/aurora-mysql/AuroraMysqlConnection.js +9 -12
- package/lib/typeorm/driver/aurora-mysql/AuroraMysqlConnection.js.map +1 -1
- package/lib/typeorm/driver/aurora-mysql/AuroraMysqlConnectionCredentialsOptions.js.map +1 -1
- package/lib/typeorm/driver/aurora-mysql/AuroraMysqlConnectionOptions.js.map +1 -1
- package/lib/typeorm/driver/aurora-mysql/AuroraMysqlDriver.js +392 -399
- package/lib/typeorm/driver/aurora-mysql/AuroraMysqlDriver.js.map +1 -1
- package/lib/typeorm/driver/aurora-mysql/AuroraMysqlQueryRunner.js +1320 -2084
- package/lib/typeorm/driver/aurora-mysql/AuroraMysqlQueryRunner.js.map +1 -1
- package/lib/typeorm/driver/aurora-postgres/AuroraPostgresConnectionOptions.js.map +1 -1
- package/lib/typeorm/driver/aurora-postgres/AuroraPostgresDriver.js +50 -78
- package/lib/typeorm/driver/aurora-postgres/AuroraPostgresDriver.js.map +1 -1
- package/lib/typeorm/driver/aurora-postgres/AuroraPostgresQueryRunner.js +89 -160
- package/lib/typeorm/driver/aurora-postgres/AuroraPostgresQueryRunner.js.map +1 -1
- package/lib/typeorm/driver/better-sqlite3/BetterSqlite3ConnectionOptions.js.map +1 -1
- package/lib/typeorm/driver/better-sqlite3/BetterSqlite3Driver.js +78 -152
- package/lib/typeorm/driver/better-sqlite3/BetterSqlite3Driver.js.map +1 -1
- package/lib/typeorm/driver/better-sqlite3/BetterSqlite3QueryRunner.js +96 -155
- package/lib/typeorm/driver/better-sqlite3/BetterSqlite3QueryRunner.js.map +1 -1
- package/lib/typeorm/driver/capacitor/CapacitorConnectionOptions.js.map +1 -1
- package/lib/typeorm/driver/capacitor/CapacitorDriver.js +44 -89
- package/lib/typeorm/driver/capacitor/CapacitorDriver.js.map +1 -1
- package/lib/typeorm/driver/capacitor/CapacitorQueryRunner.js +70 -122
- package/lib/typeorm/driver/capacitor/CapacitorQueryRunner.js.map +1 -1
- package/lib/typeorm/driver/cockroachdb/CockroachConnectionCredentialsOptions.js.map +1 -1
- package/lib/typeorm/driver/cockroachdb/CockroachConnectionOptions.js.map +1 -1
- package/lib/typeorm/driver/cockroachdb/CockroachDriver.js +368 -404
- package/lib/typeorm/driver/cockroachdb/CockroachDriver.js.map +1 -1
- package/lib/typeorm/driver/cockroachdb/CockroachQueryRunner.js +1752 -2862
- package/lib/typeorm/driver/cockroachdb/CockroachQueryRunner.js.map +1 -1
- package/lib/typeorm/driver/cordova/CordovaConnectionOptions.js.map +1 -1
- package/lib/typeorm/driver/cordova/CordovaDriver.js +36 -58
- package/lib/typeorm/driver/cordova/CordovaDriver.js.map +1 -1
- package/lib/typeorm/driver/cordova/CordovaQueryRunner.js +86 -164
- package/lib/typeorm/driver/cordova/CordovaQueryRunner.js.map +1 -1
- package/lib/typeorm/driver/expo/ExpoConnectionOptions.js.map +1 -1
- package/lib/typeorm/driver/expo/ExpoDriver.js +34 -44
- package/lib/typeorm/driver/expo/ExpoDriver.js.map +1 -1
- package/lib/typeorm/driver/expo/ExpoQueryRunner.js +114 -204
- package/lib/typeorm/driver/expo/ExpoQueryRunner.js.map +1 -1
- package/lib/typeorm/driver/mongodb/MongoConnectionOptions.js.map +1 -1
- package/lib/typeorm/driver/mongodb/MongoDriver.js +269 -243
- package/lib/typeorm/driver/mongodb/MongoDriver.js.map +1 -1
- package/lib/typeorm/driver/mongodb/MongoQueryRunner.js +357 -793
- package/lib/typeorm/driver/mongodb/MongoQueryRunner.js.map +1 -1
- package/lib/typeorm/driver/mongodb/typings.js.map +1 -1
- package/lib/typeorm/driver/mysql/MysqlConnectionCredentialsOptions.js.map +1 -1
- package/lib/typeorm/driver/mysql/MysqlConnectionOptions.js.map +1 -1
- package/lib/typeorm/driver/mysql/MysqlDriver.js +475 -480
- package/lib/typeorm/driver/mysql/MysqlDriver.js.map +1 -1
- package/lib/typeorm/driver/mysql/MysqlQueryRunner.js +1692 -2466
- package/lib/typeorm/driver/mysql/MysqlQueryRunner.js.map +1 -1
- package/lib/typeorm/driver/nativescript/NativescriptConnectionOptions.js.map +1 -1
- package/lib/typeorm/driver/nativescript/NativescriptDriver.js +46 -50
- package/lib/typeorm/driver/nativescript/NativescriptDriver.js.map +1 -1
- package/lib/typeorm/driver/nativescript/NativescriptQueryRunner.js +62 -101
- package/lib/typeorm/driver/nativescript/NativescriptQueryRunner.js.map +1 -1
- package/lib/typeorm/driver/oracle/OracleConnectionCredentialsOptions.js.map +1 -1
- package/lib/typeorm/driver/oracle/OracleConnectionOptions.js.map +1 -1
- package/lib/typeorm/driver/oracle/OracleDriver.js +345 -377
- package/lib/typeorm/driver/oracle/OracleDriver.js.map +1 -1
- package/lib/typeorm/driver/oracle/OracleQueryRunner.js +1484 -2384
- package/lib/typeorm/driver/oracle/OracleQueryRunner.js.map +1 -1
- package/lib/typeorm/driver/postgres/PostgresConnectionCredentialsOptions.js.map +1 -1
- package/lib/typeorm/driver/postgres/PostgresConnectionOptions.js.map +1 -1
- package/lib/typeorm/driver/postgres/PostgresDriver.js +574 -690
- package/lib/typeorm/driver/postgres/PostgresDriver.js.map +1 -1
- package/lib/typeorm/driver/postgres/PostgresQueryRunner.js +2153 -3379
- package/lib/typeorm/driver/postgres/PostgresQueryRunner.js.map +1 -1
- package/lib/typeorm/driver/react-native/ReactNativeConnectionOptions.js.map +1 -1
- package/lib/typeorm/driver/react-native/ReactNativeDriver.js +34 -44
- package/lib/typeorm/driver/react-native/ReactNativeDriver.js.map +1 -1
- package/lib/typeorm/driver/react-native/ReactNativeQueryRunner.js +60 -94
- package/lib/typeorm/driver/react-native/ReactNativeQueryRunner.js.map +1 -1
- package/lib/typeorm/driver/sap/SapConnectionCredentialsOptions.js.map +1 -1
- package/lib/typeorm/driver/sap/SapConnectionOptions.js.map +1 -1
- package/lib/typeorm/driver/sap/SapDriver.js +310 -305
- package/lib/typeorm/driver/sap/SapDriver.js.map +1 -1
- package/lib/typeorm/driver/sap/SapQueryRunner.js +1635 -2561
- package/lib/typeorm/driver/sap/SapQueryRunner.js.map +1 -1
- package/lib/typeorm/driver/spanner/SpannerConnectionCredentialsOptions.js.map +1 -1
- package/lib/typeorm/driver/spanner/SpannerConnectionOptions.js.map +1 -1
- package/lib/typeorm/driver/spanner/SpannerDriver.js +250 -236
- package/lib/typeorm/driver/spanner/SpannerDriver.js.map +1 -1
- package/lib/typeorm/driver/spanner/SpannerQueryRunner.js +1136 -2168
- package/lib/typeorm/driver/spanner/SpannerQueryRunner.js.map +1 -1
- package/lib/typeorm/driver/sqlite/SqliteConnectionOptions.js.map +1 -1
- package/lib/typeorm/driver/sqlite/SqliteDriver.js +82 -169
- package/lib/typeorm/driver/sqlite/SqliteDriver.js.map +1 -1
- package/lib/typeorm/driver/sqlite/SqliteQueryRunner.js +78 -122
- package/lib/typeorm/driver/sqlite/SqliteQueryRunner.js.map +1 -1
- package/lib/typeorm/driver/sqlite-abstract/AbstractSqliteDriver.js +280 -268
- package/lib/typeorm/driver/sqlite-abstract/AbstractSqliteDriver.js.map +1 -1
- package/lib/typeorm/driver/sqlite-abstract/AbstractSqliteQueryRunner.js +1158 -1990
- package/lib/typeorm/driver/sqlite-abstract/AbstractSqliteQueryRunner.js.map +1 -1
- package/lib/typeorm/driver/sqljs/SqljsConnectionOptions.js.map +1 -1
- package/lib/typeorm/driver/sqljs/SqljsDriver.js +187 -253
- package/lib/typeorm/driver/sqljs/SqljsDriver.js.map +1 -1
- package/lib/typeorm/driver/sqljs/SqljsQueryRunner.js +88 -147
- package/lib/typeorm/driver/sqljs/SqljsQueryRunner.js.map +1 -1
- package/lib/typeorm/driver/sqlserver/MssqlParameter.js +10 -13
- package/lib/typeorm/driver/sqlserver/MssqlParameter.js.map +1 -1
- package/lib/typeorm/driver/sqlserver/SqlServerConnectionCredentialsOptions.js.map +1 -1
- package/lib/typeorm/driver/sqlserver/SqlServerConnectionOptions.js.map +1 -1
- package/lib/typeorm/driver/sqlserver/SqlServerDriver.js +352 -372
- package/lib/typeorm/driver/sqlserver/SqlServerDriver.js.map +1 -1
- package/lib/typeorm/driver/sqlserver/SqlServerQueryRunner.js +1979 -3068
- package/lib/typeorm/driver/sqlserver/SqlServerQueryRunner.js.map +1 -1
- package/lib/typeorm/driver/sqlserver/authentication/AzureActiveDirectoryAccessTokenAuthentication.js.map +1 -1
- package/lib/typeorm/driver/sqlserver/authentication/AzureActiveDirectoryMsiAppServiceAuthentication.js.map +1 -1
- package/lib/typeorm/driver/sqlserver/authentication/AzureActiveDirectoryMsiVmAuthentication.js.map +1 -1
- package/lib/typeorm/driver/sqlserver/authentication/AzureActiveDirectoryPasswordAuthentication.js.map +1 -1
- package/lib/typeorm/driver/sqlserver/authentication/AzureActiveDirectoryServicePrincipalSecret.js.map +1 -1
- package/lib/typeorm/driver/sqlserver/authentication/DefaultAuthentication.js.map +1 -1
- package/lib/typeorm/driver/sqlserver/authentication/NtlmAuthentication.js.map +1 -1
- package/lib/typeorm/driver/types/ColumnTypes.js.map +1 -1
- package/lib/typeorm/driver/types/CteCapabilities.js.map +1 -1
- package/lib/typeorm/driver/types/DataTypeDefaults.js.map +1 -1
- package/lib/typeorm/driver/types/DatabaseType.js.map +1 -1
- package/lib/typeorm/driver/types/IsolationLevel.js.map +1 -1
- package/lib/typeorm/driver/types/MappedColumnTypes.js.map +1 -1
- package/lib/typeorm/driver/types/MetadataTableType.js.map +1 -1
- package/lib/typeorm/driver/types/ReplicationMode.js.map +1 -1
- package/lib/typeorm/driver/types/UpsertType.js.map +1 -1
- package/lib/typeorm/entity-manager/EntityManager.js +351 -469
- package/lib/typeorm/entity-manager/EntityManager.js.map +1 -1
- package/lib/typeorm/entity-manager/EntityManagerFactory.js +7 -10
- package/lib/typeorm/entity-manager/EntityManagerFactory.js.map +1 -1
- package/lib/typeorm/entity-manager/MongoEntityManager.js +371 -487
- package/lib/typeorm/entity-manager/MongoEntityManager.js.map +1 -1
- package/lib/typeorm/entity-manager/SqljsEntityManager.js +16 -37
- package/lib/typeorm/entity-manager/SqljsEntityManager.js.map +1 -1
- package/lib/typeorm/entity-schema/EntitySchema.js +5 -5
- package/lib/typeorm/entity-schema/EntitySchema.js.map +1 -1
- package/lib/typeorm/entity-schema/EntitySchemaCheckOptions.js.map +1 -1
- package/lib/typeorm/entity-schema/EntitySchemaColumnOptions.js.map +1 -1
- package/lib/typeorm/entity-schema/EntitySchemaEmbeddedColumnOptions.js +17 -5
- package/lib/typeorm/entity-schema/EntitySchemaEmbeddedColumnOptions.js.map +1 -1
- package/lib/typeorm/entity-schema/EntitySchemaEmbeddedError.js +11 -14
- package/lib/typeorm/entity-schema/EntitySchemaEmbeddedError.js.map +1 -1
- package/lib/typeorm/entity-schema/EntitySchemaExclusionOptions.js.map +1 -1
- package/lib/typeorm/entity-schema/EntitySchemaIndexOptions.js.map +1 -1
- package/lib/typeorm/entity-schema/EntitySchemaOptions.js +82 -5
- package/lib/typeorm/entity-schema/EntitySchemaOptions.js.map +1 -1
- package/lib/typeorm/entity-schema/EntitySchemaRelationIdOptions.js.map +1 -1
- package/lib/typeorm/entity-schema/EntitySchemaRelationOptions.js.map +1 -1
- package/lib/typeorm/entity-schema/EntitySchemaTransformer.js +51 -68
- package/lib/typeorm/entity-schema/EntitySchemaTransformer.js.map +1 -1
- package/lib/typeorm/entity-schema/EntitySchemaUniqueOptions.js.map +1 -1
- package/lib/typeorm/error/AlreadyHasActiveConnectionError.js +6 -9
- package/lib/typeorm/error/AlreadyHasActiveConnectionError.js.map +1 -1
- package/lib/typeorm/error/CannotAttachTreeChildrenEntityError.js +6 -9
- package/lib/typeorm/error/CannotAttachTreeChildrenEntityError.js.map +1 -1
- package/lib/typeorm/error/CannotConnectAlreadyConnectedError.js +5 -8
- package/lib/typeorm/error/CannotConnectAlreadyConnectedError.js.map +1 -1
- package/lib/typeorm/error/CannotCreateEntityIdMapError.js +7 -11
- package/lib/typeorm/error/CannotCreateEntityIdMapError.js.map +1 -1
- package/lib/typeorm/error/CannotDetermineEntityError.js +6 -9
- package/lib/typeorm/error/CannotDetermineEntityError.js.map +1 -1
- package/lib/typeorm/error/CannotExecuteNotConnectedError.js +5 -8
- package/lib/typeorm/error/CannotExecuteNotConnectedError.js.map +1 -1
- package/lib/typeorm/error/CannotGetEntityManagerNotConnectedError.js +5 -8
- package/lib/typeorm/error/CannotGetEntityManagerNotConnectedError.js.map +1 -1
- package/lib/typeorm/error/CannotReflectMethodParameterTypeError.js +7 -10
- package/lib/typeorm/error/CannotReflectMethodParameterTypeError.js.map +1 -1
- package/lib/typeorm/error/CircularRelationsError.js +6 -9
- package/lib/typeorm/error/CircularRelationsError.js.map +1 -1
- package/lib/typeorm/error/ColumnTypeUndefinedError.js +8 -11
- package/lib/typeorm/error/ColumnTypeUndefinedError.js.map +1 -1
- package/lib/typeorm/error/ConnectionIsNotSetError.js +5 -8
- package/lib/typeorm/error/ConnectionIsNotSetError.js.map +1 -1
- package/lib/typeorm/error/ConnectionNotFoundError.js +5 -8
- package/lib/typeorm/error/ConnectionNotFoundError.js.map +1 -1
- package/lib/typeorm/error/CustomRepositoryCannotInheritRepositoryError.js +7 -10
- package/lib/typeorm/error/CustomRepositoryCannotInheritRepositoryError.js.map +1 -1
- package/lib/typeorm/error/CustomRepositoryDoesNotHaveEntityError.js +7 -10
- package/lib/typeorm/error/CustomRepositoryDoesNotHaveEntityError.js.map +1 -1
- package/lib/typeorm/error/CustomRepositoryNotFoundError.js +7 -10
- package/lib/typeorm/error/CustomRepositoryNotFoundError.js.map +1 -1
- package/lib/typeorm/error/DataTypeNotSupportedError.js +7 -11
- package/lib/typeorm/error/DataTypeNotSupportedError.js.map +1 -1
- package/lib/typeorm/error/DriverOptionNotSetError.js +6 -9
- package/lib/typeorm/error/DriverOptionNotSetError.js.map +1 -1
- package/lib/typeorm/error/DriverPackageNotInstalledError.js +6 -9
- package/lib/typeorm/error/DriverPackageNotInstalledError.js.map +1 -1
- package/lib/typeorm/error/EntityMetadataNotFoundError.js +10 -14
- package/lib/typeorm/error/EntityMetadataNotFoundError.js.map +1 -1
- package/lib/typeorm/error/EntityNotFoundError.js +13 -17
- package/lib/typeorm/error/EntityNotFoundError.js.map +1 -1
- package/lib/typeorm/error/EntityPropertyNotFoundError.js +7 -11
- package/lib/typeorm/error/EntityPropertyNotFoundError.js.map +1 -1
- package/lib/typeorm/error/FindRelationsNotFoundError.js +9 -13
- package/lib/typeorm/error/FindRelationsNotFoundError.js.map +1 -1
- package/lib/typeorm/error/ForbiddenTransactionModeOverrideError.js +6 -9
- package/lib/typeorm/error/ForbiddenTransactionModeOverrideError.js.map +1 -1
- package/lib/typeorm/error/InitializedRelationError.js +7 -10
- package/lib/typeorm/error/InitializedRelationError.js.map +1 -1
- package/lib/typeorm/error/InsertValuesMissingError.js +6 -9
- package/lib/typeorm/error/InsertValuesMissingError.js.map +1 -1
- package/lib/typeorm/error/LimitOnUpdateNotSupportedError.js +5 -8
- package/lib/typeorm/error/LimitOnUpdateNotSupportedError.js.map +1 -1
- package/lib/typeorm/error/LockNotSupportedOnGivenDriverError.js +5 -8
- package/lib/typeorm/error/LockNotSupportedOnGivenDriverError.js.map +1 -1
- package/lib/typeorm/error/MetadataAlreadyExistsError.js +6 -9
- package/lib/typeorm/error/MetadataAlreadyExistsError.js.map +1 -1
- package/lib/typeorm/error/MetadataWithSuchNameAlreadyExistsError.js +6 -9
- package/lib/typeorm/error/MetadataWithSuchNameAlreadyExistsError.js.map +1 -1
- package/lib/typeorm/error/MissingDeleteDateColumnError.js +5 -8
- package/lib/typeorm/error/MissingDeleteDateColumnError.js.map +1 -1
- package/lib/typeorm/error/MissingDriverError.js +6 -10
- package/lib/typeorm/error/MissingDriverError.js.map +1 -1
- package/lib/typeorm/error/MissingJoinColumnError.js +12 -16
- package/lib/typeorm/error/MissingJoinColumnError.js.map +1 -1
- package/lib/typeorm/error/MissingJoinTableError.js +12 -16
- package/lib/typeorm/error/MissingJoinTableError.js.map +1 -1
- package/lib/typeorm/error/MissingPrimaryColumnError.js +6 -9
- package/lib/typeorm/error/MissingPrimaryColumnError.js.map +1 -1
- package/lib/typeorm/error/MustBeEntityError.js +5 -8
- package/lib/typeorm/error/MustBeEntityError.js.map +1 -1
- package/lib/typeorm/error/NamingStrategyNotFoundError.js +9 -13
- package/lib/typeorm/error/NamingStrategyNotFoundError.js.map +1 -1
- package/lib/typeorm/error/NestedSetMultipleRootError.js +5 -8
- package/lib/typeorm/error/NestedSetMultipleRootError.js.map +1 -1
- package/lib/typeorm/error/NoConnectionForRepositoryError.js +6 -9
- package/lib/typeorm/error/NoConnectionForRepositoryError.js.map +1 -1
- package/lib/typeorm/error/NoConnectionOptionError.js +6 -9
- package/lib/typeorm/error/NoConnectionOptionError.js.map +1 -1
- package/lib/typeorm/error/NoNeedToReleaseEntityManagerError.js +7 -10
- package/lib/typeorm/error/NoNeedToReleaseEntityManagerError.js.map +1 -1
- package/lib/typeorm/error/NoVersionOrUpdateDateColumnError.js +5 -8
- package/lib/typeorm/error/NoVersionOrUpdateDateColumnError.js.map +1 -1
- package/lib/typeorm/error/OffsetWithoutLimitNotSupportedError.js +7 -10
- package/lib/typeorm/error/OffsetWithoutLimitNotSupportedError.js.map +1 -1
- package/lib/typeorm/error/OptimisticLockCanNotBeUsedError.js +5 -8
- package/lib/typeorm/error/OptimisticLockCanNotBeUsedError.js.map +1 -1
- package/lib/typeorm/error/OptimisticLockVersionMismatchError.js +5 -8
- package/lib/typeorm/error/OptimisticLockVersionMismatchError.js.map +1 -1
- package/lib/typeorm/error/PersistedEntityNotFoundError.js +5 -8
- package/lib/typeorm/error/PersistedEntityNotFoundError.js.map +1 -1
- package/lib/typeorm/error/PessimisticLockTransactionRequiredError.js +5 -8
- package/lib/typeorm/error/PessimisticLockTransactionRequiredError.js.map +1 -1
- package/lib/typeorm/error/PrimaryColumnCannotBeNullableError.js +6 -9
- package/lib/typeorm/error/PrimaryColumnCannotBeNullableError.js.map +1 -1
- package/lib/typeorm/error/QueryFailedError.js +18 -17
- package/lib/typeorm/error/QueryFailedError.js.map +1 -1
- package/lib/typeorm/error/QueryRunnerAlreadyReleasedError.js +5 -8
- package/lib/typeorm/error/QueryRunnerAlreadyReleasedError.js.map +1 -1
- package/lib/typeorm/error/QueryRunnerProviderAlreadyReleasedError.js +6 -9
- package/lib/typeorm/error/QueryRunnerProviderAlreadyReleasedError.js.map +1 -1
- package/lib/typeorm/error/RepositoryNotTreeError.js +9 -13
- package/lib/typeorm/error/RepositoryNotTreeError.js.map +1 -1
- package/lib/typeorm/error/ReturningStatementNotSupportedError.js +5 -8
- package/lib/typeorm/error/ReturningStatementNotSupportedError.js.map +1 -1
- package/lib/typeorm/error/SubjectRemovedAndUpdatedError.js +6 -9
- package/lib/typeorm/error/SubjectRemovedAndUpdatedError.js.map +1 -1
- package/lib/typeorm/error/SubjectWithoutIdentifierError.js +5 -8
- package/lib/typeorm/error/SubjectWithoutIdentifierError.js.map +1 -1
- package/lib/typeorm/error/TransactionAlreadyStartedError.js +5 -8
- package/lib/typeorm/error/TransactionAlreadyStartedError.js.map +1 -1
- package/lib/typeorm/error/TransactionNotStartedError.js +5 -8
- package/lib/typeorm/error/TransactionNotStartedError.js.map +1 -1
- package/lib/typeorm/error/TreeRepositoryNotSupportedError.js +5 -8
- package/lib/typeorm/error/TreeRepositoryNotSupportedError.js.map +1 -1
- package/lib/typeorm/error/TypeORMError.js +9 -18
- package/lib/typeorm/error/TypeORMError.js.map +1 -1
- package/lib/typeorm/error/UpdateValuesMissingError.js +5 -8
- package/lib/typeorm/error/UpdateValuesMissingError.js.map +1 -1
- package/lib/typeorm/error/UsingJoinColumnIsNotAllowedError.js +6 -9
- package/lib/typeorm/error/UsingJoinColumnIsNotAllowedError.js.map +1 -1
- package/lib/typeorm/error/UsingJoinColumnOnlyOnOneSideAllowedError.js +7 -10
- package/lib/typeorm/error/UsingJoinColumnOnlyOnOneSideAllowedError.js.map +1 -1
- package/lib/typeorm/error/UsingJoinTableIsNotAllowedError.js +7 -10
- package/lib/typeorm/error/UsingJoinTableIsNotAllowedError.js.map +1 -1
- package/lib/typeorm/error/UsingJoinTableOnlyOnOneSideAllowedError.js +7 -10
- package/lib/typeorm/error/UsingJoinTableOnlyOnOneSideAllowedError.js.map +1 -1
- package/lib/typeorm/error/index.js +75 -62
- package/lib/typeorm/error/index.js.map +1 -1
- package/lib/typeorm/find-options/EqualOperator.js +6 -10
- package/lib/typeorm/find-options/EqualOperator.js.map +1 -1
- package/lib/typeorm/find-options/FindManyOptions.js.map +1 -1
- package/lib/typeorm/find-options/FindOneOptions.js.map +1 -1
- package/lib/typeorm/find-options/FindOperator.js +90 -94
- package/lib/typeorm/find-options/FindOperator.js.map +1 -1
- package/lib/typeorm/find-options/FindOperatorType.js.map +1 -1
- package/lib/typeorm/find-options/FindOptionsOrder.js.map +1 -1
- package/lib/typeorm/find-options/FindOptionsRelations.js.map +1 -1
- package/lib/typeorm/find-options/FindOptionsSelect.js.map +1 -1
- package/lib/typeorm/find-options/FindOptionsUtils.js +56 -87
- package/lib/typeorm/find-options/FindOptionsUtils.js.map +1 -1
- package/lib/typeorm/find-options/FindOptionsWhere.js.map +1 -1
- package/lib/typeorm/find-options/FindTreeOptions.js.map +1 -1
- package/lib/typeorm/find-options/JoinOptions.js.map +1 -1
- package/lib/typeorm/find-options/OrderByCondition.js.map +1 -1
- package/lib/typeorm/find-options/mongodb/MongoFindManyOptions.js.map +1 -1
- package/lib/typeorm/find-options/mongodb/MongoFindOneOptions.js.map +1 -1
- package/lib/typeorm/find-options/operator/And.js +2 -6
- package/lib/typeorm/find-options/operator/And.js.map +1 -1
- package/lib/typeorm/find-options/operator/Any.js +1 -1
- package/lib/typeorm/find-options/operator/Any.js.map +1 -1
- package/lib/typeorm/find-options/operator/ArrayContainedBy.js +1 -1
- package/lib/typeorm/find-options/operator/ArrayContainedBy.js.map +1 -1
- package/lib/typeorm/find-options/operator/ArrayContains.js +1 -1
- package/lib/typeorm/find-options/operator/ArrayContains.js.map +1 -1
- package/lib/typeorm/find-options/operator/ArrayOverlap.js +1 -1
- package/lib/typeorm/find-options/operator/ArrayOverlap.js.map +1 -1
- package/lib/typeorm/find-options/operator/Between.js +1 -1
- package/lib/typeorm/find-options/operator/Between.js.map +1 -1
- package/lib/typeorm/find-options/operator/Equal.js +1 -1
- package/lib/typeorm/find-options/operator/Equal.js.map +1 -1
- package/lib/typeorm/find-options/operator/ILike.js +1 -1
- package/lib/typeorm/find-options/operator/ILike.js.map +1 -1
- package/lib/typeorm/find-options/operator/In.js +1 -1
- package/lib/typeorm/find-options/operator/In.js.map +1 -1
- package/lib/typeorm/find-options/operator/IsNull.js +1 -1
- package/lib/typeorm/find-options/operator/IsNull.js.map +1 -1
- package/lib/typeorm/find-options/operator/LessThan.js +1 -1
- package/lib/typeorm/find-options/operator/LessThan.js.map +1 -1
- package/lib/typeorm/find-options/operator/LessThanOrEqual.js +1 -1
- package/lib/typeorm/find-options/operator/LessThanOrEqual.js.map +1 -1
- package/lib/typeorm/find-options/operator/Like.js +1 -1
- package/lib/typeorm/find-options/operator/Like.js.map +1 -1
- package/lib/typeorm/find-options/operator/MoreThan.js +1 -1
- package/lib/typeorm/find-options/operator/MoreThan.js.map +1 -1
- package/lib/typeorm/find-options/operator/MoreThanOrEqual.js +1 -1
- package/lib/typeorm/find-options/operator/MoreThanOrEqual.js.map +1 -1
- package/lib/typeorm/find-options/operator/Not.js +1 -1
- package/lib/typeorm/find-options/operator/Not.js.map +1 -1
- package/lib/typeorm/find-options/operator/Raw.js +1 -1
- package/lib/typeorm/find-options/operator/Raw.js.map +1 -1
- package/lib/typeorm/globals.js +33 -99
- package/lib/typeorm/globals.js.map +1 -1
- package/lib/typeorm/index.d.ts +0 -1
- package/lib/typeorm/index.js +136 -126
- package/lib/typeorm/index.js.map +1 -1
- package/lib/typeorm/logger/AdvancedConsoleLogger.js +26 -26
- package/lib/typeorm/logger/AdvancedConsoleLogger.js.map +1 -1
- package/lib/typeorm/logger/DebugLogger.js +24 -27
- package/lib/typeorm/logger/DebugLogger.js.map +1 -1
- package/lib/typeorm/logger/FileLogger.js +31 -30
- package/lib/typeorm/logger/FileLogger.js.map +1 -1
- package/lib/typeorm/logger/Logger.js.map +1 -1
- package/lib/typeorm/logger/LoggerFactory.js +9 -12
- package/lib/typeorm/logger/LoggerFactory.js.map +1 -1
- package/lib/typeorm/logger/LoggerOptions.js.map +1 -1
- package/lib/typeorm/logger/SimpleConsoleLogger.js +25 -25
- package/lib/typeorm/logger/SimpleConsoleLogger.js.map +1 -1
- package/lib/typeorm/metadata/CheckMetadata.js +30 -6
- package/lib/typeorm/metadata/CheckMetadata.js.map +1 -1
- package/lib/typeorm/metadata/ColumnMetadata.js +343 -199
- package/lib/typeorm/metadata/ColumnMetadata.js.map +1 -1
- package/lib/typeorm/metadata/EmbeddedMetadata.js +174 -153
- package/lib/typeorm/metadata/EmbeddedMetadata.js.map +1 -1
- package/lib/typeorm/metadata/EntityListenerMetadata.js +35 -15
- package/lib/typeorm/metadata/EntityListenerMetadata.js.map +1 -1
- package/lib/typeorm/metadata/EntityMetadata.js +516 -372
- package/lib/typeorm/metadata/EntityMetadata.js.map +1 -1
- package/lib/typeorm/metadata/ExclusionMetadata.js +30 -6
- package/lib/typeorm/metadata/ExclusionMetadata.js.map +1 -1
- package/lib/typeorm/metadata/ForeignKeyMetadata.js +60 -24
- package/lib/typeorm/metadata/ForeignKeyMetadata.js.map +1 -1
- package/lib/typeorm/metadata/IndexMetadata.js +119 -73
- package/lib/typeorm/metadata/IndexMetadata.js.map +1 -1
- package/lib/typeorm/metadata/RelationCountMetadata.js +40 -10
- package/lib/typeorm/metadata/RelationCountMetadata.js.map +1 -1
- package/lib/typeorm/metadata/RelationIdMetadata.js +47 -18
- package/lib/typeorm/metadata/RelationIdMetadata.js.map +1 -1
- package/lib/typeorm/metadata/RelationMetadata.js +270 -187
- package/lib/typeorm/metadata/RelationMetadata.js.map +1 -1
- package/lib/typeorm/metadata/UniqueMetadata.js +72 -47
- package/lib/typeorm/metadata/UniqueMetadata.js.map +1 -1
- package/lib/typeorm/metadata/types/ClosureTreeOptions.js.map +1 -1
- package/lib/typeorm/metadata/types/DeferrableType.js.map +1 -1
- package/lib/typeorm/metadata/types/EventListenerTypes.js +13 -16
- package/lib/typeorm/metadata/types/EventListenerTypes.js.map +1 -1
- package/lib/typeorm/metadata/types/OnDeleteType.js.map +1 -1
- package/lib/typeorm/metadata/types/OnUpdateType.js.map +1 -1
- package/lib/typeorm/metadata/types/PropertyTypeInFunction.js.map +1 -1
- package/lib/typeorm/metadata/types/RelationTypeInFunction.js.map +1 -1
- package/lib/typeorm/metadata/types/RelationTypes.js.map +1 -1
- package/lib/typeorm/metadata/types/TableTypes.js.map +1 -1
- package/lib/typeorm/metadata/types/TreeTypes.js.map +1 -1
- package/lib/typeorm/metadata-args/CheckMetadataArgs.js.map +1 -1
- package/lib/typeorm/metadata-args/ColumnMetadataArgs.js.map +1 -1
- package/lib/typeorm/metadata-args/DiscriminatorValueMetadataArgs.js.map +1 -1
- package/lib/typeorm/metadata-args/EmbeddedMetadataArgs.js.map +1 -1
- package/lib/typeorm/metadata-args/EntityListenerMetadataArgs.js.map +1 -1
- package/lib/typeorm/metadata-args/EntityRepositoryMetadataArgs.js.map +1 -1
- package/lib/typeorm/metadata-args/EntitySubscriberMetadataArgs.js.map +1 -1
- package/lib/typeorm/metadata-args/ExclusionMetadataArgs.js.map +1 -1
- package/lib/typeorm/metadata-args/GeneratedMetadataArgs.js.map +1 -1
- package/lib/typeorm/metadata-args/IndexMetadataArgs.js.map +1 -1
- package/lib/typeorm/metadata-args/InheritanceMetadataArgs.js.map +1 -1
- package/lib/typeorm/metadata-args/JoinColumnMetadataArgs.js.map +1 -1
- package/lib/typeorm/metadata-args/JoinTableMetadataArgs.js.map +1 -1
- package/lib/typeorm/metadata-args/MetadataArgsStorage.js +108 -113
- package/lib/typeorm/metadata-args/MetadataArgsStorage.js.map +1 -1
- package/lib/typeorm/metadata-args/NamingStrategyMetadataArgs.js.map +1 -1
- package/lib/typeorm/metadata-args/RelationCountMetadataArgs.js.map +1 -1
- package/lib/typeorm/metadata-args/RelationIdMetadataArgs.js.map +1 -1
- package/lib/typeorm/metadata-args/RelationMetadataArgs.js.map +1 -1
- package/lib/typeorm/metadata-args/TableMetadataArgs.js.map +1 -1
- package/lib/typeorm/metadata-args/TransactionEntityMetadataArgs.js.map +1 -1
- package/lib/typeorm/metadata-args/TransactionRepositoryMetadataArgs.js.map +1 -1
- package/lib/typeorm/metadata-args/TreeMetadataArgs.js.map +1 -1
- package/lib/typeorm/metadata-args/UniqueMetadataArgs.js.map +1 -1
- package/lib/typeorm/metadata-args/types/ColumnMode.js.map +1 -1
- package/lib/typeorm/metadata-builder/ClosureJunctionEntityMetadataBuilder.js +14 -15
- package/lib/typeorm/metadata-builder/ClosureJunctionEntityMetadataBuilder.js.map +1 -1
- package/lib/typeorm/metadata-builder/EntityMetadataBuilder.js +291 -347
- package/lib/typeorm/metadata-builder/EntityMetadataBuilder.js.map +1 -1
- package/lib/typeorm/metadata-builder/EntityMetadataValidator.js +63 -77
- package/lib/typeorm/metadata-builder/EntityMetadataValidator.js.map +1 -1
- package/lib/typeorm/metadata-builder/JunctionEntityMetadataBuilder.js +64 -69
- package/lib/typeorm/metadata-builder/JunctionEntityMetadataBuilder.js.map +1 -1
- package/lib/typeorm/metadata-builder/MetadataUtils.js +12 -15
- package/lib/typeorm/metadata-builder/MetadataUtils.js.map +1 -1
- package/lib/typeorm/metadata-builder/RelationJoinColumnBuilder.js +43 -49
- package/lib/typeorm/metadata-builder/RelationJoinColumnBuilder.js.map +1 -1
- package/lib/typeorm/migration/Migration.js +23 -4
- package/lib/typeorm/migration/Migration.js.map +1 -1
- package/lib/typeorm/migration/MigrationExecutor.js +432 -691
- package/lib/typeorm/migration/MigrationExecutor.js.map +1 -1
- package/lib/typeorm/migration/MigrationInterface.js.map +1 -1
- package/lib/typeorm/naming-strategy/DefaultNamingStrategy.js +80 -84
- package/lib/typeorm/naming-strategy/DefaultNamingStrategy.js.map +1 -1
- package/lib/typeorm/naming-strategy/NamingStrategyInterface.js.map +1 -1
- package/lib/typeorm/persistence/EntityPersistExecutor.js +154 -212
- package/lib/typeorm/persistence/EntityPersistExecutor.js.map +1 -1
- package/lib/typeorm/persistence/Subject.js +162 -149
- package/lib/typeorm/persistence/Subject.js.map +1 -1
- package/lib/typeorm/persistence/SubjectChangeMap.js.map +1 -1
- package/lib/typeorm/persistence/SubjectChangedColumnsComputer.js +29 -35
- package/lib/typeorm/persistence/SubjectChangedColumnsComputer.js.map +1 -1
- package/lib/typeorm/persistence/SubjectDatabaseEntityLoader.js +99 -130
- package/lib/typeorm/persistence/SubjectDatabaseEntityLoader.js.map +1 -1
- package/lib/typeorm/persistence/SubjectExecutor.js +635 -879
- package/lib/typeorm/persistence/SubjectExecutor.js.map +1 -1
- package/lib/typeorm/persistence/SubjectTopoligicalSorter.js +62 -58
- package/lib/typeorm/persistence/SubjectTopoligicalSorter.js.map +1 -1
- package/lib/typeorm/persistence/subject-builder/CascadesSubjectBuilder.js +16 -19
- package/lib/typeorm/persistence/subject-builder/CascadesSubjectBuilder.js.map +1 -1
- package/lib/typeorm/persistence/subject-builder/ManyToManySubjectBuilder.js +50 -53
- package/lib/typeorm/persistence/subject-builder/ManyToManySubjectBuilder.js.map +1 -1
- package/lib/typeorm/persistence/subject-builder/OneToManySubjectBuilder.js +28 -33
- package/lib/typeorm/persistence/subject-builder/OneToManySubjectBuilder.js.map +1 -1
- package/lib/typeorm/persistence/subject-builder/OneToOneInverseSideSubjectBuilder.js +19 -20
- package/lib/typeorm/persistence/subject-builder/OneToOneInverseSideSubjectBuilder.js.map +1 -1
- package/lib/typeorm/persistence/tree/ClosureSubjectExecutor.js +202 -271
- package/lib/typeorm/persistence/tree/ClosureSubjectExecutor.js.map +1 -1
- package/lib/typeorm/persistence/tree/MaterializedPathSubjectExecutor.js +79 -121
- package/lib/typeorm/persistence/tree/MaterializedPathSubjectExecutor.js.map +1 -1
- package/lib/typeorm/persistence/tree/NestedSetSubjectExecutor.js +220 -353
- package/lib/typeorm/persistence/tree/NestedSetSubjectExecutor.js.map +1 -1
- package/lib/typeorm/platform/PlatformTools.js +66 -78
- package/lib/typeorm/platform/PlatformTools.js.map +1 -1
- package/lib/typeorm/query-builder/Alias.js +31 -32
- package/lib/typeorm/query-builder/Alias.js.map +1 -1
- package/lib/typeorm/query-builder/Brackets.js +8 -5
- package/lib/typeorm/query-builder/Brackets.js.map +1 -1
- package/lib/typeorm/query-builder/DeleteQueryBuilder.js +96 -120
- package/lib/typeorm/query-builder/DeleteQueryBuilder.js.map +1 -1
- package/lib/typeorm/query-builder/InsertOrUpdateOptions.js.map +1 -1
- package/lib/typeorm/query-builder/InsertQueryBuilder.js +321 -367
- package/lib/typeorm/query-builder/InsertQueryBuilder.js.map +1 -1
- package/lib/typeorm/query-builder/JoinAttribute.js +175 -206
- package/lib/typeorm/query-builder/JoinAttribute.js.map +1 -1
- package/lib/typeorm/query-builder/JoinOptions.js.map +1 -1
- package/lib/typeorm/query-builder/NotBrackets.js +4 -11
- package/lib/typeorm/query-builder/NotBrackets.js.map +1 -1
- package/lib/typeorm/query-builder/QueryBuilder.js +400 -646
- package/lib/typeorm/query-builder/QueryBuilder.js.map +1 -1
- package/lib/typeorm/query-builder/QueryBuilderCte.js.map +1 -1
- package/lib/typeorm/query-builder/QueryBuilderUtils.js +5 -9
- package/lib/typeorm/query-builder/QueryBuilderUtils.js.map +1 -1
- package/lib/typeorm/query-builder/QueryExpressionMap.js +304 -233
- package/lib/typeorm/query-builder/QueryExpressionMap.js.map +1 -1
- package/lib/typeorm/query-builder/QueryPartialEntity.js.map +1 -1
- package/lib/typeorm/query-builder/RelationIdLoader.js +166 -189
- package/lib/typeorm/query-builder/RelationIdLoader.js.map +1 -1
- package/lib/typeorm/query-builder/RelationLoader.js +81 -94
- package/lib/typeorm/query-builder/RelationLoader.js.map +1 -1
- package/lib/typeorm/query-builder/RelationQueryBuilder.js +91 -127
- package/lib/typeorm/query-builder/RelationQueryBuilder.js.map +1 -1
- package/lib/typeorm/query-builder/RelationRemover.js +121 -124
- package/lib/typeorm/query-builder/RelationRemover.js.map +1 -1
- package/lib/typeorm/query-builder/RelationUpdater.js +130 -148
- package/lib/typeorm/query-builder/RelationUpdater.js.map +1 -1
- package/lib/typeorm/query-builder/ReturningResultsEntityUpdator.js +131 -159
- package/lib/typeorm/query-builder/ReturningResultsEntityUpdator.js.map +1 -1
- package/lib/typeorm/query-builder/SelectQuery.js.map +1 -1
- package/lib/typeorm/query-builder/SelectQueryBuilder.js +955 -1211
- package/lib/typeorm/query-builder/SelectQueryBuilder.js.map +1 -1
- package/lib/typeorm/query-builder/SelectQueryBuilderOption.js.map +1 -1
- package/lib/typeorm/query-builder/SoftDeleteQueryBuilder.js +155 -194
- package/lib/typeorm/query-builder/SoftDeleteQueryBuilder.js.map +1 -1
- package/lib/typeorm/query-builder/UpdateQueryBuilder.js +204 -246
- package/lib/typeorm/query-builder/UpdateQueryBuilder.js.map +1 -1
- package/lib/typeorm/query-builder/WhereClause.js.map +1 -1
- package/lib/typeorm/query-builder/WhereExpressionBuilder.js.map +1 -1
- package/lib/typeorm/query-builder/relation-count/RelationCountAttribute.js +85 -98
- package/lib/typeorm/query-builder/relation-count/RelationCountAttribute.js.map +1 -1
- package/lib/typeorm/query-builder/relation-count/RelationCountLoadResult.js.map +1 -1
- package/lib/typeorm/query-builder/relation-count/RelationCountLoader.js +153 -172
- package/lib/typeorm/query-builder/relation-count/RelationCountLoader.js.map +1 -1
- package/lib/typeorm/query-builder/relation-count/RelationCountMetadataToAttributeTransformer.js +16 -17
- package/lib/typeorm/query-builder/relation-count/RelationCountMetadataToAttributeTransformer.js.map +1 -1
- package/lib/typeorm/query-builder/relation-id/RelationIdAttribute.js +93 -107
- package/lib/typeorm/query-builder/relation-id/RelationIdAttribute.js.map +1 -1
- package/lib/typeorm/query-builder/relation-id/RelationIdLoadResult.js.map +1 -1
- package/lib/typeorm/query-builder/relation-id/RelationIdLoader.js +259 -267
- package/lib/typeorm/query-builder/relation-id/RelationIdLoader.js.map +1 -1
- package/lib/typeorm/query-builder/relation-id/RelationIdMetadataToAttributeTransformer.js +16 -17
- package/lib/typeorm/query-builder/relation-id/RelationIdMetadataToAttributeTransformer.js.map +1 -1
- package/lib/typeorm/query-builder/result/DeleteResult.js +14 -8
- package/lib/typeorm/query-builder/result/DeleteResult.js.map +1 -1
- package/lib/typeorm/query-builder/result/InsertResult.js +19 -18
- package/lib/typeorm/query-builder/result/InsertResult.js.map +1 -1
- package/lib/typeorm/query-builder/result/UpdateResult.js +24 -18
- package/lib/typeorm/query-builder/result/UpdateResult.js.map +1 -1
- package/lib/typeorm/query-builder/transformer/DocumentToEntityTransformer.js +24 -26
- package/lib/typeorm/query-builder/transformer/DocumentToEntityTransformer.js.map +1 -1
- package/lib/typeorm/query-builder/transformer/PlainObjectToDatabaseEntityTransformer.js +77 -112
- package/lib/typeorm/query-builder/transformer/PlainObjectToDatabaseEntityTransformer.js.map +1 -1
- package/lib/typeorm/query-builder/transformer/PlainObjectToNewEntityTransformer.js +16 -22
- package/lib/typeorm/query-builder/transformer/PlainObjectToNewEntityTransformer.js.map +1 -1
- package/lib/typeorm/query-builder/transformer/RawSqlResultsToEntityTransformer.js +117 -132
- package/lib/typeorm/query-builder/transformer/RawSqlResultsToEntityTransformer.js.map +1 -1
- package/lib/typeorm/query-runner/BaseQueryRunner.js +227 -393
- package/lib/typeorm/query-runner/BaseQueryRunner.js.map +1 -1
- package/lib/typeorm/query-runner/QueryLock.js +19 -32
- package/lib/typeorm/query-runner/QueryLock.js.map +1 -1
- package/lib/typeorm/query-runner/QueryResult.js +14 -9
- package/lib/typeorm/query-runner/QueryResult.js.map +1 -1
- package/lib/typeorm/query-runner/QueryRunner.js.map +1 -1
- package/lib/typeorm/repository/AbstractRepository.js +46 -50
- package/lib/typeorm/repository/AbstractRepository.js.map +1 -1
- package/lib/typeorm/repository/BaseEntity.js +106 -123
- package/lib/typeorm/repository/BaseEntity.js.map +1 -1
- package/lib/typeorm/repository/EntityId.js.map +1 -1
- package/lib/typeorm/repository/FindTreesOptions.js.map +1 -1
- package/lib/typeorm/repository/MongoRepository.js +109 -135
- package/lib/typeorm/repository/MongoRepository.js.map +1 -1
- package/lib/typeorm/repository/RemoveOptions.js.map +1 -1
- package/lib/typeorm/repository/Repository.js +108 -140
- package/lib/typeorm/repository/Repository.js.map +1 -1
- package/lib/typeorm/repository/SaveOptions.js.map +1 -1
- package/lib/typeorm/repository/TreeRepository.js +107 -154
- package/lib/typeorm/repository/TreeRepository.js.map +1 -1
- package/lib/typeorm/repository/UpsertOptions.js.map +1 -1
- package/lib/typeorm/schema-builder/MongoSchemaBuilder.js +30 -42
- package/lib/typeorm/schema-builder/MongoSchemaBuilder.js.map +1 -1
- package/lib/typeorm/schema-builder/RdbmsSchemaBuilder.js +727 -1938
- package/lib/typeorm/schema-builder/RdbmsSchemaBuilder.js.map +1 -1
- package/lib/typeorm/schema-builder/SchemaBuilder.js.map +1 -1
- package/lib/typeorm/schema-builder/options/TableCheckOptions.js.map +1 -1
- package/lib/typeorm/schema-builder/options/TableColumnOptions.js.map +1 -1
- package/lib/typeorm/schema-builder/options/TableExclusionOptions.js.map +1 -1
- package/lib/typeorm/schema-builder/options/TableForeignKeyOptions.js.map +1 -1
- package/lib/typeorm/schema-builder/options/TableIndexOptions.js.map +1 -1
- package/lib/typeorm/schema-builder/options/TableOptions.js.map +1 -1
- package/lib/typeorm/schema-builder/options/TableUniqueOptions.js.map +1 -1
- package/lib/typeorm/schema-builder/options/ViewOptions.js.map +1 -1
- package/lib/typeorm/schema-builder/table/Table.js +160 -157
- package/lib/typeorm/schema-builder/table/Table.js.map +1 -1
- package/lib/typeorm/schema-builder/table/TableCheck.js +24 -15
- package/lib/typeorm/schema-builder/table/TableCheck.js.map +1 -1
- package/lib/typeorm/schema-builder/table/TableColumn.js +123 -41
- package/lib/typeorm/schema-builder/table/TableColumn.js.map +1 -1
- package/lib/typeorm/schema-builder/table/TableExclusion.js +19 -9
- package/lib/typeorm/schema-builder/table/TableExclusion.js.map +1 -1
- package/lib/typeorm/schema-builder/table/TableForeignKey.js +52 -20
- package/lib/typeorm/schema-builder/table/TableForeignKey.js.map +1 -1
- package/lib/typeorm/schema-builder/table/TableIndex.js +52 -16
- package/lib/typeorm/schema-builder/table/TableIndex.js.map +1 -1
- package/lib/typeorm/schema-builder/table/TableUnique.js +26 -16
- package/lib/typeorm/schema-builder/table/TableUnique.js.map +1 -1
- package/lib/typeorm/schema-builder/util/TableUtils.js +5 -8
- package/lib/typeorm/schema-builder/util/TableUtils.js.map +1 -1
- package/lib/typeorm/schema-builder/util/ViewUtils.js +4 -7
- package/lib/typeorm/schema-builder/util/ViewUtils.js.map +1 -1
- package/lib/typeorm/schema-builder/view/View.js +32 -10
- package/lib/typeorm/schema-builder/view/View.js.map +1 -1
- package/lib/typeorm/subscriber/Broadcaster.js +180 -216
- package/lib/typeorm/subscriber/Broadcaster.js.map +1 -1
- package/lib/typeorm/subscriber/BroadcasterResult.js +16 -29
- package/lib/typeorm/subscriber/BroadcasterResult.js.map +1 -1
- package/lib/typeorm/subscriber/EntitySubscriberInterface.js.map +1 -1
- package/lib/typeorm/subscriber/event/InsertEvent.js.map +1 -1
- package/lib/typeorm/subscriber/event/LoadEvent.js.map +1 -1
- package/lib/typeorm/subscriber/event/RecoverEvent.js.map +1 -1
- package/lib/typeorm/subscriber/event/RemoveEvent.js.map +1 -1
- package/lib/typeorm/subscriber/event/SoftRemoveEvent.js.map +1 -1
- package/lib/typeorm/subscriber/event/TransactionCommitEvent.js.map +1 -1
- package/lib/typeorm/subscriber/event/TransactionRollbackEvent.js.map +1 -1
- package/lib/typeorm/subscriber/event/TransactionStartEvent.js.map +1 -1
- package/lib/typeorm/subscriber/event/UpdateEvent.js.map +1 -1
- package/lib/typeorm/util/ApplyValueTransformers.js +9 -12
- package/lib/typeorm/util/ApplyValueTransformers.js.map +1 -1
- package/lib/typeorm/util/DateUtils.js +44 -53
- package/lib/typeorm/util/DateUtils.js.map +1 -1
- package/lib/typeorm/util/DepGraph.js +50 -53
- package/lib/typeorm/util/DepGraph.js.map +1 -1
- package/lib/typeorm/util/DirectoryExportedClassesLoader.js +48 -70
- package/lib/typeorm/util/DirectoryExportedClassesLoader.js.map +1 -1
- package/lib/typeorm/util/ImportUtils.js +43 -65
- package/lib/typeorm/util/ImportUtils.js.map +1 -1
- package/lib/typeorm/util/InstanceChecker.js +64 -67
- package/lib/typeorm/util/InstanceChecker.js.map +1 -1
- package/lib/typeorm/util/ObjectUtils.js +13 -42
- package/lib/typeorm/util/ObjectUtils.js.map +1 -1
- package/lib/typeorm/util/OrmUtils.js +91 -158
- package/lib/typeorm/util/OrmUtils.js.map +1 -1
- package/lib/typeorm/util/PathUtils.js +8 -8
- package/lib/typeorm/util/PathUtils.js.map +1 -1
- package/lib/typeorm/util/RandomGenerator.js +22 -25
- package/lib/typeorm/util/RandomGenerator.js.map +1 -1
- package/lib/typeorm/util/StringUtils.js +17 -21
- package/lib/typeorm/util/StringUtils.js.map +1 -1
- package/lib/typeorm/util/TreeRepositoryUtils.js +27 -30
- package/lib/typeorm/util/TreeRepositoryUtils.js.map +1 -1
- package/lib/typeorm/util/VersionUtils.js +9 -13
- package/lib/typeorm/util/VersionUtils.js.map +1 -1
- package/lib/typeorm/util/escapeRegExp.js +2 -2
- package/lib/typeorm/util/escapeRegExp.js.map +1 -1
- package/migrations/index.js +15 -2
- package/migrations/index.js.map +1 -1
- package/migrations/migrations_index._auto-generated_.d.ts +1 -0
- package/migrations/migrations_index._auto-generated_.js.map +1 -1
- package/package.json +8 -44
- package/src.d.ts +1 -1
- package/taon.jsonc +3 -30
- package/tmp-environment.json +8 -370
- package/websql/esm2022/lib/typeorm/driver/cordova/CordovaDriver.mjs +1 -1
- package/websql/esm2022/lib/typeorm/driver/cordova/CordovaQueryRunner.mjs +1 -1
- package/websql/esm2022/lib/typeorm/driver/nativescript/NativescriptDriver.mjs +1 -1
- package/websql/esm2022/lib/typeorm/driver/nativescript/NativescriptQueryRunner.mjs +1 -1
- package/websql/esm2022/lib/typeorm/driver/react-native/ReactNativeDriver.mjs +1 -1
- package/websql/esm2022/lib/typeorm/driver/react-native/ReactNativeQueryRunner.mjs +1 -1
- package/websql/esm2022/lib/typeorm/driver/sqljs/SqljsDriver.mjs +1 -1
- package/websql/esm2022/lib/typeorm/driver/sqljs/SqljsQueryRunner.mjs +1 -1
- package/websql/esm2022/lib/typeorm/index.mjs +1 -3
- package/websql/fesm2022/taon-typeorm.mjs.map +1 -1
- package/browser/package.json +0 -25
- package/websql/package.json +0 -25
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RdbmsSchemaBuilder = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var DriverUtils_1 = require("../driver/DriverUtils");
|
|
4
|
+
const Table_1 = require("./table/Table");
|
|
5
|
+
const TableColumn_1 = require("./table/TableColumn");
|
|
6
|
+
const TableForeignKey_1 = require("./table/TableForeignKey");
|
|
7
|
+
const TableIndex_1 = require("./table/TableIndex");
|
|
8
|
+
const TableUtils_1 = require("./util/TableUtils");
|
|
9
|
+
const TableUnique_1 = require("./table/TableUnique");
|
|
10
|
+
const TableCheck_1 = require("./table/TableCheck");
|
|
11
|
+
const TableExclusion_1 = require("./table/TableExclusion");
|
|
12
|
+
const View_1 = require("./view/View");
|
|
13
|
+
const ViewUtils_1 = require("./util/ViewUtils");
|
|
14
|
+
const DriverUtils_1 = require("../driver/DriverUtils");
|
|
16
15
|
/**
|
|
17
16
|
* Creates complete tables schemas in the database based on the entity metadatas.
|
|
18
17
|
*
|
|
@@ -27,13 +26,20 @@ var DriverUtils_1 = require("../driver/DriverUtils");
|
|
|
27
26
|
* 8. create foreign keys which does not exist in the table yet
|
|
28
27
|
* 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
|
|
29
28
|
*/
|
|
30
|
-
|
|
29
|
+
class RdbmsSchemaBuilder {
|
|
30
|
+
connection;
|
|
31
|
+
"@instanceof" = Symbol.for("RdbmsSchemaBuilder");
|
|
32
|
+
/**
|
|
33
|
+
* Used to execute schema creation queries in a single connection.
|
|
34
|
+
*/
|
|
35
|
+
queryRunner;
|
|
36
|
+
currentDatabase;
|
|
37
|
+
currentSchema;
|
|
31
38
|
// -------------------------------------------------------------------------
|
|
32
39
|
// Constructor
|
|
33
40
|
// -------------------------------------------------------------------------
|
|
34
|
-
|
|
41
|
+
constructor(connection) {
|
|
35
42
|
this.connection = connection;
|
|
36
|
-
this["@instanceof"] = Symbol.for("RdbmsSchemaBuilder");
|
|
37
43
|
}
|
|
38
44
|
// -------------------------------------------------------------------------
|
|
39
45
|
// Public Methods
|
|
@@ -41,2018 +47,801 @@ var RdbmsSchemaBuilder = /** @class */ (function () {
|
|
|
41
47
|
/**
|
|
42
48
|
* Creates complete schemas for the given entity metadatas.
|
|
43
49
|
*/
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
return [4 /*yield*/, this.queryRunner.getViews([])];
|
|
80
|
-
case 6:
|
|
81
|
-
_a.sent();
|
|
82
|
-
return [4 /*yield*/, this.executeSchemaSyncOperationsInProperOrder()
|
|
83
|
-
// if cache is enabled then perform cache-synchronization as well
|
|
84
|
-
];
|
|
85
|
-
case 7:
|
|
86
|
-
_a.sent();
|
|
87
|
-
if (!this.connection.queryResultCache) return [3 /*break*/, 9];
|
|
88
|
-
return [4 /*yield*/, this.connection.queryResultCache.synchronize(this.queryRunner)];
|
|
89
|
-
case 8:
|
|
90
|
-
_a.sent();
|
|
91
|
-
_a.label = 9;
|
|
92
|
-
case 9:
|
|
93
|
-
if (!isUsingTransactions) return [3 /*break*/, 11];
|
|
94
|
-
return [4 /*yield*/, this.queryRunner.commitTransaction()];
|
|
95
|
-
case 10:
|
|
96
|
-
_a.sent();
|
|
97
|
-
_a.label = 11;
|
|
98
|
-
case 11: return [3 /*break*/, 21];
|
|
99
|
-
case 12:
|
|
100
|
-
error_1 = _a.sent();
|
|
101
|
-
_a.label = 13;
|
|
102
|
-
case 13:
|
|
103
|
-
_a.trys.push([13, 16, , 17]);
|
|
104
|
-
if (!isUsingTransactions) return [3 /*break*/, 15];
|
|
105
|
-
return [4 /*yield*/, this.queryRunner.rollbackTransaction()];
|
|
106
|
-
case 14:
|
|
107
|
-
_a.sent();
|
|
108
|
-
_a.label = 15;
|
|
109
|
-
case 15: return [3 /*break*/, 17];
|
|
110
|
-
case 16:
|
|
111
|
-
rollbackError_1 = _a.sent();
|
|
112
|
-
return [3 /*break*/, 17];
|
|
113
|
-
case 17: throw error_1;
|
|
114
|
-
case 18: return [4 /*yield*/, this.queryRunner.afterMigration()];
|
|
115
|
-
case 19:
|
|
116
|
-
_a.sent();
|
|
117
|
-
return [4 /*yield*/, this.queryRunner.release()];
|
|
118
|
-
case 20:
|
|
119
|
-
_a.sent();
|
|
120
|
-
return [7 /*endfinally*/];
|
|
121
|
-
case 21: return [2 /*return*/];
|
|
50
|
+
async build() {
|
|
51
|
+
this.queryRunner = this.connection.createQueryRunner();
|
|
52
|
+
// this.connection.driver.database || this.currentDatabase;
|
|
53
|
+
this.currentDatabase = this.connection.driver.database;
|
|
54
|
+
this.currentSchema = this.connection.driver.schema;
|
|
55
|
+
// CockroachDB implements asynchronous schema sync operations which can not been executed in transaction.
|
|
56
|
+
// E.g. if you try to DROP column and ADD it again in the same transaction, crdb throws error.
|
|
57
|
+
// In Spanner queries against the INFORMATION_SCHEMA can be used in a read-only transaction,
|
|
58
|
+
// but not in a read-write transaction.
|
|
59
|
+
const isUsingTransactions = !(this.connection.driver.options.type === "cockroachdb") &&
|
|
60
|
+
!(this.connection.driver.options.type === "spanner") &&
|
|
61
|
+
this.connection.options.migrationsTransactionMode !== "none";
|
|
62
|
+
await this.queryRunner.beforeMigration();
|
|
63
|
+
if (isUsingTransactions) {
|
|
64
|
+
await this.queryRunner.startTransaction();
|
|
65
|
+
}
|
|
66
|
+
try {
|
|
67
|
+
await this.createMetadataTableIfNecessary(this.queryRunner);
|
|
68
|
+
// Flush the queryrunner table & view cache
|
|
69
|
+
const tablePaths = this.entityToSyncMetadatas.map((metadata) => this.getTablePath(metadata));
|
|
70
|
+
await this.queryRunner.getTables(tablePaths);
|
|
71
|
+
await this.queryRunner.getViews([]);
|
|
72
|
+
await this.executeSchemaSyncOperationsInProperOrder();
|
|
73
|
+
// if cache is enabled then perform cache-synchronization as well
|
|
74
|
+
if (this.connection.queryResultCache)
|
|
75
|
+
await this.connection.queryResultCache.synchronize(this.queryRunner);
|
|
76
|
+
if (isUsingTransactions) {
|
|
77
|
+
await this.queryRunner.commitTransaction();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
try {
|
|
82
|
+
// we throw original error even if rollback thrown an error
|
|
83
|
+
if (isUsingTransactions) {
|
|
84
|
+
await this.queryRunner.rollbackTransaction();
|
|
122
85
|
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
|
|
86
|
+
}
|
|
87
|
+
catch (rollbackError) { }
|
|
88
|
+
throw error;
|
|
89
|
+
}
|
|
90
|
+
finally {
|
|
91
|
+
await this.queryRunner.afterMigration();
|
|
92
|
+
await this.queryRunner.release();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
126
95
|
/**
|
|
127
96
|
* Create the typeorm_metadata table if necessary.
|
|
128
97
|
*/
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
this.hasGeneratedColumns())) return [3 /*break*/, 2];
|
|
136
|
-
return [4 /*yield*/, this.createTypeormMetadataTable(queryRunner)];
|
|
137
|
-
case 1:
|
|
138
|
-
_a.sent();
|
|
139
|
-
_a.label = 2;
|
|
140
|
-
case 2: return [2 /*return*/];
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
|
-
});
|
|
144
|
-
};
|
|
98
|
+
async createMetadataTableIfNecessary(queryRunner) {
|
|
99
|
+
if (this.viewEntityToSyncMetadatas.length > 0 ||
|
|
100
|
+
this.hasGeneratedColumns()) {
|
|
101
|
+
await this.createTypeormMetadataTable(queryRunner);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
145
104
|
/**
|
|
146
105
|
* Returns sql queries to be executed by schema builder.
|
|
147
106
|
*/
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
case 9: return [2 /*return*/];
|
|
192
|
-
}
|
|
193
|
-
});
|
|
194
|
-
});
|
|
195
|
-
};
|
|
196
|
-
Object.defineProperty(RdbmsSchemaBuilder.prototype, "entityToSyncMetadatas", {
|
|
197
|
-
// -------------------------------------------------------------------------
|
|
198
|
-
// Protected Methods
|
|
199
|
-
// -------------------------------------------------------------------------
|
|
200
|
-
/**
|
|
201
|
-
* Returns only entities that should be synced in the database.
|
|
202
|
-
*/
|
|
203
|
-
get: function () {
|
|
204
|
-
return this.connection.entityMetadatas.filter(function (metadata) {
|
|
205
|
-
return metadata.synchronize &&
|
|
206
|
-
metadata.tableType !== "entity-child" &&
|
|
207
|
-
metadata.tableType !== "view";
|
|
208
|
-
});
|
|
209
|
-
},
|
|
210
|
-
enumerable: false,
|
|
211
|
-
configurable: true
|
|
212
|
-
});
|
|
213
|
-
Object.defineProperty(RdbmsSchemaBuilder.prototype, "viewEntityToSyncMetadatas", {
|
|
214
|
-
/**
|
|
215
|
-
* Returns only entities that should be synced in the database.
|
|
216
|
-
*/
|
|
217
|
-
get: function () {
|
|
218
|
-
return (this.connection.entityMetadatas
|
|
219
|
-
.filter(function (metadata) {
|
|
220
|
-
return metadata.tableType === "view" && metadata.synchronize;
|
|
221
|
-
})
|
|
222
|
-
// sort views in creation order by dependencies
|
|
223
|
-
.sort(ViewUtils_1.ViewUtils.viewMetadataCmp));
|
|
224
|
-
},
|
|
225
|
-
enumerable: false,
|
|
226
|
-
configurable: true
|
|
227
|
-
});
|
|
107
|
+
async log() {
|
|
108
|
+
this.queryRunner = this.connection.createQueryRunner();
|
|
109
|
+
try {
|
|
110
|
+
// Flush the queryrunner table & view cache
|
|
111
|
+
const tablePaths = this.entityToSyncMetadatas.map((metadata) => this.getTablePath(metadata));
|
|
112
|
+
await this.queryRunner.getTables(tablePaths);
|
|
113
|
+
await this.queryRunner.getViews([]);
|
|
114
|
+
this.queryRunner.enableSqlMemory();
|
|
115
|
+
await this.executeSchemaSyncOperationsInProperOrder();
|
|
116
|
+
// if cache is enabled then perform cache-synchronization as well
|
|
117
|
+
if (this.connection.queryResultCache)
|
|
118
|
+
// todo: check this functionality
|
|
119
|
+
await this.connection.queryResultCache.synchronize(this.queryRunner);
|
|
120
|
+
return this.queryRunner.getMemorySql();
|
|
121
|
+
}
|
|
122
|
+
finally {
|
|
123
|
+
// its important to disable this mode despite the fact we are release query builder
|
|
124
|
+
// because there exist drivers which reuse same query runner. Also its important to disable
|
|
125
|
+
// sql memory after call of getMemorySql() method because last one flushes sql memory.
|
|
126
|
+
this.queryRunner.disableSqlMemory();
|
|
127
|
+
await this.queryRunner.release();
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
// -------------------------------------------------------------------------
|
|
131
|
+
// Protected Methods
|
|
132
|
+
// -------------------------------------------------------------------------
|
|
133
|
+
/**
|
|
134
|
+
* Returns only entities that should be synced in the database.
|
|
135
|
+
*/
|
|
136
|
+
get entityToSyncMetadatas() {
|
|
137
|
+
return this.connection.entityMetadatas.filter((metadata) => metadata.synchronize &&
|
|
138
|
+
metadata.tableType !== "entity-child" &&
|
|
139
|
+
metadata.tableType !== "view");
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Returns only entities that should be synced in the database.
|
|
143
|
+
*/
|
|
144
|
+
get viewEntityToSyncMetadatas() {
|
|
145
|
+
return (this.connection.entityMetadatas
|
|
146
|
+
.filter((metadata) => metadata.tableType === "view" && metadata.synchronize)
|
|
147
|
+
// sort views in creation order by dependencies
|
|
148
|
+
.sort(ViewUtils_1.ViewUtils.viewMetadataCmp));
|
|
149
|
+
}
|
|
228
150
|
/**
|
|
229
151
|
* Checks if there are at least one generated column.
|
|
230
152
|
*/
|
|
231
|
-
|
|
232
|
-
return this.connection.entityMetadatas.some(
|
|
233
|
-
return entityMetadata.columns.some(
|
|
153
|
+
hasGeneratedColumns() {
|
|
154
|
+
return this.connection.entityMetadatas.some((entityMetadata) => {
|
|
155
|
+
return entityMetadata.columns.some((column) => column.generatedType);
|
|
234
156
|
});
|
|
235
|
-
}
|
|
157
|
+
}
|
|
236
158
|
/**
|
|
237
159
|
* Executes schema sync operations in a proper order.
|
|
238
160
|
* Order of operations matter here.
|
|
239
161
|
*/
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
_a.sent();
|
|
264
|
-
// await this.renameTables();
|
|
265
|
-
return [4 /*yield*/, this.renameColumns()];
|
|
266
|
-
case 7:
|
|
267
|
-
// await this.renameTables();
|
|
268
|
-
_a.sent();
|
|
269
|
-
return [4 /*yield*/, this.createNewTables()];
|
|
270
|
-
case 8:
|
|
271
|
-
_a.sent();
|
|
272
|
-
return [4 /*yield*/, this.dropRemovedColumns()];
|
|
273
|
-
case 9:
|
|
274
|
-
_a.sent();
|
|
275
|
-
return [4 /*yield*/, this.addNewColumns()];
|
|
276
|
-
case 10:
|
|
277
|
-
_a.sent();
|
|
278
|
-
return [4 /*yield*/, this.updatePrimaryKeys()];
|
|
279
|
-
case 11:
|
|
280
|
-
_a.sent();
|
|
281
|
-
return [4 /*yield*/, this.updateExistColumns()];
|
|
282
|
-
case 12:
|
|
283
|
-
_a.sent();
|
|
284
|
-
return [4 /*yield*/, this.createNewIndices()];
|
|
285
|
-
case 13:
|
|
286
|
-
_a.sent();
|
|
287
|
-
return [4 /*yield*/, this.createNewChecks()];
|
|
288
|
-
case 14:
|
|
289
|
-
_a.sent();
|
|
290
|
-
return [4 /*yield*/, this.createNewExclusions()];
|
|
291
|
-
case 15:
|
|
292
|
-
_a.sent();
|
|
293
|
-
return [4 /*yield*/, this.createCompositeUniqueConstraints()];
|
|
294
|
-
case 16:
|
|
295
|
-
_a.sent();
|
|
296
|
-
return [4 /*yield*/, this.createForeignKeys()];
|
|
297
|
-
case 17:
|
|
298
|
-
_a.sent();
|
|
299
|
-
return [4 /*yield*/, this.createViews()];
|
|
300
|
-
case 18:
|
|
301
|
-
_a.sent();
|
|
302
|
-
return [2 /*return*/];
|
|
303
|
-
}
|
|
304
|
-
});
|
|
305
|
-
});
|
|
306
|
-
};
|
|
307
|
-
RdbmsSchemaBuilder.prototype.getTablePath = function (target) {
|
|
308
|
-
var parsed = this.connection.driver.parseTableName(target);
|
|
162
|
+
async executeSchemaSyncOperationsInProperOrder() {
|
|
163
|
+
await this.dropOldViews();
|
|
164
|
+
await this.dropOldForeignKeys();
|
|
165
|
+
await this.dropOldIndices();
|
|
166
|
+
await this.dropOldChecks();
|
|
167
|
+
await this.dropOldExclusions();
|
|
168
|
+
await this.dropCompositeUniqueConstraints();
|
|
169
|
+
// await this.renameTables();
|
|
170
|
+
await this.renameColumns();
|
|
171
|
+
await this.createNewTables();
|
|
172
|
+
await this.dropRemovedColumns();
|
|
173
|
+
await this.addNewColumns();
|
|
174
|
+
await this.updatePrimaryKeys();
|
|
175
|
+
await this.updateExistColumns();
|
|
176
|
+
await this.createNewIndices();
|
|
177
|
+
await this.createNewChecks();
|
|
178
|
+
await this.createNewExclusions();
|
|
179
|
+
await this.createCompositeUniqueConstraints();
|
|
180
|
+
await this.createForeignKeys();
|
|
181
|
+
await this.createViews();
|
|
182
|
+
}
|
|
183
|
+
getTablePath(target) {
|
|
184
|
+
const parsed = this.connection.driver.parseTableName(target);
|
|
309
185
|
return this.connection.driver.buildTableName(parsed.tableName, parsed.schema || this.currentSchema, parsed.database || this.currentDatabase);
|
|
310
|
-
}
|
|
186
|
+
}
|
|
311
187
|
/**
|
|
312
188
|
* Drops all (old) foreign keys that exist in the tables, but do not exist in the entity metadata.
|
|
313
189
|
*/
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
});
|
|
330
|
-
if (!table)
|
|
331
|
-
return [2 /*return*/, "continue"];
|
|
332
|
-
tableForeignKeysToDrop = table.foreignKeys.filter(function (tableForeignKey) {
|
|
333
|
-
var metadataFK = metadata.foreignKeys.find(function (metadataForeignKey) {
|
|
334
|
-
return tableForeignKey.name === metadataForeignKey.name &&
|
|
335
|
-
_this.getTablePath(tableForeignKey) ===
|
|
336
|
-
_this.getTablePath(metadataForeignKey.referencedEntityMetadata);
|
|
337
|
-
});
|
|
338
|
-
return (!metadataFK ||
|
|
339
|
-
(metadataFK.onDelete &&
|
|
340
|
-
metadataFK.onDelete !== tableForeignKey.onDelete) ||
|
|
341
|
-
(metadataFK.onUpdate &&
|
|
342
|
-
metadataFK.onUpdate !== tableForeignKey.onUpdate));
|
|
343
|
-
});
|
|
344
|
-
if (tableForeignKeysToDrop.length === 0)
|
|
345
|
-
return [2 /*return*/, "continue"];
|
|
346
|
-
this_1.connection.logger.logSchemaBuild("dropping old foreign keys of ".concat(table.name, ": ").concat(tableForeignKeysToDrop
|
|
347
|
-
.map(function (dbForeignKey) { return dbForeignKey.name; })
|
|
348
|
-
.join(", ")));
|
|
349
|
-
// drop foreign keys from the database
|
|
350
|
-
return [4 /*yield*/, this_1.queryRunner.dropForeignKeys(table, tableForeignKeysToDrop)];
|
|
351
|
-
case 1:
|
|
352
|
-
// drop foreign keys from the database
|
|
353
|
-
_e.sent();
|
|
354
|
-
return [2 /*return*/];
|
|
355
|
-
}
|
|
356
|
-
});
|
|
357
|
-
};
|
|
358
|
-
this_1 = this;
|
|
359
|
-
_d.label = 1;
|
|
360
|
-
case 1:
|
|
361
|
-
_d.trys.push([1, 6, 7, 8]);
|
|
362
|
-
_a = tslib_1.__values(this.entityToSyncMetadatas), _b = _a.next();
|
|
363
|
-
_d.label = 2;
|
|
364
|
-
case 2:
|
|
365
|
-
if (!!_b.done) return [3 /*break*/, 5];
|
|
366
|
-
metadata = _b.value;
|
|
367
|
-
return [5 /*yield**/, _loop_1(metadata)];
|
|
368
|
-
case 3:
|
|
369
|
-
_d.sent();
|
|
370
|
-
_d.label = 4;
|
|
371
|
-
case 4:
|
|
372
|
-
_b = _a.next();
|
|
373
|
-
return [3 /*break*/, 2];
|
|
374
|
-
case 5: return [3 /*break*/, 8];
|
|
375
|
-
case 6:
|
|
376
|
-
e_1_1 = _d.sent();
|
|
377
|
-
e_1 = { error: e_1_1 };
|
|
378
|
-
return [3 /*break*/, 8];
|
|
379
|
-
case 7:
|
|
380
|
-
try {
|
|
381
|
-
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
382
|
-
}
|
|
383
|
-
finally { if (e_1) throw e_1.error; }
|
|
384
|
-
return [7 /*endfinally*/];
|
|
385
|
-
case 8: return [2 /*return*/];
|
|
386
|
-
}
|
|
190
|
+
async dropOldForeignKeys() {
|
|
191
|
+
for (const metadata of this.entityToSyncMetadatas) {
|
|
192
|
+
const table = this.queryRunner.loadedTables.find((table) => this.getTablePath(table) === this.getTablePath(metadata));
|
|
193
|
+
if (!table)
|
|
194
|
+
continue;
|
|
195
|
+
// find foreign keys that exist in the schemas but does not exist in the entity metadata
|
|
196
|
+
const tableForeignKeysToDrop = table.foreignKeys.filter((tableForeignKey) => {
|
|
197
|
+
const metadataFK = metadata.foreignKeys.find((metadataForeignKey) => tableForeignKey.name === metadataForeignKey.name &&
|
|
198
|
+
this.getTablePath(tableForeignKey) ===
|
|
199
|
+
this.getTablePath(metadataForeignKey.referencedEntityMetadata));
|
|
200
|
+
return (!metadataFK ||
|
|
201
|
+
(metadataFK.onDelete &&
|
|
202
|
+
metadataFK.onDelete !== tableForeignKey.onDelete) ||
|
|
203
|
+
(metadataFK.onUpdate &&
|
|
204
|
+
metadataFK.onUpdate !== tableForeignKey.onUpdate));
|
|
387
205
|
});
|
|
388
|
-
|
|
389
|
-
|
|
206
|
+
if (tableForeignKeysToDrop.length === 0)
|
|
207
|
+
continue;
|
|
208
|
+
this.connection.logger.logSchemaBuild(`dropping old foreign keys of ${table.name}: ${tableForeignKeysToDrop
|
|
209
|
+
.map((dbForeignKey) => dbForeignKey.name)
|
|
210
|
+
.join(", ")}`);
|
|
211
|
+
// drop foreign keys from the database
|
|
212
|
+
await this.queryRunner.dropForeignKeys(table, tableForeignKeysToDrop);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
390
215
|
/**
|
|
391
216
|
* Rename tables
|
|
392
217
|
*/
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
});
|
|
399
|
-
};
|
|
218
|
+
async renameTables() {
|
|
219
|
+
// for (const metadata of this.entityToSyncMetadatas) {
|
|
220
|
+
// const table = this.queryRunner.loadedTables.find(table => this.getTablePath(table) === this.getTablePath(metadata));
|
|
221
|
+
// }
|
|
222
|
+
}
|
|
400
223
|
/**
|
|
401
224
|
* Renames columns.
|
|
402
225
|
* Works if only one column per table was changed.
|
|
403
226
|
* Changes only column name. If something besides name was changed, these changes will be ignored.
|
|
404
227
|
*/
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
if (metadata.columns.length !== table.columns.length)
|
|
424
|
-
return [2 /*return*/, "continue"];
|
|
425
|
-
renamedMetadataColumns = metadata.columns
|
|
426
|
-
.filter(function (c) { return !c.isVirtualProperty; })
|
|
427
|
-
.filter(function (column) {
|
|
428
|
-
return !table.columns.find(function (tableColumn) {
|
|
429
|
-
return (tableColumn.name === column.databaseName &&
|
|
430
|
-
tableColumn.type ===
|
|
431
|
-
_this.connection.driver.normalizeType(column) &&
|
|
432
|
-
tableColumn.isNullable === column.isNullable &&
|
|
433
|
-
tableColumn.isUnique ===
|
|
434
|
-
_this.connection.driver.normalizeIsUnique(column));
|
|
435
|
-
});
|
|
436
|
-
});
|
|
437
|
-
if (renamedMetadataColumns.length === 0 ||
|
|
438
|
-
renamedMetadataColumns.length > 1)
|
|
439
|
-
return [2 /*return*/, "continue"];
|
|
440
|
-
renamedTableColumns = table.columns.filter(function (tableColumn) {
|
|
441
|
-
return !metadata.columns.find(function (column) {
|
|
442
|
-
return (!column.isVirtualProperty &&
|
|
443
|
-
column.databaseName === tableColumn.name &&
|
|
444
|
-
_this.connection.driver.normalizeType(column) ===
|
|
445
|
-
tableColumn.type &&
|
|
446
|
-
column.isNullable === tableColumn.isNullable &&
|
|
447
|
-
_this.connection.driver.normalizeIsUnique(column) ===
|
|
448
|
-
tableColumn.isUnique);
|
|
449
|
-
});
|
|
450
|
-
});
|
|
451
|
-
if (renamedTableColumns.length === 0 ||
|
|
452
|
-
renamedTableColumns.length > 1)
|
|
453
|
-
return [2 /*return*/, "continue"];
|
|
454
|
-
renamedColumn = renamedTableColumns[0].clone();
|
|
455
|
-
renamedColumn.name = renamedMetadataColumns[0].databaseName;
|
|
456
|
-
this_2.connection.logger.logSchemaBuild("renaming column \"".concat(renamedTableColumns[0].name, "\" in to \"").concat(renamedColumn.name, "\""));
|
|
457
|
-
return [4 /*yield*/, this_2.queryRunner.renameColumn(table, renamedTableColumns[0], renamedColumn)];
|
|
458
|
-
case 1:
|
|
459
|
-
_e.sent();
|
|
460
|
-
return [2 /*return*/];
|
|
461
|
-
}
|
|
462
|
-
});
|
|
463
|
-
};
|
|
464
|
-
this_2 = this;
|
|
465
|
-
_d.label = 1;
|
|
466
|
-
case 1:
|
|
467
|
-
_d.trys.push([1, 6, 7, 8]);
|
|
468
|
-
_a = tslib_1.__values(this.entityToSyncMetadatas), _b = _a.next();
|
|
469
|
-
_d.label = 2;
|
|
470
|
-
case 2:
|
|
471
|
-
if (!!_b.done) return [3 /*break*/, 5];
|
|
472
|
-
metadata = _b.value;
|
|
473
|
-
return [5 /*yield**/, _loop_2(metadata)];
|
|
474
|
-
case 3:
|
|
475
|
-
_d.sent();
|
|
476
|
-
_d.label = 4;
|
|
477
|
-
case 4:
|
|
478
|
-
_b = _a.next();
|
|
479
|
-
return [3 /*break*/, 2];
|
|
480
|
-
case 5: return [3 /*break*/, 8];
|
|
481
|
-
case 6:
|
|
482
|
-
e_2_1 = _d.sent();
|
|
483
|
-
e_2 = { error: e_2_1 };
|
|
484
|
-
return [3 /*break*/, 8];
|
|
485
|
-
case 7:
|
|
486
|
-
try {
|
|
487
|
-
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
488
|
-
}
|
|
489
|
-
finally { if (e_2) throw e_2.error; }
|
|
490
|
-
return [7 /*endfinally*/];
|
|
491
|
-
case 8: return [2 /*return*/];
|
|
492
|
-
}
|
|
228
|
+
async renameColumns() {
|
|
229
|
+
for (const metadata of this.entityToSyncMetadatas) {
|
|
230
|
+
const table = this.queryRunner.loadedTables.find((table) => this.getTablePath(table) === this.getTablePath(metadata));
|
|
231
|
+
if (!table)
|
|
232
|
+
continue;
|
|
233
|
+
if (metadata.columns.length !== table.columns.length)
|
|
234
|
+
continue;
|
|
235
|
+
const renamedMetadataColumns = metadata.columns
|
|
236
|
+
.filter((c) => !c.isVirtualProperty)
|
|
237
|
+
.filter((column) => {
|
|
238
|
+
return !table.columns.find((tableColumn) => {
|
|
239
|
+
return (tableColumn.name === column.databaseName &&
|
|
240
|
+
tableColumn.type ===
|
|
241
|
+
this.connection.driver.normalizeType(column) &&
|
|
242
|
+
tableColumn.isNullable === column.isNullable &&
|
|
243
|
+
tableColumn.isUnique ===
|
|
244
|
+
this.connection.driver.normalizeIsUnique(column));
|
|
245
|
+
});
|
|
493
246
|
});
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
switch (_e.label) {
|
|
508
|
-
case 0:
|
|
509
|
-
table = this_3.queryRunner.loadedTables.find(function (table) {
|
|
510
|
-
return _this.getTablePath(table) === _this.getTablePath(metadata);
|
|
511
|
-
});
|
|
512
|
-
if (!table)
|
|
513
|
-
return [2 /*return*/, "continue"];
|
|
514
|
-
dropQueries = table.indices
|
|
515
|
-
.filter(function (tableIndex) {
|
|
516
|
-
var indexMetadata = metadata.indices.find(function (index) { return index.name === tableIndex.name; });
|
|
517
|
-
if (indexMetadata) {
|
|
518
|
-
if (indexMetadata.synchronize === false)
|
|
519
|
-
return false;
|
|
520
|
-
if (indexMetadata.isUnique !== tableIndex.isUnique)
|
|
521
|
-
return true;
|
|
522
|
-
if (indexMetadata.isSpatial !== tableIndex.isSpatial)
|
|
523
|
-
return true;
|
|
524
|
-
if (_this.connection.driver.isFullTextColumnTypeSupported() &&
|
|
525
|
-
indexMetadata.isFulltext !== tableIndex.isFulltext)
|
|
526
|
-
return true;
|
|
527
|
-
if (indexMetadata.columns.length !==
|
|
528
|
-
tableIndex.columnNames.length)
|
|
529
|
-
return true;
|
|
530
|
-
return !indexMetadata.columns.every(function (column) {
|
|
531
|
-
return tableIndex.columnNames.indexOf(column.databaseName) !== -1;
|
|
532
|
-
});
|
|
533
|
-
}
|
|
534
|
-
return true;
|
|
535
|
-
})
|
|
536
|
-
.map(function (tableIndex) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
537
|
-
return tslib_1.__generator(this, function (_a) {
|
|
538
|
-
switch (_a.label) {
|
|
539
|
-
case 0:
|
|
540
|
-
this.connection.logger.logSchemaBuild("dropping an index: \"".concat(tableIndex.name, "\" from table ").concat(table.name));
|
|
541
|
-
return [4 /*yield*/, this.queryRunner.dropIndex(table, tableIndex)];
|
|
542
|
-
case 1:
|
|
543
|
-
_a.sent();
|
|
544
|
-
return [2 /*return*/];
|
|
545
|
-
}
|
|
546
|
-
});
|
|
547
|
-
}); });
|
|
548
|
-
return [4 /*yield*/, Promise.all(dropQueries)];
|
|
549
|
-
case 1:
|
|
550
|
-
_e.sent();
|
|
551
|
-
return [2 /*return*/];
|
|
552
|
-
}
|
|
553
|
-
});
|
|
554
|
-
};
|
|
555
|
-
this_3 = this;
|
|
556
|
-
_d.label = 1;
|
|
557
|
-
case 1:
|
|
558
|
-
_d.trys.push([1, 6, 7, 8]);
|
|
559
|
-
_a = tslib_1.__values(this.entityToSyncMetadatas), _b = _a.next();
|
|
560
|
-
_d.label = 2;
|
|
561
|
-
case 2:
|
|
562
|
-
if (!!_b.done) return [3 /*break*/, 5];
|
|
563
|
-
metadata = _b.value;
|
|
564
|
-
return [5 /*yield**/, _loop_3(metadata)];
|
|
565
|
-
case 3:
|
|
566
|
-
_d.sent();
|
|
567
|
-
_d.label = 4;
|
|
568
|
-
case 4:
|
|
569
|
-
_b = _a.next();
|
|
570
|
-
return [3 /*break*/, 2];
|
|
571
|
-
case 5: return [3 /*break*/, 8];
|
|
572
|
-
case 6:
|
|
573
|
-
e_3_1 = _d.sent();
|
|
574
|
-
e_3 = { error: e_3_1 };
|
|
575
|
-
return [3 /*break*/, 8];
|
|
576
|
-
case 7:
|
|
577
|
-
try {
|
|
578
|
-
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
579
|
-
}
|
|
580
|
-
finally { if (e_3) throw e_3.error; }
|
|
581
|
-
return [7 /*endfinally*/];
|
|
582
|
-
case 8: return [2 /*return*/];
|
|
583
|
-
}
|
|
247
|
+
if (renamedMetadataColumns.length === 0 ||
|
|
248
|
+
renamedMetadataColumns.length > 1)
|
|
249
|
+
continue;
|
|
250
|
+
const renamedTableColumns = table.columns.filter((tableColumn) => {
|
|
251
|
+
return !metadata.columns.find((column) => {
|
|
252
|
+
return (!column.isVirtualProperty &&
|
|
253
|
+
column.databaseName === tableColumn.name &&
|
|
254
|
+
this.connection.driver.normalizeType(column) ===
|
|
255
|
+
tableColumn.type &&
|
|
256
|
+
column.isNullable === tableColumn.isNullable &&
|
|
257
|
+
this.connection.driver.normalizeIsUnique(column) ===
|
|
258
|
+
tableColumn.isUnique);
|
|
259
|
+
});
|
|
584
260
|
});
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
.join(", "), " from table \"").concat(table.name, "\""));
|
|
617
|
-
return [4 /*yield*/, this_4.queryRunner.dropCheckConstraints(table, oldChecks)];
|
|
618
|
-
case 1:
|
|
619
|
-
_e.sent();
|
|
620
|
-
return [2 /*return*/];
|
|
621
|
-
}
|
|
622
|
-
});
|
|
623
|
-
};
|
|
624
|
-
this_4 = this;
|
|
625
|
-
_d.label = 1;
|
|
626
|
-
case 1:
|
|
627
|
-
_d.trys.push([1, 6, 7, 8]);
|
|
628
|
-
_a = tslib_1.__values(this.entityToSyncMetadatas), _b = _a.next();
|
|
629
|
-
_d.label = 2;
|
|
630
|
-
case 2:
|
|
631
|
-
if (!!_b.done) return [3 /*break*/, 5];
|
|
632
|
-
metadata = _b.value;
|
|
633
|
-
return [5 /*yield**/, _loop_4(metadata)];
|
|
634
|
-
case 3:
|
|
635
|
-
_d.sent();
|
|
636
|
-
_d.label = 4;
|
|
637
|
-
case 4:
|
|
638
|
-
_b = _a.next();
|
|
639
|
-
return [3 /*break*/, 2];
|
|
640
|
-
case 5: return [3 /*break*/, 8];
|
|
641
|
-
case 6:
|
|
642
|
-
e_4_1 = _d.sent();
|
|
643
|
-
e_4 = { error: e_4_1 };
|
|
644
|
-
return [3 /*break*/, 8];
|
|
645
|
-
case 7:
|
|
646
|
-
try {
|
|
647
|
-
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
648
|
-
}
|
|
649
|
-
finally { if (e_4) throw e_4.error; }
|
|
650
|
-
return [7 /*endfinally*/];
|
|
651
|
-
case 8: return [2 /*return*/];
|
|
261
|
+
if (renamedTableColumns.length === 0 ||
|
|
262
|
+
renamedTableColumns.length > 1)
|
|
263
|
+
continue;
|
|
264
|
+
const renamedColumn = renamedTableColumns[0].clone();
|
|
265
|
+
renamedColumn.name = renamedMetadataColumns[0].databaseName;
|
|
266
|
+
this.connection.logger.logSchemaBuild(`renaming column "${renamedTableColumns[0].name}" in to "${renamedColumn.name}"`);
|
|
267
|
+
await this.queryRunner.renameColumn(table, renamedTableColumns[0], renamedColumn);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
async dropOldIndices() {
|
|
271
|
+
for (const metadata of this.entityToSyncMetadatas) {
|
|
272
|
+
const table = this.queryRunner.loadedTables.find((table) => this.getTablePath(table) === this.getTablePath(metadata));
|
|
273
|
+
if (!table)
|
|
274
|
+
continue;
|
|
275
|
+
const dropQueries = table.indices
|
|
276
|
+
.filter((tableIndex) => {
|
|
277
|
+
const indexMetadata = metadata.indices.find((index) => index.name === tableIndex.name);
|
|
278
|
+
if (indexMetadata) {
|
|
279
|
+
if (indexMetadata.synchronize === false)
|
|
280
|
+
return false;
|
|
281
|
+
if (indexMetadata.isUnique !== tableIndex.isUnique)
|
|
282
|
+
return true;
|
|
283
|
+
if (indexMetadata.isSpatial !== tableIndex.isSpatial)
|
|
284
|
+
return true;
|
|
285
|
+
if (this.connection.driver.isFullTextColumnTypeSupported() &&
|
|
286
|
+
indexMetadata.isFulltext !== tableIndex.isFulltext)
|
|
287
|
+
return true;
|
|
288
|
+
if (indexMetadata.columns.length !==
|
|
289
|
+
tableIndex.columnNames.length)
|
|
290
|
+
return true;
|
|
291
|
+
return !indexMetadata.columns.every((column) => tableIndex.columnNames.indexOf(column.databaseName) !== -1);
|
|
652
292
|
}
|
|
293
|
+
return true;
|
|
294
|
+
})
|
|
295
|
+
.map(async (tableIndex) => {
|
|
296
|
+
this.connection.logger.logSchemaBuild(`dropping an index: "${tableIndex.name}" from table ${table.name}`);
|
|
297
|
+
await this.queryRunner.dropIndex(table, tableIndex);
|
|
653
298
|
});
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
return
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
case 0:
|
|
669
|
-
table = this_5.queryRunner.loadedTables.find(function (table) {
|
|
670
|
-
return _this.getTablePath(table) === _this.getTablePath(metadata);
|
|
671
|
-
});
|
|
672
|
-
if (!table)
|
|
673
|
-
return [2 /*return*/, "continue"];
|
|
674
|
-
compositeUniques = table.uniques.filter(function (tableUnique) {
|
|
675
|
-
return (tableUnique.columnNames.length > 1 &&
|
|
676
|
-
!metadata.uniques.find(function (uniqueMetadata) {
|
|
677
|
-
return uniqueMetadata.name === tableUnique.name;
|
|
678
|
-
}));
|
|
679
|
-
});
|
|
680
|
-
if (compositeUniques.length === 0)
|
|
681
|
-
return [2 /*return*/, "continue"];
|
|
682
|
-
this_5.connection.logger.logSchemaBuild("dropping old unique constraint: ".concat(compositeUniques
|
|
683
|
-
.map(function (unique) { return "\"".concat(unique.name, "\""); })
|
|
684
|
-
.join(", "), " from table \"").concat(table.name, "\""));
|
|
685
|
-
return [4 /*yield*/, this_5.queryRunner.dropUniqueConstraints(table, compositeUniques)];
|
|
686
|
-
case 1:
|
|
687
|
-
_e.sent();
|
|
688
|
-
return [2 /*return*/];
|
|
689
|
-
}
|
|
690
|
-
});
|
|
691
|
-
};
|
|
692
|
-
this_5 = this;
|
|
693
|
-
_d.label = 1;
|
|
694
|
-
case 1:
|
|
695
|
-
_d.trys.push([1, 6, 7, 8]);
|
|
696
|
-
_a = tslib_1.__values(this.entityToSyncMetadatas), _b = _a.next();
|
|
697
|
-
_d.label = 2;
|
|
698
|
-
case 2:
|
|
699
|
-
if (!!_b.done) return [3 /*break*/, 5];
|
|
700
|
-
metadata = _b.value;
|
|
701
|
-
return [5 /*yield**/, _loop_5(metadata)];
|
|
702
|
-
case 3:
|
|
703
|
-
_d.sent();
|
|
704
|
-
_d.label = 4;
|
|
705
|
-
case 4:
|
|
706
|
-
_b = _a.next();
|
|
707
|
-
return [3 /*break*/, 2];
|
|
708
|
-
case 5: return [3 /*break*/, 8];
|
|
709
|
-
case 6:
|
|
710
|
-
e_5_1 = _d.sent();
|
|
711
|
-
e_5 = { error: e_5_1 };
|
|
712
|
-
return [3 /*break*/, 8];
|
|
713
|
-
case 7:
|
|
714
|
-
try {
|
|
715
|
-
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
716
|
-
}
|
|
717
|
-
finally { if (e_5) throw e_5.error; }
|
|
718
|
-
return [7 /*endfinally*/];
|
|
719
|
-
case 8: return [2 /*return*/];
|
|
720
|
-
}
|
|
299
|
+
await Promise.all(dropQueries);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
async dropOldChecks() {
|
|
303
|
+
// Mysql does not support check constraints
|
|
304
|
+
if (DriverUtils_1.DriverUtils.isMySQLFamily(this.connection.driver) ||
|
|
305
|
+
this.connection.driver.options.type === "aurora-mysql")
|
|
306
|
+
return;
|
|
307
|
+
for (const metadata of this.entityToSyncMetadatas) {
|
|
308
|
+
const table = this.queryRunner.loadedTables.find((table) => this.getTablePath(table) === this.getTablePath(metadata));
|
|
309
|
+
if (!table)
|
|
310
|
+
continue;
|
|
311
|
+
const oldChecks = table.checks.filter((tableCheck) => {
|
|
312
|
+
return !metadata.checks.find((checkMetadata) => checkMetadata.name === tableCheck.name);
|
|
721
313
|
});
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
switch (_e.label) {
|
|
739
|
-
case 0:
|
|
740
|
-
table = this_6.queryRunner.loadedTables.find(function (table) {
|
|
741
|
-
return _this.getTablePath(table) === _this.getTablePath(metadata);
|
|
742
|
-
});
|
|
743
|
-
if (!table)
|
|
744
|
-
return [2 /*return*/, "continue"];
|
|
745
|
-
oldExclusions = table.exclusions.filter(function (tableExclusion) {
|
|
746
|
-
return !metadata.exclusions.find(function (exclusionMetadata) {
|
|
747
|
-
return exclusionMetadata.name === tableExclusion.name;
|
|
748
|
-
});
|
|
749
|
-
});
|
|
750
|
-
if (oldExclusions.length === 0)
|
|
751
|
-
return [2 /*return*/, "continue"];
|
|
752
|
-
this_6.connection.logger.logSchemaBuild("dropping old exclusion constraint: ".concat(oldExclusions
|
|
753
|
-
.map(function (exclusion) { return "\"".concat(exclusion.name, "\""); })
|
|
754
|
-
.join(", "), " from table \"").concat(table.name, "\""));
|
|
755
|
-
return [4 /*yield*/, this_6.queryRunner.dropExclusionConstraints(table, oldExclusions)];
|
|
756
|
-
case 1:
|
|
757
|
-
_e.sent();
|
|
758
|
-
return [2 /*return*/];
|
|
759
|
-
}
|
|
760
|
-
});
|
|
761
|
-
};
|
|
762
|
-
this_6 = this;
|
|
763
|
-
_d.label = 1;
|
|
764
|
-
case 1:
|
|
765
|
-
_d.trys.push([1, 6, 7, 8]);
|
|
766
|
-
_a = tslib_1.__values(this.entityToSyncMetadatas), _b = _a.next();
|
|
767
|
-
_d.label = 2;
|
|
768
|
-
case 2:
|
|
769
|
-
if (!!_b.done) return [3 /*break*/, 5];
|
|
770
|
-
metadata = _b.value;
|
|
771
|
-
return [5 /*yield**/, _loop_6(metadata)];
|
|
772
|
-
case 3:
|
|
773
|
-
_d.sent();
|
|
774
|
-
_d.label = 4;
|
|
775
|
-
case 4:
|
|
776
|
-
_b = _a.next();
|
|
777
|
-
return [3 /*break*/, 2];
|
|
778
|
-
case 5: return [3 /*break*/, 8];
|
|
779
|
-
case 6:
|
|
780
|
-
e_6_1 = _d.sent();
|
|
781
|
-
e_6 = { error: e_6_1 };
|
|
782
|
-
return [3 /*break*/, 8];
|
|
783
|
-
case 7:
|
|
784
|
-
try {
|
|
785
|
-
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
786
|
-
}
|
|
787
|
-
finally { if (e_6) throw e_6.error; }
|
|
788
|
-
return [7 /*endfinally*/];
|
|
789
|
-
case 8: return [2 /*return*/];
|
|
790
|
-
}
|
|
314
|
+
if (oldChecks.length === 0)
|
|
315
|
+
continue;
|
|
316
|
+
this.connection.logger.logSchemaBuild(`dropping old check constraint: ${oldChecks
|
|
317
|
+
.map((check) => `"${check.name}"`)
|
|
318
|
+
.join(", ")} from table "${table.name}"`);
|
|
319
|
+
await this.queryRunner.dropCheckConstraints(table, oldChecks);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
async dropCompositeUniqueConstraints() {
|
|
323
|
+
for (const metadata of this.entityToSyncMetadatas) {
|
|
324
|
+
const table = this.queryRunner.loadedTables.find((table) => this.getTablePath(table) === this.getTablePath(metadata));
|
|
325
|
+
if (!table)
|
|
326
|
+
continue;
|
|
327
|
+
const compositeUniques = table.uniques.filter((tableUnique) => {
|
|
328
|
+
return (tableUnique.columnNames.length > 1 &&
|
|
329
|
+
!metadata.uniques.find((uniqueMetadata) => uniqueMetadata.name === tableUnique.name));
|
|
791
330
|
});
|
|
792
|
-
|
|
793
|
-
|
|
331
|
+
if (compositeUniques.length === 0)
|
|
332
|
+
continue;
|
|
333
|
+
this.connection.logger.logSchemaBuild(`dropping old unique constraint: ${compositeUniques
|
|
334
|
+
.map((unique) => `"${unique.name}"`)
|
|
335
|
+
.join(", ")} from table "${table.name}"`);
|
|
336
|
+
await this.queryRunner.dropUniqueConstraints(table, compositeUniques);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
async dropOldExclusions() {
|
|
340
|
+
// Only PostgreSQL supports exclusion constraints
|
|
341
|
+
if (!(this.connection.driver.options.type === "postgres"))
|
|
342
|
+
return;
|
|
343
|
+
for (const metadata of this.entityToSyncMetadatas) {
|
|
344
|
+
const table = this.queryRunner.loadedTables.find((table) => this.getTablePath(table) === this.getTablePath(metadata));
|
|
345
|
+
if (!table)
|
|
346
|
+
continue;
|
|
347
|
+
const oldExclusions = table.exclusions.filter((tableExclusion) => {
|
|
348
|
+
return !metadata.exclusions.find((exclusionMetadata) => exclusionMetadata.name === tableExclusion.name);
|
|
349
|
+
});
|
|
350
|
+
if (oldExclusions.length === 0)
|
|
351
|
+
continue;
|
|
352
|
+
this.connection.logger.logSchemaBuild(`dropping old exclusion constraint: ${oldExclusions
|
|
353
|
+
.map((exclusion) => `"${exclusion.name}"`)
|
|
354
|
+
.join(", ")} from table "${table.name}"`);
|
|
355
|
+
await this.queryRunner.dropExclusionConstraints(table, oldExclusions);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
794
358
|
/**
|
|
795
359
|
* Creates tables that do not exist in the database yet.
|
|
796
360
|
* New tables are created without foreign and primary keys.
|
|
797
361
|
* Primary key only can be created in conclusion with auto generated column.
|
|
798
362
|
*/
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
}
|
|
825
|
-
});
|
|
826
|
-
};
|
|
827
|
-
this_7 = this;
|
|
828
|
-
_d.label = 1;
|
|
829
|
-
case 1:
|
|
830
|
-
_d.trys.push([1, 6, 7, 8]);
|
|
831
|
-
_a = tslib_1.__values(this.entityToSyncMetadatas), _b = _a.next();
|
|
832
|
-
_d.label = 2;
|
|
833
|
-
case 2:
|
|
834
|
-
if (!!_b.done) return [3 /*break*/, 5];
|
|
835
|
-
metadata = _b.value;
|
|
836
|
-
return [5 /*yield**/, _loop_7(metadata)];
|
|
837
|
-
case 3:
|
|
838
|
-
_d.sent();
|
|
839
|
-
_d.label = 4;
|
|
840
|
-
case 4:
|
|
841
|
-
_b = _a.next();
|
|
842
|
-
return [3 /*break*/, 2];
|
|
843
|
-
case 5: return [3 /*break*/, 8];
|
|
844
|
-
case 6:
|
|
845
|
-
e_7_1 = _d.sent();
|
|
846
|
-
e_7 = { error: e_7_1 };
|
|
847
|
-
return [3 /*break*/, 8];
|
|
848
|
-
case 7:
|
|
849
|
-
try {
|
|
850
|
-
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
851
|
-
}
|
|
852
|
-
finally { if (e_7) throw e_7.error; }
|
|
853
|
-
return [7 /*endfinally*/];
|
|
854
|
-
case 8: return [2 /*return*/];
|
|
855
|
-
}
|
|
363
|
+
async createNewTables() {
|
|
364
|
+
for (const metadata of this.entityToSyncMetadatas) {
|
|
365
|
+
// check if table does not exist yet
|
|
366
|
+
const existTable = this.queryRunner.loadedTables.find((table) => this.getTablePath(table) === this.getTablePath(metadata));
|
|
367
|
+
if (existTable)
|
|
368
|
+
continue;
|
|
369
|
+
this.connection.logger.logSchemaBuild(`creating a new table: ${this.getTablePath(metadata)}`);
|
|
370
|
+
// create a new table and sync it in the database
|
|
371
|
+
const table = Table_1.Table.create(metadata, this.connection.driver);
|
|
372
|
+
await this.queryRunner.createTable(table, false, false);
|
|
373
|
+
this.queryRunner.loadedTables.push(table);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
async createViews() {
|
|
377
|
+
for (const metadata of this.viewEntityToSyncMetadatas) {
|
|
378
|
+
// check if view does not exist yet
|
|
379
|
+
const existView = this.queryRunner.loadedViews.find((view) => {
|
|
380
|
+
const viewExpression = typeof view.expression === "string"
|
|
381
|
+
? view.expression.trim()
|
|
382
|
+
: view.expression(this.connection).getQuery();
|
|
383
|
+
const metadataExpression = typeof metadata.expression === "string"
|
|
384
|
+
? metadata.expression.trim()
|
|
385
|
+
: metadata.expression(this.connection).getQuery();
|
|
386
|
+
return (this.getTablePath(view) === this.getTablePath(metadata) &&
|
|
387
|
+
viewExpression === metadataExpression);
|
|
856
388
|
});
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
? view.expression.trim()
|
|
875
|
-
: view.expression(_this.connection).getQuery();
|
|
876
|
-
var metadataExpression = typeof metadata.expression === "string"
|
|
877
|
-
? metadata.expression.trim()
|
|
878
|
-
: metadata.expression(_this.connection).getQuery();
|
|
879
|
-
return (_this.getTablePath(view) === _this.getTablePath(metadata) &&
|
|
880
|
-
viewExpression === metadataExpression);
|
|
881
|
-
});
|
|
882
|
-
if (existView)
|
|
883
|
-
return [2 /*return*/, "continue"];
|
|
884
|
-
this_8.connection.logger.logSchemaBuild("creating a new view: ".concat(this_8.getTablePath(metadata)));
|
|
885
|
-
view = View_1.View.create(metadata, this_8.connection.driver);
|
|
886
|
-
return [4 /*yield*/, this_8.queryRunner.createView(view, true)];
|
|
887
|
-
case 1:
|
|
888
|
-
_e.sent();
|
|
889
|
-
this_8.queryRunner.loadedViews.push(view);
|
|
890
|
-
return [2 /*return*/];
|
|
891
|
-
}
|
|
892
|
-
});
|
|
893
|
-
};
|
|
894
|
-
this_8 = this;
|
|
895
|
-
_d.label = 1;
|
|
896
|
-
case 1:
|
|
897
|
-
_d.trys.push([1, 6, 7, 8]);
|
|
898
|
-
_a = tslib_1.__values(this.viewEntityToSyncMetadatas), _b = _a.next();
|
|
899
|
-
_d.label = 2;
|
|
900
|
-
case 2:
|
|
901
|
-
if (!!_b.done) return [3 /*break*/, 5];
|
|
902
|
-
metadata = _b.value;
|
|
903
|
-
return [5 /*yield**/, _loop_8(metadata)];
|
|
904
|
-
case 3:
|
|
905
|
-
_d.sent();
|
|
906
|
-
_d.label = 4;
|
|
907
|
-
case 4:
|
|
908
|
-
_b = _a.next();
|
|
909
|
-
return [3 /*break*/, 2];
|
|
910
|
-
case 5: return [3 /*break*/, 8];
|
|
911
|
-
case 6:
|
|
912
|
-
e_8_1 = _d.sent();
|
|
913
|
-
e_8 = { error: e_8_1 };
|
|
914
|
-
return [3 /*break*/, 8];
|
|
915
|
-
case 7:
|
|
916
|
-
try {
|
|
917
|
-
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
918
|
-
}
|
|
919
|
-
finally { if (e_8) throw e_8.error; }
|
|
920
|
-
return [7 /*endfinally*/];
|
|
921
|
-
case 8: return [2 /*return*/];
|
|
922
|
-
}
|
|
389
|
+
if (existView)
|
|
390
|
+
continue;
|
|
391
|
+
this.connection.logger.logSchemaBuild(`creating a new view: ${this.getTablePath(metadata)}`);
|
|
392
|
+
// create a new view and sync it in the database
|
|
393
|
+
const view = View_1.View.create(metadata, this.connection.driver);
|
|
394
|
+
await this.queryRunner.createView(view, true);
|
|
395
|
+
this.queryRunner.loadedViews.push(view);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
async dropOldViews() {
|
|
399
|
+
const droppedViews = [];
|
|
400
|
+
const viewEntityToSyncMetadatas = this.viewEntityToSyncMetadatas;
|
|
401
|
+
// BuIld lookup cache for finding views metadata
|
|
402
|
+
const viewToMetadata = new Map();
|
|
403
|
+
for (const view of this.queryRunner.loadedViews) {
|
|
404
|
+
const viewMetadata = viewEntityToSyncMetadatas.find((metadata) => {
|
|
405
|
+
return this.getTablePath(view) === this.getTablePath(metadata);
|
|
923
406
|
});
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
for (_c = tslib_1.__values(this.queryRunner.loadedViews), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
961
|
-
view = _d.value;
|
|
962
|
-
viewMetadata = viewToMetadata.get(view);
|
|
963
|
-
if (!viewMetadata) {
|
|
964
|
-
continue;
|
|
965
|
-
}
|
|
966
|
-
viewExpression = typeof view.expression === "string"
|
|
967
|
-
? view.expression.trim()
|
|
968
|
-
: view.expression(this.connection).getQuery();
|
|
969
|
-
metadataExpression = typeof viewMetadata.expression === "string"
|
|
970
|
-
? viewMetadata.expression.trim()
|
|
971
|
-
: viewMetadata.expression(this.connection).getQuery();
|
|
972
|
-
if (viewExpression === metadataExpression)
|
|
973
|
-
continue;
|
|
974
|
-
this.connection.logger.logSchemaBuild("dropping an old view: ".concat(view.name));
|
|
975
|
-
// Collect view to be dropped
|
|
976
|
-
droppedViews.push(view);
|
|
977
|
-
}
|
|
978
|
-
}
|
|
979
|
-
catch (e_11_1) { e_11 = { error: e_11_1 }; }
|
|
980
|
-
finally {
|
|
981
|
-
try {
|
|
982
|
-
if (_d && !_d.done && (_f = _c.return)) _f.call(_c);
|
|
983
|
-
}
|
|
984
|
-
finally { if (e_11) throw e_11.error; }
|
|
985
|
-
}
|
|
986
|
-
viewDependencyChain = function (view) {
|
|
987
|
-
var e_12, _a;
|
|
988
|
-
// Get the view metadata
|
|
989
|
-
var viewMetadata = viewToMetadata.get(view);
|
|
990
|
-
var viewWithDependencies = [view];
|
|
991
|
-
// If no metadata is known for the view, simply return the view itself
|
|
992
|
-
if (!viewMetadata) {
|
|
993
|
-
return viewWithDependencies;
|
|
994
|
-
}
|
|
995
|
-
try {
|
|
996
|
-
// Iterate over all known views
|
|
997
|
-
for (var _b = tslib_1.__values(viewToMetadata.entries()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
998
|
-
var _d = tslib_1.__read(_c.value, 2), currentView = _d[0], currentMetadata = _d[1];
|
|
999
|
-
// Ignore self reference
|
|
1000
|
-
if (currentView === view) {
|
|
1001
|
-
continue;
|
|
1002
|
-
}
|
|
1003
|
-
// If the currently iterated view depends on the passed in view
|
|
1004
|
-
if (currentMetadata.dependsOn &&
|
|
1005
|
-
(currentMetadata.dependsOn.has(viewMetadata.target) ||
|
|
1006
|
-
currentMetadata.dependsOn.has(viewMetadata.name))) {
|
|
1007
|
-
// Recursively add currently iterate view and its dependents
|
|
1008
|
-
viewWithDependencies = viewWithDependencies.concat(viewDependencyChain(currentView));
|
|
1009
|
-
}
|
|
1010
|
-
}
|
|
1011
|
-
}
|
|
1012
|
-
catch (e_12_1) { e_12 = { error: e_12_1 }; }
|
|
1013
|
-
finally {
|
|
1014
|
-
try {
|
|
1015
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
1016
|
-
}
|
|
1017
|
-
finally { if (e_12) throw e_12.error; }
|
|
1018
|
-
}
|
|
1019
|
-
// Return all collected views
|
|
1020
|
-
return viewWithDependencies;
|
|
1021
|
-
};
|
|
1022
|
-
droppedViewsWithDependencies = new Set(
|
|
1023
|
-
// Collect all dropped views, and their dependencies
|
|
1024
|
-
droppedViews
|
|
1025
|
-
.map(function (view) { return viewDependencyChain(view); })
|
|
1026
|
-
// Flattened to single Array ( can be replaced with flatMap, once supported)
|
|
1027
|
-
.reduce(function (all, segment) {
|
|
1028
|
-
return all.concat(segment);
|
|
1029
|
-
}, [])
|
|
1030
|
-
// Sort the views to be dropped in creation order
|
|
1031
|
-
.sort(function (a, b) {
|
|
1032
|
-
return ViewUtils_1.ViewUtils.viewMetadataCmp(viewToMetadata.get(a), viewToMetadata.get(b));
|
|
1033
|
-
})
|
|
1034
|
-
// reverse order to get drop order
|
|
1035
|
-
.reverse());
|
|
1036
|
-
_h.label = 1;
|
|
1037
|
-
case 1:
|
|
1038
|
-
_h.trys.push([1, 6, 7, 8]);
|
|
1039
|
-
droppedViewsWithDependencies_1 = tslib_1.__values(droppedViewsWithDependencies), droppedViewsWithDependencies_1_1 = droppedViewsWithDependencies_1.next();
|
|
1040
|
-
_h.label = 2;
|
|
1041
|
-
case 2:
|
|
1042
|
-
if (!!droppedViewsWithDependencies_1_1.done) return [3 /*break*/, 5];
|
|
1043
|
-
view = droppedViewsWithDependencies_1_1.value;
|
|
1044
|
-
return [4 /*yield*/, this.queryRunner.dropView(view)];
|
|
1045
|
-
case 3:
|
|
1046
|
-
_h.sent();
|
|
1047
|
-
_h.label = 4;
|
|
1048
|
-
case 4:
|
|
1049
|
-
droppedViewsWithDependencies_1_1 = droppedViewsWithDependencies_1.next();
|
|
1050
|
-
return [3 /*break*/, 2];
|
|
1051
|
-
case 5: return [3 /*break*/, 8];
|
|
1052
|
-
case 6:
|
|
1053
|
-
e_9_1 = _h.sent();
|
|
1054
|
-
e_9 = { error: e_9_1 };
|
|
1055
|
-
return [3 /*break*/, 8];
|
|
1056
|
-
case 7:
|
|
1057
|
-
try {
|
|
1058
|
-
if (droppedViewsWithDependencies_1_1 && !droppedViewsWithDependencies_1_1.done && (_g = droppedViewsWithDependencies_1.return)) _g.call(droppedViewsWithDependencies_1);
|
|
1059
|
-
}
|
|
1060
|
-
finally { if (e_9) throw e_9.error; }
|
|
1061
|
-
return [7 /*endfinally*/];
|
|
1062
|
-
case 8:
|
|
1063
|
-
this.queryRunner.loadedViews = this.queryRunner.loadedViews.filter(function (view) { return !droppedViewsWithDependencies.has(view); });
|
|
1064
|
-
return [2 /*return*/];
|
|
407
|
+
if (viewMetadata) {
|
|
408
|
+
viewToMetadata.set(view, viewMetadata);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
// Gather all changed view, that need a drop
|
|
412
|
+
for (const view of this.queryRunner.loadedViews) {
|
|
413
|
+
const viewMetadata = viewToMetadata.get(view);
|
|
414
|
+
if (!viewMetadata) {
|
|
415
|
+
continue;
|
|
416
|
+
}
|
|
417
|
+
const viewExpression = typeof view.expression === "string"
|
|
418
|
+
? view.expression.trim()
|
|
419
|
+
: view.expression(this.connection).getQuery();
|
|
420
|
+
const metadataExpression = typeof viewMetadata.expression === "string"
|
|
421
|
+
? viewMetadata.expression.trim()
|
|
422
|
+
: viewMetadata.expression(this.connection).getQuery();
|
|
423
|
+
if (viewExpression === metadataExpression)
|
|
424
|
+
continue;
|
|
425
|
+
this.connection.logger.logSchemaBuild(`dropping an old view: ${view.name}`);
|
|
426
|
+
// Collect view to be dropped
|
|
427
|
+
droppedViews.push(view);
|
|
428
|
+
}
|
|
429
|
+
// Helper function that for a given view, will recursively return list of the view and all views that depend on it
|
|
430
|
+
const viewDependencyChain = (view) => {
|
|
431
|
+
// Get the view metadata
|
|
432
|
+
const viewMetadata = viewToMetadata.get(view);
|
|
433
|
+
let viewWithDependencies = [view];
|
|
434
|
+
// If no metadata is known for the view, simply return the view itself
|
|
435
|
+
if (!viewMetadata) {
|
|
436
|
+
return viewWithDependencies;
|
|
437
|
+
}
|
|
438
|
+
// Iterate over all known views
|
|
439
|
+
for (const [currentView, currentMetadata,] of viewToMetadata.entries()) {
|
|
440
|
+
// Ignore self reference
|
|
441
|
+
if (currentView === view) {
|
|
442
|
+
continue;
|
|
1065
443
|
}
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
444
|
+
// If the currently iterated view depends on the passed in view
|
|
445
|
+
if (currentMetadata.dependsOn &&
|
|
446
|
+
(currentMetadata.dependsOn.has(viewMetadata.target) ||
|
|
447
|
+
currentMetadata.dependsOn.has(viewMetadata.name))) {
|
|
448
|
+
// Recursively add currently iterate view and its dependents
|
|
449
|
+
viewWithDependencies = viewWithDependencies.concat(viewDependencyChain(currentView));
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
// Return all collected views
|
|
453
|
+
return viewWithDependencies;
|
|
454
|
+
};
|
|
455
|
+
// Collect final list of views to be dropped in a Set so there are no duplicates
|
|
456
|
+
const droppedViewsWithDependencies = new Set(
|
|
457
|
+
// Collect all dropped views, and their dependencies
|
|
458
|
+
droppedViews
|
|
459
|
+
.map((view) => viewDependencyChain(view))
|
|
460
|
+
// Flattened to single Array ( can be replaced with flatMap, once supported)
|
|
461
|
+
.reduce((all, segment) => {
|
|
462
|
+
return all.concat(segment);
|
|
463
|
+
}, [])
|
|
464
|
+
// Sort the views to be dropped in creation order
|
|
465
|
+
.sort((a, b) => {
|
|
466
|
+
return ViewUtils_1.ViewUtils.viewMetadataCmp(viewToMetadata.get(a), viewToMetadata.get(b));
|
|
467
|
+
})
|
|
468
|
+
// reverse order to get drop order
|
|
469
|
+
.reverse());
|
|
470
|
+
// Finally emit all drop views
|
|
471
|
+
for (const view of droppedViewsWithDependencies) {
|
|
472
|
+
await this.queryRunner.dropView(view);
|
|
473
|
+
}
|
|
474
|
+
this.queryRunner.loadedViews = this.queryRunner.loadedViews.filter((view) => !droppedViewsWithDependencies.has(view));
|
|
475
|
+
}
|
|
1069
476
|
/**
|
|
1070
477
|
* Drops all columns that exist in the table, but does not exist in the metadata (left old).
|
|
1071
478
|
* We drop their keys too, since it should be safe.
|
|
1072
479
|
*/
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
var table, droppedTableColumns;
|
|
1083
|
-
return tslib_1.__generator(this, function (_e) {
|
|
1084
|
-
switch (_e.label) {
|
|
1085
|
-
case 0:
|
|
1086
|
-
table = this_9.queryRunner.loadedTables.find(function (table) {
|
|
1087
|
-
return _this.getTablePath(table) === _this.getTablePath(metadata);
|
|
1088
|
-
});
|
|
1089
|
-
if (!table)
|
|
1090
|
-
return [2 /*return*/, "continue"];
|
|
1091
|
-
droppedTableColumns = table.columns.filter(function (tableColumn) {
|
|
1092
|
-
return !metadata.columns.find(function (columnMetadata) {
|
|
1093
|
-
return columnMetadata.isVirtualProperty ||
|
|
1094
|
-
columnMetadata.databaseName === tableColumn.name;
|
|
1095
|
-
});
|
|
1096
|
-
});
|
|
1097
|
-
if (droppedTableColumns.length === 0)
|
|
1098
|
-
return [2 /*return*/, "continue"];
|
|
1099
|
-
this_9.connection.logger.logSchemaBuild("columns dropped in ".concat(table.name, ": ") +
|
|
1100
|
-
droppedTableColumns.map(function (column) { return column.name; }).join(", "));
|
|
1101
|
-
// drop columns from the database
|
|
1102
|
-
return [4 /*yield*/, this_9.queryRunner.dropColumns(table, droppedTableColumns)];
|
|
1103
|
-
case 1:
|
|
1104
|
-
// drop columns from the database
|
|
1105
|
-
_e.sent();
|
|
1106
|
-
return [2 /*return*/];
|
|
1107
|
-
}
|
|
1108
|
-
});
|
|
1109
|
-
};
|
|
1110
|
-
this_9 = this;
|
|
1111
|
-
_d.label = 1;
|
|
1112
|
-
case 1:
|
|
1113
|
-
_d.trys.push([1, 6, 7, 8]);
|
|
1114
|
-
_a = tslib_1.__values(this.entityToSyncMetadatas), _b = _a.next();
|
|
1115
|
-
_d.label = 2;
|
|
1116
|
-
case 2:
|
|
1117
|
-
if (!!_b.done) return [3 /*break*/, 5];
|
|
1118
|
-
metadata = _b.value;
|
|
1119
|
-
return [5 /*yield**/, _loop_10(metadata)];
|
|
1120
|
-
case 3:
|
|
1121
|
-
_d.sent();
|
|
1122
|
-
_d.label = 4;
|
|
1123
|
-
case 4:
|
|
1124
|
-
_b = _a.next();
|
|
1125
|
-
return [3 /*break*/, 2];
|
|
1126
|
-
case 5: return [3 /*break*/, 8];
|
|
1127
|
-
case 6:
|
|
1128
|
-
e_13_1 = _d.sent();
|
|
1129
|
-
e_13 = { error: e_13_1 };
|
|
1130
|
-
return [3 /*break*/, 8];
|
|
1131
|
-
case 7:
|
|
1132
|
-
try {
|
|
1133
|
-
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
1134
|
-
}
|
|
1135
|
-
finally { if (e_13) throw e_13.error; }
|
|
1136
|
-
return [7 /*endfinally*/];
|
|
1137
|
-
case 8: return [2 /*return*/];
|
|
1138
|
-
}
|
|
480
|
+
async dropRemovedColumns() {
|
|
481
|
+
for (const metadata of this.entityToSyncMetadatas) {
|
|
482
|
+
const table = this.queryRunner.loadedTables.find((table) => this.getTablePath(table) === this.getTablePath(metadata));
|
|
483
|
+
if (!table)
|
|
484
|
+
continue;
|
|
485
|
+
// find columns that exist in the database but does not exist in the metadata
|
|
486
|
+
const droppedTableColumns = table.columns.filter((tableColumn) => {
|
|
487
|
+
return !metadata.columns.find((columnMetadata) => columnMetadata.isVirtualProperty ||
|
|
488
|
+
columnMetadata.databaseName === tableColumn.name);
|
|
1139
489
|
});
|
|
1140
|
-
|
|
1141
|
-
|
|
490
|
+
if (droppedTableColumns.length === 0)
|
|
491
|
+
continue;
|
|
492
|
+
this.connection.logger.logSchemaBuild(`columns dropped in ${table.name}: ` +
|
|
493
|
+
droppedTableColumns.map((column) => column.name).join(", "));
|
|
494
|
+
// drop columns from the database
|
|
495
|
+
await this.queryRunner.dropColumns(table, droppedTableColumns);
|
|
496
|
+
}
|
|
497
|
+
}
|
|
1142
498
|
/**
|
|
1143
499
|
* Adds columns from metadata which does not exist in the table.
|
|
1144
500
|
* Columns are created without keys.
|
|
1145
501
|
*/
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
return tslib_1.__generator(this, function (_e) {
|
|
1157
|
-
switch (_e.label) {
|
|
1158
|
-
case 0:
|
|
1159
|
-
table = this_10.queryRunner.loadedTables.find(function (table) {
|
|
1160
|
-
return _this.getTablePath(table) === _this.getTablePath(metadata);
|
|
1161
|
-
});
|
|
1162
|
-
if (!table)
|
|
1163
|
-
return [2 /*return*/, "continue"];
|
|
1164
|
-
newColumnMetadatas = metadata.columns.filter(function (columnMetadata) {
|
|
1165
|
-
return (!columnMetadata.isVirtualProperty &&
|
|
1166
|
-
!table.columns.find(function (tableColumn) {
|
|
1167
|
-
return tableColumn.name ===
|
|
1168
|
-
columnMetadata.databaseName;
|
|
1169
|
-
}));
|
|
1170
|
-
});
|
|
1171
|
-
if (newColumnMetadatas.length === 0)
|
|
1172
|
-
return [2 /*return*/, "continue"];
|
|
1173
|
-
newTableColumnOptions = this_10.metadataColumnsToTableColumnOptions(newColumnMetadatas);
|
|
1174
|
-
newTableColumns = newTableColumnOptions.map(function (option) { return new TableColumn_1.TableColumn(option); });
|
|
1175
|
-
if (newTableColumns.length === 0)
|
|
1176
|
-
return [2 /*return*/, "continue"];
|
|
1177
|
-
this_10.connection.logger.logSchemaBuild("new columns added: " +
|
|
1178
|
-
newColumnMetadatas
|
|
1179
|
-
.map(function (column) { return column.databaseName; })
|
|
1180
|
-
.join(", "));
|
|
1181
|
-
return [4 /*yield*/, this_10.queryRunner.addColumns(table, newTableColumns)];
|
|
1182
|
-
case 1:
|
|
1183
|
-
_e.sent();
|
|
1184
|
-
return [2 /*return*/];
|
|
1185
|
-
}
|
|
1186
|
-
});
|
|
1187
|
-
};
|
|
1188
|
-
this_10 = this;
|
|
1189
|
-
_d.label = 1;
|
|
1190
|
-
case 1:
|
|
1191
|
-
_d.trys.push([1, 6, 7, 8]);
|
|
1192
|
-
_a = tslib_1.__values(this.entityToSyncMetadatas), _b = _a.next();
|
|
1193
|
-
_d.label = 2;
|
|
1194
|
-
case 2:
|
|
1195
|
-
if (!!_b.done) return [3 /*break*/, 5];
|
|
1196
|
-
metadata = _b.value;
|
|
1197
|
-
return [5 /*yield**/, _loop_11(metadata)];
|
|
1198
|
-
case 3:
|
|
1199
|
-
_d.sent();
|
|
1200
|
-
_d.label = 4;
|
|
1201
|
-
case 4:
|
|
1202
|
-
_b = _a.next();
|
|
1203
|
-
return [3 /*break*/, 2];
|
|
1204
|
-
case 5: return [3 /*break*/, 8];
|
|
1205
|
-
case 6:
|
|
1206
|
-
e_14_1 = _d.sent();
|
|
1207
|
-
e_14 = { error: e_14_1 };
|
|
1208
|
-
return [3 /*break*/, 8];
|
|
1209
|
-
case 7:
|
|
1210
|
-
try {
|
|
1211
|
-
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
1212
|
-
}
|
|
1213
|
-
finally { if (e_14) throw e_14.error; }
|
|
1214
|
-
return [7 /*endfinally*/];
|
|
1215
|
-
case 8: return [2 /*return*/];
|
|
1216
|
-
}
|
|
502
|
+
async addNewColumns() {
|
|
503
|
+
for (const metadata of this.entityToSyncMetadatas) {
|
|
504
|
+
const table = this.queryRunner.loadedTables.find((table) => this.getTablePath(table) === this.getTablePath(metadata));
|
|
505
|
+
if (!table)
|
|
506
|
+
continue;
|
|
507
|
+
// find which columns are new
|
|
508
|
+
const newColumnMetadatas = metadata.columns.filter((columnMetadata) => {
|
|
509
|
+
return (!columnMetadata.isVirtualProperty &&
|
|
510
|
+
!table.columns.find((tableColumn) => tableColumn.name ===
|
|
511
|
+
columnMetadata.databaseName));
|
|
1217
512
|
});
|
|
1218
|
-
|
|
1219
|
-
|
|
513
|
+
if (newColumnMetadatas.length === 0)
|
|
514
|
+
continue;
|
|
515
|
+
// create columns in the database
|
|
516
|
+
const newTableColumnOptions = this.metadataColumnsToTableColumnOptions(newColumnMetadatas);
|
|
517
|
+
const newTableColumns = newTableColumnOptions.map((option) => new TableColumn_1.TableColumn(option));
|
|
518
|
+
if (newTableColumns.length === 0)
|
|
519
|
+
continue;
|
|
520
|
+
this.connection.logger.logSchemaBuild(`new columns added: ` +
|
|
521
|
+
newColumnMetadatas
|
|
522
|
+
.map((column) => column.databaseName)
|
|
523
|
+
.join(", "));
|
|
524
|
+
await this.queryRunner.addColumns(table, newTableColumns);
|
|
525
|
+
}
|
|
526
|
+
}
|
|
1220
527
|
/**
|
|
1221
528
|
* Updates composite primary keys.
|
|
1222
529
|
*/
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
if (!table)
|
|
1240
|
-
return [2 /*return*/, "continue"];
|
|
1241
|
-
primaryMetadataColumns = metadata.columns.filter(function (column) { return column.isPrimary; });
|
|
1242
|
-
primaryTableColumns = table.columns.filter(function (column) { return column.isPrimary; });
|
|
1243
|
-
if (!(primaryTableColumns.length !== primaryMetadataColumns.length &&
|
|
1244
|
-
primaryMetadataColumns.length > 1)) return [3 /*break*/, 2];
|
|
1245
|
-
changedPrimaryColumns = primaryMetadataColumns.map(function (primaryMetadataColumn) {
|
|
1246
|
-
return new TableColumn_1.TableColumn(TableUtils_1.TableUtils.createTableColumnOptions(primaryMetadataColumn, _this.connection.driver));
|
|
1247
|
-
});
|
|
1248
|
-
return [4 /*yield*/, this_11.queryRunner.updatePrimaryKeys(table, changedPrimaryColumns)];
|
|
1249
|
-
case 1:
|
|
1250
|
-
_e.sent();
|
|
1251
|
-
_e.label = 2;
|
|
1252
|
-
case 2: return [2 /*return*/];
|
|
1253
|
-
}
|
|
1254
|
-
});
|
|
1255
|
-
};
|
|
1256
|
-
this_11 = this;
|
|
1257
|
-
_d.label = 1;
|
|
1258
|
-
case 1:
|
|
1259
|
-
_d.trys.push([1, 6, 7, 8]);
|
|
1260
|
-
_a = tslib_1.__values(this.entityToSyncMetadatas), _b = _a.next();
|
|
1261
|
-
_d.label = 2;
|
|
1262
|
-
case 2:
|
|
1263
|
-
if (!!_b.done) return [3 /*break*/, 5];
|
|
1264
|
-
metadata = _b.value;
|
|
1265
|
-
return [5 /*yield**/, _loop_12(metadata)];
|
|
1266
|
-
case 3:
|
|
1267
|
-
_d.sent();
|
|
1268
|
-
_d.label = 4;
|
|
1269
|
-
case 4:
|
|
1270
|
-
_b = _a.next();
|
|
1271
|
-
return [3 /*break*/, 2];
|
|
1272
|
-
case 5: return [3 /*break*/, 8];
|
|
1273
|
-
case 6:
|
|
1274
|
-
e_15_1 = _d.sent();
|
|
1275
|
-
e_15 = { error: e_15_1 };
|
|
1276
|
-
return [3 /*break*/, 8];
|
|
1277
|
-
case 7:
|
|
1278
|
-
try {
|
|
1279
|
-
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
1280
|
-
}
|
|
1281
|
-
finally { if (e_15) throw e_15.error; }
|
|
1282
|
-
return [7 /*endfinally*/];
|
|
1283
|
-
case 8: return [2 /*return*/];
|
|
1284
|
-
}
|
|
1285
|
-
});
|
|
1286
|
-
});
|
|
1287
|
-
};
|
|
530
|
+
async updatePrimaryKeys() {
|
|
531
|
+
for (const metadata of this.entityToSyncMetadatas) {
|
|
532
|
+
const table = this.queryRunner.loadedTables.find((table) => this.getTablePath(table) === this.getTablePath(metadata));
|
|
533
|
+
if (!table)
|
|
534
|
+
continue;
|
|
535
|
+
const primaryMetadataColumns = metadata.columns.filter((column) => column.isPrimary);
|
|
536
|
+
const primaryTableColumns = table.columns.filter((column) => column.isPrimary);
|
|
537
|
+
if (primaryTableColumns.length !== primaryMetadataColumns.length &&
|
|
538
|
+
primaryMetadataColumns.length > 1) {
|
|
539
|
+
const changedPrimaryColumns = primaryMetadataColumns.map((primaryMetadataColumn) => {
|
|
540
|
+
return new TableColumn_1.TableColumn(TableUtils_1.TableUtils.createTableColumnOptions(primaryMetadataColumn, this.connection.driver));
|
|
541
|
+
});
|
|
542
|
+
await this.queryRunner.updatePrimaryKeys(table, changedPrimaryColumns);
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
}
|
|
1288
546
|
/**
|
|
1289
547
|
* Update all exist columns which metadata has changed.
|
|
1290
548
|
* Still don't create keys. Also we don't touch foreign keys of the changed columns.
|
|
1291
549
|
*/
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
case 1:
|
|
1316
|
-
_h.trys.push([1, 6, 7, 8]);
|
|
1317
|
-
changedColumns_1 = (e_17 = void 0, tslib_1.__values(changedColumns)), changedColumns_1_1 = changedColumns_1.next();
|
|
1318
|
-
_h.label = 2;
|
|
1319
|
-
case 2:
|
|
1320
|
-
if (!!changedColumns_1_1.done) return [3 /*break*/, 5];
|
|
1321
|
-
changedColumn = changedColumns_1_1.value;
|
|
1322
|
-
return [4 /*yield*/, this_12.dropColumnReferencedForeignKeys(this_12.getTablePath(metadata), changedColumn.databaseName)];
|
|
1323
|
-
case 3:
|
|
1324
|
-
_h.sent();
|
|
1325
|
-
_h.label = 4;
|
|
1326
|
-
case 4:
|
|
1327
|
-
changedColumns_1_1 = changedColumns_1.next();
|
|
1328
|
-
return [3 /*break*/, 2];
|
|
1329
|
-
case 5: return [3 /*break*/, 8];
|
|
1330
|
-
case 6:
|
|
1331
|
-
e_17_1 = _h.sent();
|
|
1332
|
-
e_17 = { error: e_17_1 };
|
|
1333
|
-
return [3 /*break*/, 8];
|
|
1334
|
-
case 7:
|
|
1335
|
-
try {
|
|
1336
|
-
if (changedColumns_1_1 && !changedColumns_1_1.done && (_e = changedColumns_1.return)) _e.call(changedColumns_1);
|
|
1337
|
-
}
|
|
1338
|
-
finally { if (e_17) throw e_17.error; }
|
|
1339
|
-
return [7 /*endfinally*/];
|
|
1340
|
-
case 8:
|
|
1341
|
-
_h.trys.push([8, 13, 14, 15]);
|
|
1342
|
-
changedColumns_2 = (e_18 = void 0, tslib_1.__values(changedColumns)), changedColumns_2_1 = changedColumns_2.next();
|
|
1343
|
-
_h.label = 9;
|
|
1344
|
-
case 9:
|
|
1345
|
-
if (!!changedColumns_2_1.done) return [3 /*break*/, 12];
|
|
1346
|
-
changedColumn = changedColumns_2_1.value;
|
|
1347
|
-
return [4 /*yield*/, this_12.dropColumnCompositeIndices(this_12.getTablePath(metadata), changedColumn.databaseName)];
|
|
1348
|
-
case 10:
|
|
1349
|
-
_h.sent();
|
|
1350
|
-
_h.label = 11;
|
|
1351
|
-
case 11:
|
|
1352
|
-
changedColumns_2_1 = changedColumns_2.next();
|
|
1353
|
-
return [3 /*break*/, 9];
|
|
1354
|
-
case 12: return [3 /*break*/, 15];
|
|
1355
|
-
case 13:
|
|
1356
|
-
e_18_1 = _h.sent();
|
|
1357
|
-
e_18 = { error: e_18_1 };
|
|
1358
|
-
return [3 /*break*/, 15];
|
|
1359
|
-
case 14:
|
|
1360
|
-
try {
|
|
1361
|
-
if (changedColumns_2_1 && !changedColumns_2_1.done && (_f = changedColumns_2.return)) _f.call(changedColumns_2);
|
|
1362
|
-
}
|
|
1363
|
-
finally { if (e_18) throw e_18.error; }
|
|
1364
|
-
return [7 /*endfinally*/];
|
|
1365
|
-
case 15:
|
|
1366
|
-
if (!!(DriverUtils_1.DriverUtils.isMySQLFamily(this_12.connection.driver) ||
|
|
1367
|
-
this_12.connection.driver.options.type === "aurora-mysql" ||
|
|
1368
|
-
this_12.connection.driver.options.type === "spanner")) return [3 /*break*/, 23];
|
|
1369
|
-
_h.label = 16;
|
|
1370
|
-
case 16:
|
|
1371
|
-
_h.trys.push([16, 21, 22, 23]);
|
|
1372
|
-
changedColumns_3 = (e_19 = void 0, tslib_1.__values(changedColumns)), changedColumns_3_1 = changedColumns_3.next();
|
|
1373
|
-
_h.label = 17;
|
|
1374
|
-
case 17:
|
|
1375
|
-
if (!!changedColumns_3_1.done) return [3 /*break*/, 20];
|
|
1376
|
-
changedColumn = changedColumns_3_1.value;
|
|
1377
|
-
return [4 /*yield*/, this_12.dropColumnCompositeUniques(this_12.getTablePath(metadata), changedColumn.databaseName)];
|
|
1378
|
-
case 18:
|
|
1379
|
-
_h.sent();
|
|
1380
|
-
_h.label = 19;
|
|
1381
|
-
case 19:
|
|
1382
|
-
changedColumns_3_1 = changedColumns_3.next();
|
|
1383
|
-
return [3 /*break*/, 17];
|
|
1384
|
-
case 20: return [3 /*break*/, 23];
|
|
1385
|
-
case 21:
|
|
1386
|
-
e_19_1 = _h.sent();
|
|
1387
|
-
e_19 = { error: e_19_1 };
|
|
1388
|
-
return [3 /*break*/, 23];
|
|
1389
|
-
case 22:
|
|
1390
|
-
try {
|
|
1391
|
-
if (changedColumns_3_1 && !changedColumns_3_1.done && (_g = changedColumns_3.return)) _g.call(changedColumns_3);
|
|
1392
|
-
}
|
|
1393
|
-
finally { if (e_19) throw e_19.error; }
|
|
1394
|
-
return [7 /*endfinally*/];
|
|
1395
|
-
case 23:
|
|
1396
|
-
newAndOldTableColumns = changedColumns.map(function (changedColumn) {
|
|
1397
|
-
var oldTableColumn = table.columns.find(function (column) { return column.name === changedColumn.databaseName; });
|
|
1398
|
-
var newTableColumnOptions = TableUtils_1.TableUtils.createTableColumnOptions(changedColumn, _this.connection.driver);
|
|
1399
|
-
var newTableColumn = new TableColumn_1.TableColumn(newTableColumnOptions);
|
|
1400
|
-
return {
|
|
1401
|
-
oldColumn: oldTableColumn,
|
|
1402
|
-
newColumn: newTableColumn,
|
|
1403
|
-
};
|
|
1404
|
-
});
|
|
1405
|
-
if (newAndOldTableColumns.length === 0)
|
|
1406
|
-
return [2 /*return*/, "continue"];
|
|
1407
|
-
this_12.connection.logger.logSchemaBuild("columns changed in \"".concat(table.name, "\". updating: ") +
|
|
1408
|
-
changedColumns
|
|
1409
|
-
.map(function (column) { return column.databaseName; })
|
|
1410
|
-
.join(", "));
|
|
1411
|
-
return [4 /*yield*/, this_12.queryRunner.changeColumns(table, newAndOldTableColumns)];
|
|
1412
|
-
case 24:
|
|
1413
|
-
_h.sent();
|
|
1414
|
-
return [2 /*return*/];
|
|
1415
|
-
}
|
|
1416
|
-
});
|
|
1417
|
-
};
|
|
1418
|
-
this_12 = this;
|
|
1419
|
-
_d.label = 1;
|
|
1420
|
-
case 1:
|
|
1421
|
-
_d.trys.push([1, 6, 7, 8]);
|
|
1422
|
-
_a = tslib_1.__values(this.entityToSyncMetadatas), _b = _a.next();
|
|
1423
|
-
_d.label = 2;
|
|
1424
|
-
case 2:
|
|
1425
|
-
if (!!_b.done) return [3 /*break*/, 5];
|
|
1426
|
-
metadata = _b.value;
|
|
1427
|
-
return [5 /*yield**/, _loop_13(metadata)];
|
|
1428
|
-
case 3:
|
|
1429
|
-
_d.sent();
|
|
1430
|
-
_d.label = 4;
|
|
1431
|
-
case 4:
|
|
1432
|
-
_b = _a.next();
|
|
1433
|
-
return [3 /*break*/, 2];
|
|
1434
|
-
case 5: return [3 /*break*/, 8];
|
|
1435
|
-
case 6:
|
|
1436
|
-
e_16_1 = _d.sent();
|
|
1437
|
-
e_16 = { error: e_16_1 };
|
|
1438
|
-
return [3 /*break*/, 8];
|
|
1439
|
-
case 7:
|
|
1440
|
-
try {
|
|
1441
|
-
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
1442
|
-
}
|
|
1443
|
-
finally { if (e_16) throw e_16.error; }
|
|
1444
|
-
return [7 /*endfinally*/];
|
|
1445
|
-
case 8: return [2 /*return*/];
|
|
550
|
+
async updateExistColumns() {
|
|
551
|
+
for (const metadata of this.entityToSyncMetadatas) {
|
|
552
|
+
const table = this.queryRunner.loadedTables.find((table) => this.getTablePath(table) === this.getTablePath(metadata));
|
|
553
|
+
if (!table)
|
|
554
|
+
continue;
|
|
555
|
+
const changedColumns = this.connection.driver.findChangedColumns(table.columns, metadata.columns);
|
|
556
|
+
if (changedColumns.length === 0)
|
|
557
|
+
continue;
|
|
558
|
+
// drop all foreign keys that point to this column
|
|
559
|
+
for (const changedColumn of changedColumns) {
|
|
560
|
+
await this.dropColumnReferencedForeignKeys(this.getTablePath(metadata), changedColumn.databaseName);
|
|
561
|
+
}
|
|
562
|
+
// drop all composite indices related to this column
|
|
563
|
+
for (const changedColumn of changedColumns) {
|
|
564
|
+
await this.dropColumnCompositeIndices(this.getTablePath(metadata), changedColumn.databaseName);
|
|
565
|
+
}
|
|
566
|
+
// drop all composite uniques related to this column
|
|
567
|
+
// Mysql does not support unique constraints.
|
|
568
|
+
if (!(DriverUtils_1.DriverUtils.isMySQLFamily(this.connection.driver) ||
|
|
569
|
+
this.connection.driver.options.type === "aurora-mysql" ||
|
|
570
|
+
this.connection.driver.options.type === "spanner")) {
|
|
571
|
+
for (const changedColumn of changedColumns) {
|
|
572
|
+
await this.dropColumnCompositeUniques(this.getTablePath(metadata), changedColumn.databaseName);
|
|
1446
573
|
}
|
|
574
|
+
}
|
|
575
|
+
// generate a map of new/old columns
|
|
576
|
+
const newAndOldTableColumns = changedColumns.map((changedColumn) => {
|
|
577
|
+
const oldTableColumn = table.columns.find((column) => column.name === changedColumn.databaseName);
|
|
578
|
+
const newTableColumnOptions = TableUtils_1.TableUtils.createTableColumnOptions(changedColumn, this.connection.driver);
|
|
579
|
+
const newTableColumn = new TableColumn_1.TableColumn(newTableColumnOptions);
|
|
580
|
+
return {
|
|
581
|
+
oldColumn: oldTableColumn,
|
|
582
|
+
newColumn: newTableColumn,
|
|
583
|
+
};
|
|
1447
584
|
});
|
|
1448
|
-
|
|
1449
|
-
|
|
585
|
+
if (newAndOldTableColumns.length === 0)
|
|
586
|
+
continue;
|
|
587
|
+
this.connection.logger.logSchemaBuild(`columns changed in "${table.name}". updating: ` +
|
|
588
|
+
changedColumns
|
|
589
|
+
.map((column) => column.databaseName)
|
|
590
|
+
.join(", "));
|
|
591
|
+
await this.queryRunner.changeColumns(table, newAndOldTableColumns);
|
|
592
|
+
}
|
|
593
|
+
}
|
|
1450
594
|
/**
|
|
1451
595
|
* Creates composite indices which are missing in db yet.
|
|
1452
596
|
*/
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
};
|
|
1490
|
-
this_13 = this;
|
|
1491
|
-
_d.label = 1;
|
|
1492
|
-
case 1:
|
|
1493
|
-
_d.trys.push([1, 6, 7, 8]);
|
|
1494
|
-
_a = tslib_1.__values(this.entityToSyncMetadatas), _b = _a.next();
|
|
1495
|
-
_d.label = 2;
|
|
1496
|
-
case 2:
|
|
1497
|
-
if (!!_b.done) return [3 /*break*/, 5];
|
|
1498
|
-
metadata = _b.value;
|
|
1499
|
-
return [5 /*yield**/, _loop_14(metadata)];
|
|
1500
|
-
case 3:
|
|
1501
|
-
_d.sent();
|
|
1502
|
-
_d.label = 4;
|
|
1503
|
-
case 4:
|
|
1504
|
-
_b = _a.next();
|
|
1505
|
-
return [3 /*break*/, 2];
|
|
1506
|
-
case 5: return [3 /*break*/, 8];
|
|
1507
|
-
case 6:
|
|
1508
|
-
e_20_1 = _d.sent();
|
|
1509
|
-
e_20 = { error: e_20_1 };
|
|
1510
|
-
return [3 /*break*/, 8];
|
|
1511
|
-
case 7:
|
|
1512
|
-
try {
|
|
1513
|
-
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
1514
|
-
}
|
|
1515
|
-
finally { if (e_20) throw e_20.error; }
|
|
1516
|
-
return [7 /*endfinally*/];
|
|
1517
|
-
case 8: return [2 /*return*/];
|
|
1518
|
-
}
|
|
1519
|
-
});
|
|
1520
|
-
});
|
|
1521
|
-
};
|
|
1522
|
-
RdbmsSchemaBuilder.prototype.createNewChecks = function () {
|
|
1523
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1524
|
-
var _loop_15, this_14, _a, _b, metadata, e_21_1;
|
|
1525
|
-
var e_21, _c;
|
|
1526
|
-
var _this = this;
|
|
1527
|
-
return tslib_1.__generator(this, function (_d) {
|
|
1528
|
-
switch (_d.label) {
|
|
1529
|
-
case 0:
|
|
1530
|
-
// Mysql does not support check constraints
|
|
1531
|
-
if (DriverUtils_1.DriverUtils.isMySQLFamily(this.connection.driver) ||
|
|
1532
|
-
this.connection.driver.options.type === "aurora-mysql")
|
|
1533
|
-
return [2 /*return*/];
|
|
1534
|
-
_loop_15 = function (metadata) {
|
|
1535
|
-
var table, newChecks;
|
|
1536
|
-
return tslib_1.__generator(this, function (_e) {
|
|
1537
|
-
switch (_e.label) {
|
|
1538
|
-
case 0:
|
|
1539
|
-
table = this_14.queryRunner.loadedTables.find(function (table) {
|
|
1540
|
-
return _this.getTablePath(table) === _this.getTablePath(metadata);
|
|
1541
|
-
});
|
|
1542
|
-
if (!table)
|
|
1543
|
-
return [2 /*return*/, "continue"];
|
|
1544
|
-
newChecks = metadata.checks
|
|
1545
|
-
.filter(function (checkMetadata) {
|
|
1546
|
-
return !table.checks.find(function (tableCheck) {
|
|
1547
|
-
return tableCheck.name === checkMetadata.name;
|
|
1548
|
-
});
|
|
1549
|
-
})
|
|
1550
|
-
.map(function (checkMetadata) { return TableCheck_1.TableCheck.create(checkMetadata); });
|
|
1551
|
-
if (newChecks.length === 0)
|
|
1552
|
-
return [2 /*return*/, "continue"];
|
|
1553
|
-
this_14.connection.logger.logSchemaBuild("adding new check constraints: ".concat(newChecks
|
|
1554
|
-
.map(function (index) { return "\"".concat(index.name, "\""); })
|
|
1555
|
-
.join(", "), " in table \"").concat(table.name, "\""));
|
|
1556
|
-
return [4 /*yield*/, this_14.queryRunner.createCheckConstraints(table, newChecks)];
|
|
1557
|
-
case 1:
|
|
1558
|
-
_e.sent();
|
|
1559
|
-
return [2 /*return*/];
|
|
1560
|
-
}
|
|
1561
|
-
});
|
|
1562
|
-
};
|
|
1563
|
-
this_14 = this;
|
|
1564
|
-
_d.label = 1;
|
|
1565
|
-
case 1:
|
|
1566
|
-
_d.trys.push([1, 6, 7, 8]);
|
|
1567
|
-
_a = tslib_1.__values(this.entityToSyncMetadatas), _b = _a.next();
|
|
1568
|
-
_d.label = 2;
|
|
1569
|
-
case 2:
|
|
1570
|
-
if (!!_b.done) return [3 /*break*/, 5];
|
|
1571
|
-
metadata = _b.value;
|
|
1572
|
-
return [5 /*yield**/, _loop_15(metadata)];
|
|
1573
|
-
case 3:
|
|
1574
|
-
_d.sent();
|
|
1575
|
-
_d.label = 4;
|
|
1576
|
-
case 4:
|
|
1577
|
-
_b = _a.next();
|
|
1578
|
-
return [3 /*break*/, 2];
|
|
1579
|
-
case 5: return [3 /*break*/, 8];
|
|
1580
|
-
case 6:
|
|
1581
|
-
e_21_1 = _d.sent();
|
|
1582
|
-
e_21 = { error: e_21_1 };
|
|
1583
|
-
return [3 /*break*/, 8];
|
|
1584
|
-
case 7:
|
|
1585
|
-
try {
|
|
1586
|
-
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
1587
|
-
}
|
|
1588
|
-
finally { if (e_21) throw e_21.error; }
|
|
1589
|
-
return [7 /*endfinally*/];
|
|
1590
|
-
case 8: return [2 /*return*/];
|
|
1591
|
-
}
|
|
1592
|
-
});
|
|
1593
|
-
});
|
|
1594
|
-
};
|
|
597
|
+
async createNewIndices() {
|
|
598
|
+
for (const metadata of this.entityToSyncMetadatas) {
|
|
599
|
+
const table = this.queryRunner.loadedTables.find((table) => this.getTablePath(table) === this.getTablePath(metadata));
|
|
600
|
+
if (!table)
|
|
601
|
+
continue;
|
|
602
|
+
const newIndices = metadata.indices
|
|
603
|
+
.filter((indexMetadata) => !table.indices.find((tableIndex) => tableIndex.name === indexMetadata.name) && indexMetadata.synchronize === true)
|
|
604
|
+
.map((indexMetadata) => TableIndex_1.TableIndex.create(indexMetadata));
|
|
605
|
+
if (newIndices.length === 0)
|
|
606
|
+
continue;
|
|
607
|
+
this.connection.logger.logSchemaBuild(`adding new indices ${newIndices
|
|
608
|
+
.map((index) => `"${index.name}"`)
|
|
609
|
+
.join(", ")} in table "${table.name}"`);
|
|
610
|
+
await this.queryRunner.createIndices(table, newIndices);
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
async createNewChecks() {
|
|
614
|
+
// Mysql does not support check constraints
|
|
615
|
+
if (DriverUtils_1.DriverUtils.isMySQLFamily(this.connection.driver) ||
|
|
616
|
+
this.connection.driver.options.type === "aurora-mysql")
|
|
617
|
+
return;
|
|
618
|
+
for (const metadata of this.entityToSyncMetadatas) {
|
|
619
|
+
const table = this.queryRunner.loadedTables.find((table) => this.getTablePath(table) === this.getTablePath(metadata));
|
|
620
|
+
if (!table)
|
|
621
|
+
continue;
|
|
622
|
+
const newChecks = metadata.checks
|
|
623
|
+
.filter((checkMetadata) => !table.checks.find((tableCheck) => tableCheck.name === checkMetadata.name))
|
|
624
|
+
.map((checkMetadata) => TableCheck_1.TableCheck.create(checkMetadata));
|
|
625
|
+
if (newChecks.length === 0)
|
|
626
|
+
continue;
|
|
627
|
+
this.connection.logger.logSchemaBuild(`adding new check constraints: ${newChecks
|
|
628
|
+
.map((index) => `"${index.name}"`)
|
|
629
|
+
.join(", ")} in table "${table.name}"`);
|
|
630
|
+
await this.queryRunner.createCheckConstraints(table, newChecks);
|
|
631
|
+
}
|
|
632
|
+
}
|
|
1595
633
|
/**
|
|
1596
634
|
* Creates composite uniques which are missing in db yet.
|
|
1597
635
|
*/
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
return [2 /*return*/, "continue"];
|
|
1616
|
-
compositeUniques = metadata.uniques
|
|
1617
|
-
.filter(function (uniqueMetadata) {
|
|
1618
|
-
return uniqueMetadata.columns.length > 1 &&
|
|
1619
|
-
!table.uniques.find(function (tableUnique) {
|
|
1620
|
-
return tableUnique.name === uniqueMetadata.name;
|
|
1621
|
-
});
|
|
1622
|
-
})
|
|
1623
|
-
.map(function (uniqueMetadata) { return TableUnique_1.TableUnique.create(uniqueMetadata); });
|
|
1624
|
-
if (compositeUniques.length === 0)
|
|
1625
|
-
return [2 /*return*/, "continue"];
|
|
1626
|
-
this_15.connection.logger.logSchemaBuild("adding new unique constraints: ".concat(compositeUniques
|
|
1627
|
-
.map(function (unique) { return "\"".concat(unique.name, "\""); })
|
|
1628
|
-
.join(", "), " in table \"").concat(table.name, "\""));
|
|
1629
|
-
return [4 /*yield*/, this_15.queryRunner.createUniqueConstraints(table, compositeUniques)];
|
|
1630
|
-
case 1:
|
|
1631
|
-
_e.sent();
|
|
1632
|
-
return [2 /*return*/];
|
|
1633
|
-
}
|
|
1634
|
-
});
|
|
1635
|
-
};
|
|
1636
|
-
this_15 = this;
|
|
1637
|
-
_d.label = 1;
|
|
1638
|
-
case 1:
|
|
1639
|
-
_d.trys.push([1, 6, 7, 8]);
|
|
1640
|
-
_a = tslib_1.__values(this.entityToSyncMetadatas), _b = _a.next();
|
|
1641
|
-
_d.label = 2;
|
|
1642
|
-
case 2:
|
|
1643
|
-
if (!!_b.done) return [3 /*break*/, 5];
|
|
1644
|
-
metadata = _b.value;
|
|
1645
|
-
return [5 /*yield**/, _loop_16(metadata)];
|
|
1646
|
-
case 3:
|
|
1647
|
-
_d.sent();
|
|
1648
|
-
_d.label = 4;
|
|
1649
|
-
case 4:
|
|
1650
|
-
_b = _a.next();
|
|
1651
|
-
return [3 /*break*/, 2];
|
|
1652
|
-
case 5: return [3 /*break*/, 8];
|
|
1653
|
-
case 6:
|
|
1654
|
-
e_22_1 = _d.sent();
|
|
1655
|
-
e_22 = { error: e_22_1 };
|
|
1656
|
-
return [3 /*break*/, 8];
|
|
1657
|
-
case 7:
|
|
1658
|
-
try {
|
|
1659
|
-
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
1660
|
-
}
|
|
1661
|
-
finally { if (e_22) throw e_22.error; }
|
|
1662
|
-
return [7 /*endfinally*/];
|
|
1663
|
-
case 8: return [2 /*return*/];
|
|
1664
|
-
}
|
|
1665
|
-
});
|
|
1666
|
-
});
|
|
1667
|
-
};
|
|
636
|
+
async createCompositeUniqueConstraints() {
|
|
637
|
+
for (const metadata of this.entityToSyncMetadatas) {
|
|
638
|
+
const table = this.queryRunner.loadedTables.find((table) => this.getTablePath(table) === this.getTablePath(metadata));
|
|
639
|
+
if (!table)
|
|
640
|
+
continue;
|
|
641
|
+
const compositeUniques = metadata.uniques
|
|
642
|
+
.filter((uniqueMetadata) => uniqueMetadata.columns.length > 1 &&
|
|
643
|
+
!table.uniques.find((tableUnique) => tableUnique.name === uniqueMetadata.name))
|
|
644
|
+
.map((uniqueMetadata) => TableUnique_1.TableUnique.create(uniqueMetadata));
|
|
645
|
+
if (compositeUniques.length === 0)
|
|
646
|
+
continue;
|
|
647
|
+
this.connection.logger.logSchemaBuild(`adding new unique constraints: ${compositeUniques
|
|
648
|
+
.map((unique) => `"${unique.name}"`)
|
|
649
|
+
.join(", ")} in table "${table.name}"`);
|
|
650
|
+
await this.queryRunner.createUniqueConstraints(table, compositeUniques);
|
|
651
|
+
}
|
|
652
|
+
}
|
|
1668
653
|
/**
|
|
1669
654
|
* Creates exclusions which are missing in db yet.
|
|
1670
655
|
*/
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
if (!table)
|
|
1691
|
-
return [2 /*return*/, "continue"];
|
|
1692
|
-
newExclusions = metadata.exclusions
|
|
1693
|
-
.filter(function (exclusionMetadata) {
|
|
1694
|
-
return !table.exclusions.find(function (tableExclusion) {
|
|
1695
|
-
return tableExclusion.name === exclusionMetadata.name;
|
|
1696
|
-
});
|
|
1697
|
-
})
|
|
1698
|
-
.map(function (exclusionMetadata) {
|
|
1699
|
-
return TableExclusion_1.TableExclusion.create(exclusionMetadata);
|
|
1700
|
-
});
|
|
1701
|
-
if (newExclusions.length === 0)
|
|
1702
|
-
return [2 /*return*/, "continue"];
|
|
1703
|
-
this_16.connection.logger.logSchemaBuild("adding new exclusion constraints: ".concat(newExclusions
|
|
1704
|
-
.map(function (exclusion) { return "\"".concat(exclusion.name, "\""); })
|
|
1705
|
-
.join(", "), " in table \"").concat(table.name, "\""));
|
|
1706
|
-
return [4 /*yield*/, this_16.queryRunner.createExclusionConstraints(table, newExclusions)];
|
|
1707
|
-
case 1:
|
|
1708
|
-
_e.sent();
|
|
1709
|
-
return [2 /*return*/];
|
|
1710
|
-
}
|
|
1711
|
-
});
|
|
1712
|
-
};
|
|
1713
|
-
this_16 = this;
|
|
1714
|
-
_d.label = 1;
|
|
1715
|
-
case 1:
|
|
1716
|
-
_d.trys.push([1, 6, 7, 8]);
|
|
1717
|
-
_a = tslib_1.__values(this.entityToSyncMetadatas), _b = _a.next();
|
|
1718
|
-
_d.label = 2;
|
|
1719
|
-
case 2:
|
|
1720
|
-
if (!!_b.done) return [3 /*break*/, 5];
|
|
1721
|
-
metadata = _b.value;
|
|
1722
|
-
return [5 /*yield**/, _loop_17(metadata)];
|
|
1723
|
-
case 3:
|
|
1724
|
-
_d.sent();
|
|
1725
|
-
_d.label = 4;
|
|
1726
|
-
case 4:
|
|
1727
|
-
_b = _a.next();
|
|
1728
|
-
return [3 /*break*/, 2];
|
|
1729
|
-
case 5: return [3 /*break*/, 8];
|
|
1730
|
-
case 6:
|
|
1731
|
-
e_23_1 = _d.sent();
|
|
1732
|
-
e_23 = { error: e_23_1 };
|
|
1733
|
-
return [3 /*break*/, 8];
|
|
1734
|
-
case 7:
|
|
1735
|
-
try {
|
|
1736
|
-
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
1737
|
-
}
|
|
1738
|
-
finally { if (e_23) throw e_23.error; }
|
|
1739
|
-
return [7 /*endfinally*/];
|
|
1740
|
-
case 8: return [2 /*return*/];
|
|
1741
|
-
}
|
|
1742
|
-
});
|
|
1743
|
-
});
|
|
1744
|
-
};
|
|
656
|
+
async createNewExclusions() {
|
|
657
|
+
// Only PostgreSQL supports exclusion constraints
|
|
658
|
+
if (!(this.connection.driver.options.type === "postgres"))
|
|
659
|
+
return;
|
|
660
|
+
for (const metadata of this.entityToSyncMetadatas) {
|
|
661
|
+
const table = this.queryRunner.loadedTables.find((table) => this.getTablePath(table) === this.getTablePath(metadata));
|
|
662
|
+
if (!table)
|
|
663
|
+
continue;
|
|
664
|
+
const newExclusions = metadata.exclusions
|
|
665
|
+
.filter((exclusionMetadata) => !table.exclusions.find((tableExclusion) => tableExclusion.name === exclusionMetadata.name))
|
|
666
|
+
.map((exclusionMetadata) => TableExclusion_1.TableExclusion.create(exclusionMetadata));
|
|
667
|
+
if (newExclusions.length === 0)
|
|
668
|
+
continue;
|
|
669
|
+
this.connection.logger.logSchemaBuild(`adding new exclusion constraints: ${newExclusions
|
|
670
|
+
.map((exclusion) => `"${exclusion.name}"`)
|
|
671
|
+
.join(", ")} in table "${table.name}"`);
|
|
672
|
+
await this.queryRunner.createExclusionConstraints(table, newExclusions);
|
|
673
|
+
}
|
|
674
|
+
}
|
|
1745
675
|
/**
|
|
1746
676
|
* Creates foreign keys which does not exist in the table yet.
|
|
1747
677
|
*/
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
var table, newKeys, dbForeignKeys;
|
|
1758
|
-
return tslib_1.__generator(this, function (_e) {
|
|
1759
|
-
switch (_e.label) {
|
|
1760
|
-
case 0:
|
|
1761
|
-
table = this_17.queryRunner.loadedTables.find(function (table) {
|
|
1762
|
-
return _this.getTablePath(table) === _this.getTablePath(metadata);
|
|
1763
|
-
});
|
|
1764
|
-
if (!table)
|
|
1765
|
-
return [2 /*return*/, "continue"];
|
|
1766
|
-
newKeys = metadata.foreignKeys.filter(function (foreignKey) {
|
|
1767
|
-
return !table.foreignKeys.find(function (dbForeignKey) {
|
|
1768
|
-
return dbForeignKey.name === foreignKey.name &&
|
|
1769
|
-
_this.getTablePath(dbForeignKey) ===
|
|
1770
|
-
_this.getTablePath(foreignKey.referencedEntityMetadata);
|
|
1771
|
-
});
|
|
1772
|
-
});
|
|
1773
|
-
if (newKeys.length === 0)
|
|
1774
|
-
return [2 /*return*/, "continue"];
|
|
1775
|
-
dbForeignKeys = newKeys.map(function (foreignKeyMetadata) {
|
|
1776
|
-
return TableForeignKey_1.TableForeignKey.create(foreignKeyMetadata, _this.connection.driver);
|
|
1777
|
-
});
|
|
1778
|
-
this_17.connection.logger.logSchemaBuild("creating a foreign keys: ".concat(newKeys
|
|
1779
|
-
.map(function (key) { return key.name; })
|
|
1780
|
-
.join(", "), " on table \"").concat(table.name, "\""));
|
|
1781
|
-
return [4 /*yield*/, this_17.queryRunner.createForeignKeys(table, dbForeignKeys)];
|
|
1782
|
-
case 1:
|
|
1783
|
-
_e.sent();
|
|
1784
|
-
return [2 /*return*/];
|
|
1785
|
-
}
|
|
1786
|
-
});
|
|
1787
|
-
};
|
|
1788
|
-
this_17 = this;
|
|
1789
|
-
_d.label = 1;
|
|
1790
|
-
case 1:
|
|
1791
|
-
_d.trys.push([1, 6, 7, 8]);
|
|
1792
|
-
_a = tslib_1.__values(this.entityToSyncMetadatas), _b = _a.next();
|
|
1793
|
-
_d.label = 2;
|
|
1794
|
-
case 2:
|
|
1795
|
-
if (!!_b.done) return [3 /*break*/, 5];
|
|
1796
|
-
metadata = _b.value;
|
|
1797
|
-
return [5 /*yield**/, _loop_18(metadata)];
|
|
1798
|
-
case 3:
|
|
1799
|
-
_d.sent();
|
|
1800
|
-
_d.label = 4;
|
|
1801
|
-
case 4:
|
|
1802
|
-
_b = _a.next();
|
|
1803
|
-
return [3 /*break*/, 2];
|
|
1804
|
-
case 5: return [3 /*break*/, 8];
|
|
1805
|
-
case 6:
|
|
1806
|
-
e_24_1 = _d.sent();
|
|
1807
|
-
e_24 = { error: e_24_1 };
|
|
1808
|
-
return [3 /*break*/, 8];
|
|
1809
|
-
case 7:
|
|
1810
|
-
try {
|
|
1811
|
-
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
1812
|
-
}
|
|
1813
|
-
finally { if (e_24) throw e_24.error; }
|
|
1814
|
-
return [7 /*endfinally*/];
|
|
1815
|
-
case 8: return [2 /*return*/];
|
|
1816
|
-
}
|
|
678
|
+
async createForeignKeys() {
|
|
679
|
+
for (const metadata of this.entityToSyncMetadatas) {
|
|
680
|
+
const table = this.queryRunner.loadedTables.find((table) => this.getTablePath(table) === this.getTablePath(metadata));
|
|
681
|
+
if (!table)
|
|
682
|
+
continue;
|
|
683
|
+
const newKeys = metadata.foreignKeys.filter((foreignKey) => {
|
|
684
|
+
return !table.foreignKeys.find((dbForeignKey) => dbForeignKey.name === foreignKey.name &&
|
|
685
|
+
this.getTablePath(dbForeignKey) ===
|
|
686
|
+
this.getTablePath(foreignKey.referencedEntityMetadata));
|
|
1817
687
|
});
|
|
1818
|
-
|
|
1819
|
-
|
|
688
|
+
if (newKeys.length === 0)
|
|
689
|
+
continue;
|
|
690
|
+
const dbForeignKeys = newKeys.map((foreignKeyMetadata) => TableForeignKey_1.TableForeignKey.create(foreignKeyMetadata, this.connection.driver));
|
|
691
|
+
this.connection.logger.logSchemaBuild(`creating a foreign keys: ${newKeys
|
|
692
|
+
.map((key) => key.name)
|
|
693
|
+
.join(", ")} on table "${table.name}"`);
|
|
694
|
+
await this.queryRunner.createForeignKeys(table, dbForeignKeys);
|
|
695
|
+
}
|
|
696
|
+
}
|
|
1820
697
|
/**
|
|
1821
698
|
* Drops all foreign keys where given column of the given table is being used.
|
|
1822
699
|
*/
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
table.removeForeignKey(columnForeignKey);
|
|
1841
|
-
}
|
|
1842
|
-
_loop_19 = function (loadedTable) {
|
|
1843
|
-
var dependForeignKeys = loadedTable.foreignKeys.filter(function (foreignKey) {
|
|
1844
|
-
return (_this.getTablePath(foreignKey) === tablePath &&
|
|
1845
|
-
foreignKey.referencedColumnNames.indexOf(columnName) !==
|
|
1846
|
-
-1);
|
|
1847
|
-
});
|
|
1848
|
-
if (dependForeignKeys.length > 0) {
|
|
1849
|
-
var clonedTable = loadedTable.clone();
|
|
1850
|
-
clonedTable.foreignKeys = dependForeignKeys;
|
|
1851
|
-
tablesWithFK.push(clonedTable);
|
|
1852
|
-
dependForeignKeys.forEach(function (dependForeignKey) {
|
|
1853
|
-
return loadedTable.removeForeignKey(dependForeignKey);
|
|
1854
|
-
});
|
|
1855
|
-
}
|
|
1856
|
-
};
|
|
1857
|
-
try {
|
|
1858
|
-
for (_a = tslib_1.__values(this.queryRunner.loadedTables), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
1859
|
-
loadedTable = _b.value;
|
|
1860
|
-
_loop_19(loadedTable);
|
|
1861
|
-
}
|
|
1862
|
-
}
|
|
1863
|
-
catch (e_26_1) { e_26 = { error: e_26_1 }; }
|
|
1864
|
-
finally {
|
|
1865
|
-
try {
|
|
1866
|
-
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
1867
|
-
}
|
|
1868
|
-
finally { if (e_26) throw e_26.error; }
|
|
1869
|
-
}
|
|
1870
|
-
if (!(tablesWithFK.length > 0)) return [3 /*break*/, 8];
|
|
1871
|
-
_e.label = 1;
|
|
1872
|
-
case 1:
|
|
1873
|
-
_e.trys.push([1, 6, 7, 8]);
|
|
1874
|
-
tablesWithFK_1 = tslib_1.__values(tablesWithFK), tablesWithFK_1_1 = tablesWithFK_1.next();
|
|
1875
|
-
_e.label = 2;
|
|
1876
|
-
case 2:
|
|
1877
|
-
if (!!tablesWithFK_1_1.done) return [3 /*break*/, 5];
|
|
1878
|
-
tableWithFK = tablesWithFK_1_1.value;
|
|
1879
|
-
this.connection.logger.logSchemaBuild("dropping related foreign keys of ".concat(tableWithFK.name, ": ").concat(tableWithFK.foreignKeys
|
|
1880
|
-
.map(function (foreignKey) { return foreignKey.name; })
|
|
1881
|
-
.join(", ")));
|
|
1882
|
-
return [4 /*yield*/, this.queryRunner.dropForeignKeys(tableWithFK, tableWithFK.foreignKeys)];
|
|
1883
|
-
case 3:
|
|
1884
|
-
_e.sent();
|
|
1885
|
-
_e.label = 4;
|
|
1886
|
-
case 4:
|
|
1887
|
-
tablesWithFK_1_1 = tablesWithFK_1.next();
|
|
1888
|
-
return [3 /*break*/, 2];
|
|
1889
|
-
case 5: return [3 /*break*/, 8];
|
|
1890
|
-
case 6:
|
|
1891
|
-
e_25_1 = _e.sent();
|
|
1892
|
-
e_25 = { error: e_25_1 };
|
|
1893
|
-
return [3 /*break*/, 8];
|
|
1894
|
-
case 7:
|
|
1895
|
-
try {
|
|
1896
|
-
if (tablesWithFK_1_1 && !tablesWithFK_1_1.done && (_d = tablesWithFK_1.return)) _d.call(tablesWithFK_1);
|
|
1897
|
-
}
|
|
1898
|
-
finally { if (e_25) throw e_25.error; }
|
|
1899
|
-
return [7 /*endfinally*/];
|
|
1900
|
-
case 8: return [2 /*return*/];
|
|
1901
|
-
}
|
|
700
|
+
async dropColumnReferencedForeignKeys(tablePath, columnName) {
|
|
701
|
+
const table = this.queryRunner.loadedTables.find((table) => this.getTablePath(table) === tablePath);
|
|
702
|
+
if (!table)
|
|
703
|
+
return;
|
|
704
|
+
const tablesWithFK = [];
|
|
705
|
+
const columnForeignKey = table.foreignKeys.find((foreignKey) => foreignKey.columnNames.indexOf(columnName) !== -1);
|
|
706
|
+
if (columnForeignKey) {
|
|
707
|
+
const clonedTable = table.clone();
|
|
708
|
+
clonedTable.foreignKeys = [columnForeignKey];
|
|
709
|
+
tablesWithFK.push(clonedTable);
|
|
710
|
+
table.removeForeignKey(columnForeignKey);
|
|
711
|
+
}
|
|
712
|
+
for (const loadedTable of this.queryRunner.loadedTables) {
|
|
713
|
+
const dependForeignKeys = loadedTable.foreignKeys.filter((foreignKey) => {
|
|
714
|
+
return (this.getTablePath(foreignKey) === tablePath &&
|
|
715
|
+
foreignKey.referencedColumnNames.indexOf(columnName) !==
|
|
716
|
+
-1);
|
|
1902
717
|
});
|
|
1903
|
-
|
|
1904
|
-
|
|
718
|
+
if (dependForeignKeys.length > 0) {
|
|
719
|
+
const clonedTable = loadedTable.clone();
|
|
720
|
+
clonedTable.foreignKeys = dependForeignKeys;
|
|
721
|
+
tablesWithFK.push(clonedTable);
|
|
722
|
+
dependForeignKeys.forEach((dependForeignKey) => loadedTable.removeForeignKey(dependForeignKey));
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
if (tablesWithFK.length > 0) {
|
|
726
|
+
for (const tableWithFK of tablesWithFK) {
|
|
727
|
+
this.connection.logger.logSchemaBuild(`dropping related foreign keys of ${tableWithFK.name}: ${tableWithFK.foreignKeys
|
|
728
|
+
.map((foreignKey) => foreignKey.name)
|
|
729
|
+
.join(", ")}`);
|
|
730
|
+
await this.queryRunner.dropForeignKeys(tableWithFK, tableWithFK.foreignKeys);
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
}
|
|
1905
734
|
/**
|
|
1906
735
|
* Drops all composite indices, related to given column.
|
|
1907
736
|
*/
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
});
|
|
1922
|
-
if (relatedIndices.length === 0)
|
|
1923
|
-
return [2 /*return*/];
|
|
1924
|
-
this.connection.logger.logSchemaBuild("dropping related indices of \"".concat(tablePath, "\".\"").concat(columnName, "\": ").concat(relatedIndices
|
|
1925
|
-
.map(function (index) { return index.name; })
|
|
1926
|
-
.join(", ")));
|
|
1927
|
-
return [4 /*yield*/, this.queryRunner.dropIndices(table, relatedIndices)];
|
|
1928
|
-
case 1:
|
|
1929
|
-
_a.sent();
|
|
1930
|
-
return [2 /*return*/];
|
|
1931
|
-
}
|
|
1932
|
-
});
|
|
1933
|
-
});
|
|
1934
|
-
};
|
|
737
|
+
async dropColumnCompositeIndices(tablePath, columnName) {
|
|
738
|
+
const table = this.queryRunner.loadedTables.find((table) => this.getTablePath(table) === tablePath);
|
|
739
|
+
if (!table)
|
|
740
|
+
return;
|
|
741
|
+
const relatedIndices = table.indices.filter((index) => index.columnNames.length > 1 &&
|
|
742
|
+
index.columnNames.indexOf(columnName) !== -1);
|
|
743
|
+
if (relatedIndices.length === 0)
|
|
744
|
+
return;
|
|
745
|
+
this.connection.logger.logSchemaBuild(`dropping related indices of "${tablePath}"."${columnName}": ${relatedIndices
|
|
746
|
+
.map((index) => index.name)
|
|
747
|
+
.join(", ")}`);
|
|
748
|
+
await this.queryRunner.dropIndices(table, relatedIndices);
|
|
749
|
+
}
|
|
1935
750
|
/**
|
|
1936
751
|
* Drops all composite uniques, related to given column.
|
|
1937
752
|
*/
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
});
|
|
1952
|
-
if (relatedUniques.length === 0)
|
|
1953
|
-
return [2 /*return*/];
|
|
1954
|
-
this.connection.logger.logSchemaBuild("dropping related unique constraints of \"".concat(tablePath, "\".\"").concat(columnName, "\": ").concat(relatedUniques
|
|
1955
|
-
.map(function (unique) { return unique.name; })
|
|
1956
|
-
.join(", ")));
|
|
1957
|
-
return [4 /*yield*/, this.queryRunner.dropUniqueConstraints(table, relatedUniques)];
|
|
1958
|
-
case 1:
|
|
1959
|
-
_a.sent();
|
|
1960
|
-
return [2 /*return*/];
|
|
1961
|
-
}
|
|
1962
|
-
});
|
|
1963
|
-
});
|
|
1964
|
-
};
|
|
753
|
+
async dropColumnCompositeUniques(tablePath, columnName) {
|
|
754
|
+
const table = this.queryRunner.loadedTables.find((table) => this.getTablePath(table) === tablePath);
|
|
755
|
+
if (!table)
|
|
756
|
+
return;
|
|
757
|
+
const relatedUniques = table.uniques.filter((unique) => unique.columnNames.length > 1 &&
|
|
758
|
+
unique.columnNames.indexOf(columnName) !== -1);
|
|
759
|
+
if (relatedUniques.length === 0)
|
|
760
|
+
return;
|
|
761
|
+
this.connection.logger.logSchemaBuild(`dropping related unique constraints of "${tablePath}"."${columnName}": ${relatedUniques
|
|
762
|
+
.map((unique) => unique.name)
|
|
763
|
+
.join(", ")}`);
|
|
764
|
+
await this.queryRunner.dropUniqueConstraints(table, relatedUniques);
|
|
765
|
+
}
|
|
1965
766
|
/**
|
|
1966
767
|
* Creates new columns from the given column metadatas.
|
|
1967
768
|
*/
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
return TableUtils_1.TableUtils.createTableColumnOptions(columnMetadata, _this.connection.driver);
|
|
1972
|
-
});
|
|
1973
|
-
};
|
|
769
|
+
metadataColumnsToTableColumnOptions(columns) {
|
|
770
|
+
return columns.map((columnMetadata) => TableUtils_1.TableUtils.createTableColumnOptions(columnMetadata, this.connection.driver));
|
|
771
|
+
}
|
|
1974
772
|
/**
|
|
1975
773
|
* Creates typeorm service table for storing user defined Views and generate columns.
|
|
1976
774
|
*/
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
case 1:
|
|
2049
|
-
_a.sent();
|
|
2050
|
-
return [2 /*return*/];
|
|
2051
|
-
}
|
|
2052
|
-
});
|
|
2053
|
-
});
|
|
2054
|
-
};
|
|
2055
|
-
return RdbmsSchemaBuilder;
|
|
2056
|
-
}());
|
|
775
|
+
async createTypeormMetadataTable(queryRunner) {
|
|
776
|
+
const schema = this.currentSchema;
|
|
777
|
+
const database = this.currentDatabase;
|
|
778
|
+
const typeormMetadataTable = this.connection.driver.buildTableName(this.connection.metadataTableName, schema, database);
|
|
779
|
+
// Spanner requires at least one primary key in a table.
|
|
780
|
+
// Since we don't have unique column in "typeorm_metadata" table
|
|
781
|
+
// and we should avoid breaking changes, we mark all columns as primary for Spanner driver.
|
|
782
|
+
const isPrimary = this.connection.driver.options.type === "spanner";
|
|
783
|
+
await queryRunner.createTable(new Table_1.Table({
|
|
784
|
+
database: database,
|
|
785
|
+
schema: schema,
|
|
786
|
+
name: typeormMetadataTable,
|
|
787
|
+
columns: [
|
|
788
|
+
{
|
|
789
|
+
name: "type",
|
|
790
|
+
type: this.connection.driver.normalizeType({
|
|
791
|
+
type: this.connection.driver.mappedDataTypes
|
|
792
|
+
.metadataType,
|
|
793
|
+
}),
|
|
794
|
+
isNullable: false,
|
|
795
|
+
isPrimary,
|
|
796
|
+
},
|
|
797
|
+
{
|
|
798
|
+
name: "database",
|
|
799
|
+
type: this.connection.driver.normalizeType({
|
|
800
|
+
type: this.connection.driver.mappedDataTypes
|
|
801
|
+
.metadataDatabase,
|
|
802
|
+
}),
|
|
803
|
+
isNullable: true,
|
|
804
|
+
isPrimary,
|
|
805
|
+
},
|
|
806
|
+
{
|
|
807
|
+
name: "schema",
|
|
808
|
+
type: this.connection.driver.normalizeType({
|
|
809
|
+
type: this.connection.driver.mappedDataTypes
|
|
810
|
+
.metadataSchema,
|
|
811
|
+
}),
|
|
812
|
+
isNullable: true,
|
|
813
|
+
isPrimary,
|
|
814
|
+
},
|
|
815
|
+
{
|
|
816
|
+
name: "table",
|
|
817
|
+
type: this.connection.driver.normalizeType({
|
|
818
|
+
type: this.connection.driver.mappedDataTypes
|
|
819
|
+
.metadataTable,
|
|
820
|
+
}),
|
|
821
|
+
isNullable: true,
|
|
822
|
+
isPrimary,
|
|
823
|
+
},
|
|
824
|
+
{
|
|
825
|
+
name: "name",
|
|
826
|
+
type: this.connection.driver.normalizeType({
|
|
827
|
+
type: this.connection.driver.mappedDataTypes
|
|
828
|
+
.metadataName,
|
|
829
|
+
}),
|
|
830
|
+
isNullable: true,
|
|
831
|
+
isPrimary,
|
|
832
|
+
},
|
|
833
|
+
{
|
|
834
|
+
name: "value",
|
|
835
|
+
type: this.connection.driver.normalizeType({
|
|
836
|
+
type: this.connection.driver.mappedDataTypes
|
|
837
|
+
.metadataValue,
|
|
838
|
+
}),
|
|
839
|
+
isNullable: true,
|
|
840
|
+
isPrimary,
|
|
841
|
+
},
|
|
842
|
+
],
|
|
843
|
+
}), true);
|
|
844
|
+
}
|
|
845
|
+
}
|
|
2057
846
|
exports.RdbmsSchemaBuilder = RdbmsSchemaBuilder;
|
|
2058
847
|
//# sourceMappingURL=RdbmsSchemaBuilder.js.map
|