typeorm 0.2.39-dev.cf281ef → 0.2.39-dev.ef33cf4
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/README.md +36 -36
- package/browser/decorator/entity-view/ViewEntity.js +1 -0
- package/browser/decorator/entity-view/ViewEntity.js.map +1 -1
- package/browser/decorator/options/ViewEntityOptions.d.ts +5 -0
- package/browser/decorator/options/ViewEntityOptions.js.map +1 -1
- package/browser/metadata/EntityMetadata.d.ts +5 -0
- package/browser/metadata/EntityMetadata.js +1 -0
- package/browser/metadata/EntityMetadata.js.map +1 -1
- package/browser/metadata-args/TableMetadataArgs.d.ts +4 -0
- package/browser/metadata-args/TableMetadataArgs.js.map +1 -1
- package/browser/migration/MigrationExecutor.js +4 -0
- package/browser/migration/MigrationExecutor.js.map +1 -1
- package/browser/query-builder/transformer/RawSqlResultsToEntityTransformer.js +2 -8
- package/browser/query-builder/transformer/RawSqlResultsToEntityTransformer.js.map +1 -1
- package/browser/schema-builder/RdbmsSchemaBuilder.js +223 -148
- package/browser/schema-builder/RdbmsSchemaBuilder.js.map +1 -1
- package/browser/schema-builder/util/ViewUtils.d.ts +7 -0
- package/browser/schema-builder/util/ViewUtils.js +25 -0
- package/browser/schema-builder/util/ViewUtils.js.map +1 -0
- package/decorator/entity-view/ViewEntity.js +1 -0
- package/decorator/entity-view/ViewEntity.js.map +1 -1
- package/decorator/options/ViewEntityOptions.d.ts +5 -0
- package/decorator/options/ViewEntityOptions.js.map +1 -1
- package/metadata/EntityMetadata.d.ts +5 -0
- package/metadata/EntityMetadata.js +1 -0
- package/metadata/EntityMetadata.js.map +1 -1
- package/metadata-args/TableMetadataArgs.d.ts +4 -0
- package/metadata-args/TableMetadataArgs.js.map +1 -1
- package/migration/MigrationExecutor.js +4 -0
- package/migration/MigrationExecutor.js.map +1 -1
- package/package.json +1 -1
- package/query-builder/transformer/RawSqlResultsToEntityTransformer.js +2 -8
- package/query-builder/transformer/RawSqlResultsToEntityTransformer.js.map +1 -1
- package/schema-builder/RdbmsSchemaBuilder.js +222 -147
- package/schema-builder/RdbmsSchemaBuilder.js.map +1 -1
- package/schema-builder/util/ViewUtils.d.ts +7 -0
- package/schema-builder/util/ViewUtils.js +28 -0
- package/schema-builder/util/ViewUtils.js.map +1 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __awaiter, __generator, __values } from "tslib";
|
|
1
|
+
import { __awaiter, __generator, __read, __values } from "tslib";
|
|
2
2
|
import { CockroachDriver } from "../driver/cockroachdb/CockroachDriver";
|
|
3
3
|
import { Table } from "./table/Table";
|
|
4
4
|
import { TableColumn } from "./table/TableColumn";
|
|
@@ -11,6 +11,7 @@ import { TableUnique } from "./table/TableUnique";
|
|
|
11
11
|
import { TableCheck } from "./table/TableCheck";
|
|
12
12
|
import { TableExclusion } from "./table/TableExclusion";
|
|
13
13
|
import { View } from "./view/View";
|
|
14
|
+
import { ViewUtils } from "./util/ViewUtils";
|
|
14
15
|
import { AuroraDataApiDriver } from "../driver/aurora-data-api/AuroraDataApiDriver";
|
|
15
16
|
/**
|
|
16
17
|
* Creates complete tables schemas in the database based on the entity metadatas.
|
|
@@ -180,7 +181,10 @@ var RdbmsSchemaBuilder = /** @class */ (function () {
|
|
|
180
181
|
* Returns only entities that should be synced in the database.
|
|
181
182
|
*/
|
|
182
183
|
get: function () {
|
|
183
|
-
return this.connection.entityMetadatas
|
|
184
|
+
return this.connection.entityMetadatas
|
|
185
|
+
.filter(function (metadata) { return metadata.tableType === "view" && metadata.synchronize; })
|
|
186
|
+
// sort views in creation order by dependencies
|
|
187
|
+
.sort(ViewUtils.viewMetadataCmp);
|
|
184
188
|
},
|
|
185
189
|
enumerable: false,
|
|
186
190
|
configurable: true
|
|
@@ -824,65 +828,136 @@ var RdbmsSchemaBuilder = /** @class */ (function () {
|
|
|
824
828
|
};
|
|
825
829
|
RdbmsSchemaBuilder.prototype.dropOldViews = function () {
|
|
826
830
|
return __awaiter(this, void 0, void 0, function () {
|
|
827
|
-
var droppedViews,
|
|
828
|
-
var e_9,
|
|
831
|
+
var droppedViews, viewEntityToSyncMetadatas, viewToMetadata, _loop_9, _a, _b, view, _c, _d, view, viewMetadata, viewExpression, metadataExpression, viewDependencyChain, droppedViewsWithDependencies, droppedViewsWithDependencies_1, droppedViewsWithDependencies_1_1, view, e_9_1;
|
|
832
|
+
var e_10, _e, e_11, _f, e_9, _g;
|
|
829
833
|
var _this = this;
|
|
830
|
-
return __generator(this, function (
|
|
831
|
-
switch (
|
|
834
|
+
return __generator(this, function (_h) {
|
|
835
|
+
switch (_h.label) {
|
|
832
836
|
case 0:
|
|
833
|
-
droppedViews =
|
|
837
|
+
droppedViews = [];
|
|
838
|
+
viewEntityToSyncMetadatas = this.viewEntityToSyncMetadatas;
|
|
839
|
+
viewToMetadata = new Map();
|
|
834
840
|
_loop_9 = function (view) {
|
|
835
|
-
var
|
|
836
|
-
|
|
837
|
-
switch (_e.label) {
|
|
838
|
-
case 0:
|
|
839
|
-
existViewMetadata = this_9.viewEntityToSyncMetadatas.find(function (metadata) {
|
|
840
|
-
var viewExpression = typeof view.expression === "string" ? view.expression.trim() : view.expression(_this.connection).getQuery();
|
|
841
|
-
var metadataExpression = typeof metadata.expression === "string" ? metadata.expression.trim() : metadata.expression(_this.connection).getQuery();
|
|
842
|
-
return _this.getTablePath(view) === _this.getTablePath(metadata) && viewExpression === metadataExpression;
|
|
843
|
-
});
|
|
844
|
-
if (existViewMetadata)
|
|
845
|
-
return [2 /*return*/, "continue"];
|
|
846
|
-
this_9.connection.logger.logSchemaBuild("dropping an old view: " + view.name);
|
|
847
|
-
// drop an old view
|
|
848
|
-
return [4 /*yield*/, this_9.queryRunner.dropView(view)];
|
|
849
|
-
case 1:
|
|
850
|
-
// drop an old view
|
|
851
|
-
_e.sent();
|
|
852
|
-
droppedViews.add(view);
|
|
853
|
-
return [2 /*return*/];
|
|
854
|
-
}
|
|
841
|
+
var viewMetadata = viewEntityToSyncMetadatas.find(function (metadata) {
|
|
842
|
+
return _this.getTablePath(view) === _this.getTablePath(metadata);
|
|
855
843
|
});
|
|
844
|
+
if (viewMetadata) {
|
|
845
|
+
viewToMetadata.set(view, viewMetadata);
|
|
846
|
+
}
|
|
856
847
|
};
|
|
857
|
-
|
|
858
|
-
|
|
848
|
+
try {
|
|
849
|
+
for (_a = __values(this.queryRunner.loadedViews), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
850
|
+
view = _b.value;
|
|
851
|
+
_loop_9(view);
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
catch (e_10_1) { e_10 = { error: e_10_1 }; }
|
|
855
|
+
finally {
|
|
856
|
+
try {
|
|
857
|
+
if (_b && !_b.done && (_e = _a.return)) _e.call(_a);
|
|
858
|
+
}
|
|
859
|
+
finally { if (e_10) throw e_10.error; }
|
|
860
|
+
}
|
|
861
|
+
try {
|
|
862
|
+
// Gather all changed view, that need a drop
|
|
863
|
+
for (_c = __values(this.queryRunner.loadedViews), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
864
|
+
view = _d.value;
|
|
865
|
+
viewMetadata = viewToMetadata.get(view);
|
|
866
|
+
if (!viewMetadata) {
|
|
867
|
+
continue;
|
|
868
|
+
}
|
|
869
|
+
viewExpression = typeof view.expression === "string" ? view.expression.trim() : view.expression(this.connection).getQuery();
|
|
870
|
+
metadataExpression = typeof viewMetadata.expression === "string" ? viewMetadata.expression.trim() : viewMetadata.expression(this.connection).getQuery();
|
|
871
|
+
if (viewExpression === metadataExpression)
|
|
872
|
+
continue;
|
|
873
|
+
this.connection.logger.logSchemaBuild("dropping an old view: " + view.name);
|
|
874
|
+
// Collect view to be dropped
|
|
875
|
+
droppedViews.push(view);
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
catch (e_11_1) { e_11 = { error: e_11_1 }; }
|
|
879
|
+
finally {
|
|
880
|
+
try {
|
|
881
|
+
if (_d && !_d.done && (_f = _c.return)) _f.call(_c);
|
|
882
|
+
}
|
|
883
|
+
finally { if (e_11) throw e_11.error; }
|
|
884
|
+
}
|
|
885
|
+
viewDependencyChain = function (view) {
|
|
886
|
+
var e_12, _a;
|
|
887
|
+
// Get the view metadata
|
|
888
|
+
var viewMetadata = viewToMetadata.get(view);
|
|
889
|
+
var viewWithDependencies = [view];
|
|
890
|
+
// If no metadata is known for the view, simply return the view itself
|
|
891
|
+
if (!viewMetadata) {
|
|
892
|
+
return viewWithDependencies;
|
|
893
|
+
}
|
|
894
|
+
try {
|
|
895
|
+
// Iterate over all known views
|
|
896
|
+
for (var _b = __values(viewToMetadata.entries()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
897
|
+
var _d = __read(_c.value, 2), currentView = _d[0], currentMetadata = _d[1];
|
|
898
|
+
// Ignore self reference
|
|
899
|
+
if (currentView === view) {
|
|
900
|
+
continue;
|
|
901
|
+
}
|
|
902
|
+
// If the currently iterated view depends on the passed in view
|
|
903
|
+
if (currentMetadata.dependsOn && (currentMetadata.dependsOn.has(viewMetadata.target) ||
|
|
904
|
+
currentMetadata.dependsOn.has(viewMetadata.name))) {
|
|
905
|
+
// Recursively add currently iterate view and its dependents
|
|
906
|
+
viewWithDependencies = viewWithDependencies.concat(viewDependencyChain(currentView));
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
catch (e_12_1) { e_12 = { error: e_12_1 }; }
|
|
911
|
+
finally {
|
|
912
|
+
try {
|
|
913
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
914
|
+
}
|
|
915
|
+
finally { if (e_12) throw e_12.error; }
|
|
916
|
+
}
|
|
917
|
+
// Return all collected views
|
|
918
|
+
return viewWithDependencies;
|
|
919
|
+
};
|
|
920
|
+
droppedViewsWithDependencies = new Set(
|
|
921
|
+
// Collect all dropped views, and their dependencies
|
|
922
|
+
droppedViews.map(function (view) { return viewDependencyChain(view); })
|
|
923
|
+
// Flattened to single Array ( can be replaced with flatMap, once supported)
|
|
924
|
+
.reduce(function (all, segment) {
|
|
925
|
+
return all.concat(segment);
|
|
926
|
+
}, [])
|
|
927
|
+
// Sort the views to be dropped in creation order
|
|
928
|
+
.sort(function (a, b) {
|
|
929
|
+
return ViewUtils.viewMetadataCmp(viewToMetadata.get(a), viewToMetadata.get(b));
|
|
930
|
+
})
|
|
931
|
+
// reverse order to get drop order
|
|
932
|
+
.reverse());
|
|
933
|
+
_h.label = 1;
|
|
859
934
|
case 1:
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
935
|
+
_h.trys.push([1, 6, 7, 8]);
|
|
936
|
+
droppedViewsWithDependencies_1 = __values(droppedViewsWithDependencies), droppedViewsWithDependencies_1_1 = droppedViewsWithDependencies_1.next();
|
|
937
|
+
_h.label = 2;
|
|
863
938
|
case 2:
|
|
864
|
-
if (!!
|
|
865
|
-
view =
|
|
866
|
-
return [
|
|
939
|
+
if (!!droppedViewsWithDependencies_1_1.done) return [3 /*break*/, 5];
|
|
940
|
+
view = droppedViewsWithDependencies_1_1.value;
|
|
941
|
+
return [4 /*yield*/, this.queryRunner.dropView(view)];
|
|
867
942
|
case 3:
|
|
868
|
-
|
|
869
|
-
|
|
943
|
+
_h.sent();
|
|
944
|
+
_h.label = 4;
|
|
870
945
|
case 4:
|
|
871
|
-
|
|
946
|
+
droppedViewsWithDependencies_1_1 = droppedViewsWithDependencies_1.next();
|
|
872
947
|
return [3 /*break*/, 2];
|
|
873
948
|
case 5: return [3 /*break*/, 8];
|
|
874
949
|
case 6:
|
|
875
|
-
e_9_1 =
|
|
950
|
+
e_9_1 = _h.sent();
|
|
876
951
|
e_9 = { error: e_9_1 };
|
|
877
952
|
return [3 /*break*/, 8];
|
|
878
953
|
case 7:
|
|
879
954
|
try {
|
|
880
|
-
if (
|
|
955
|
+
if (droppedViewsWithDependencies_1_1 && !droppedViewsWithDependencies_1_1.done && (_g = droppedViewsWithDependencies_1.return)) _g.call(droppedViewsWithDependencies_1);
|
|
881
956
|
}
|
|
882
957
|
finally { if (e_9) throw e_9.error; }
|
|
883
958
|
return [7 /*endfinally*/];
|
|
884
959
|
case 8:
|
|
885
|
-
this.queryRunner.loadedViews = this.queryRunner.loadedViews.filter(function (view) { return !
|
|
960
|
+
this.queryRunner.loadedViews = this.queryRunner.loadedViews.filter(function (view) { return !droppedViewsWithDependencies.has(view); });
|
|
886
961
|
return [2 /*return*/];
|
|
887
962
|
}
|
|
888
963
|
});
|
|
@@ -894,8 +969,8 @@ var RdbmsSchemaBuilder = /** @class */ (function () {
|
|
|
894
969
|
*/
|
|
895
970
|
RdbmsSchemaBuilder.prototype.dropRemovedColumns = function () {
|
|
896
971
|
return __awaiter(this, void 0, void 0, function () {
|
|
897
|
-
var _loop_10,
|
|
898
|
-
var
|
|
972
|
+
var _loop_10, this_9, _a, _b, metadata, e_13_1;
|
|
973
|
+
var e_13, _c;
|
|
899
974
|
var _this = this;
|
|
900
975
|
return __generator(this, function (_d) {
|
|
901
976
|
switch (_d.label) {
|
|
@@ -905,7 +980,7 @@ var RdbmsSchemaBuilder = /** @class */ (function () {
|
|
|
905
980
|
return __generator(this, function (_e) {
|
|
906
981
|
switch (_e.label) {
|
|
907
982
|
case 0:
|
|
908
|
-
table =
|
|
983
|
+
table = this_9.queryRunner.loadedTables.find(function (table) { return _this.getTablePath(table) === _this.getTablePath(metadata); });
|
|
909
984
|
if (!table)
|
|
910
985
|
return [2 /*return*/, "continue"];
|
|
911
986
|
droppedTableColumns = table.columns.filter(function (tableColumn) {
|
|
@@ -913,9 +988,9 @@ var RdbmsSchemaBuilder = /** @class */ (function () {
|
|
|
913
988
|
});
|
|
914
989
|
if (droppedTableColumns.length === 0)
|
|
915
990
|
return [2 /*return*/, "continue"];
|
|
916
|
-
|
|
991
|
+
this_9.connection.logger.logSchemaBuild("columns dropped in " + table.name + ": " + droppedTableColumns.map(function (column) { return column.name; }).join(", "));
|
|
917
992
|
// drop columns from the database
|
|
918
|
-
return [4 /*yield*/,
|
|
993
|
+
return [4 /*yield*/, this_9.queryRunner.dropColumns(table, droppedTableColumns)];
|
|
919
994
|
case 1:
|
|
920
995
|
// drop columns from the database
|
|
921
996
|
_e.sent();
|
|
@@ -923,7 +998,7 @@ var RdbmsSchemaBuilder = /** @class */ (function () {
|
|
|
923
998
|
}
|
|
924
999
|
});
|
|
925
1000
|
};
|
|
926
|
-
|
|
1001
|
+
this_9 = this;
|
|
927
1002
|
_d.label = 1;
|
|
928
1003
|
case 1:
|
|
929
1004
|
_d.trys.push([1, 6, 7, 8]);
|
|
@@ -941,14 +1016,14 @@ var RdbmsSchemaBuilder = /** @class */ (function () {
|
|
|
941
1016
|
return [3 /*break*/, 2];
|
|
942
1017
|
case 5: return [3 /*break*/, 8];
|
|
943
1018
|
case 6:
|
|
944
|
-
|
|
945
|
-
|
|
1019
|
+
e_13_1 = _d.sent();
|
|
1020
|
+
e_13 = { error: e_13_1 };
|
|
946
1021
|
return [3 /*break*/, 8];
|
|
947
1022
|
case 7:
|
|
948
1023
|
try {
|
|
949
1024
|
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
950
1025
|
}
|
|
951
|
-
finally { if (
|
|
1026
|
+
finally { if (e_13) throw e_13.error; }
|
|
952
1027
|
return [7 /*endfinally*/];
|
|
953
1028
|
case 8: return [2 /*return*/];
|
|
954
1029
|
}
|
|
@@ -961,8 +1036,8 @@ var RdbmsSchemaBuilder = /** @class */ (function () {
|
|
|
961
1036
|
*/
|
|
962
1037
|
RdbmsSchemaBuilder.prototype.addNewColumns = function () {
|
|
963
1038
|
return __awaiter(this, void 0, void 0, function () {
|
|
964
|
-
var _loop_11,
|
|
965
|
-
var
|
|
1039
|
+
var _loop_11, this_10, _a, _b, metadata, e_14_1;
|
|
1040
|
+
var e_14, _c;
|
|
966
1041
|
var _this = this;
|
|
967
1042
|
return __generator(this, function (_d) {
|
|
968
1043
|
switch (_d.label) {
|
|
@@ -972,7 +1047,7 @@ var RdbmsSchemaBuilder = /** @class */ (function () {
|
|
|
972
1047
|
return __generator(this, function (_e) {
|
|
973
1048
|
switch (_e.label) {
|
|
974
1049
|
case 0:
|
|
975
|
-
table =
|
|
1050
|
+
table = this_10.queryRunner.loadedTables.find(function (table) { return _this.getTablePath(table) === _this.getTablePath(metadata); });
|
|
976
1051
|
if (!table)
|
|
977
1052
|
return [2 /*return*/, "continue"];
|
|
978
1053
|
newColumnMetadatas = metadata.columns.filter(function (columnMetadata) {
|
|
@@ -980,19 +1055,19 @@ var RdbmsSchemaBuilder = /** @class */ (function () {
|
|
|
980
1055
|
});
|
|
981
1056
|
if (newColumnMetadatas.length === 0)
|
|
982
1057
|
return [2 /*return*/, "continue"];
|
|
983
|
-
newTableColumnOptions =
|
|
1058
|
+
newTableColumnOptions = this_10.metadataColumnsToTableColumnOptions(newColumnMetadatas);
|
|
984
1059
|
newTableColumns = newTableColumnOptions.map(function (option) { return new TableColumn(option); });
|
|
985
1060
|
if (newTableColumns.length === 0)
|
|
986
1061
|
return [2 /*return*/, "continue"];
|
|
987
|
-
|
|
988
|
-
return [4 /*yield*/,
|
|
1062
|
+
this_10.connection.logger.logSchemaBuild("new columns added: " + newColumnMetadatas.map(function (column) { return column.databaseName; }).join(", "));
|
|
1063
|
+
return [4 /*yield*/, this_10.queryRunner.addColumns(table, newTableColumns)];
|
|
989
1064
|
case 1:
|
|
990
1065
|
_e.sent();
|
|
991
1066
|
return [2 /*return*/];
|
|
992
1067
|
}
|
|
993
1068
|
});
|
|
994
1069
|
};
|
|
995
|
-
|
|
1070
|
+
this_10 = this;
|
|
996
1071
|
_d.label = 1;
|
|
997
1072
|
case 1:
|
|
998
1073
|
_d.trys.push([1, 6, 7, 8]);
|
|
@@ -1010,14 +1085,14 @@ var RdbmsSchemaBuilder = /** @class */ (function () {
|
|
|
1010
1085
|
return [3 /*break*/, 2];
|
|
1011
1086
|
case 5: return [3 /*break*/, 8];
|
|
1012
1087
|
case 6:
|
|
1013
|
-
|
|
1014
|
-
|
|
1088
|
+
e_14_1 = _d.sent();
|
|
1089
|
+
e_14 = { error: e_14_1 };
|
|
1015
1090
|
return [3 /*break*/, 8];
|
|
1016
1091
|
case 7:
|
|
1017
1092
|
try {
|
|
1018
1093
|
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
1019
1094
|
}
|
|
1020
|
-
finally { if (
|
|
1095
|
+
finally { if (e_14) throw e_14.error; }
|
|
1021
1096
|
return [7 /*endfinally*/];
|
|
1022
1097
|
case 8: return [2 /*return*/];
|
|
1023
1098
|
}
|
|
@@ -1029,8 +1104,8 @@ var RdbmsSchemaBuilder = /** @class */ (function () {
|
|
|
1029
1104
|
*/
|
|
1030
1105
|
RdbmsSchemaBuilder.prototype.updatePrimaryKeys = function () {
|
|
1031
1106
|
return __awaiter(this, void 0, void 0, function () {
|
|
1032
|
-
var _loop_12,
|
|
1033
|
-
var
|
|
1107
|
+
var _loop_12, this_11, _a, _b, metadata, e_15_1;
|
|
1108
|
+
var e_15, _c;
|
|
1034
1109
|
var _this = this;
|
|
1035
1110
|
return __generator(this, function (_d) {
|
|
1036
1111
|
switch (_d.label) {
|
|
@@ -1040,7 +1115,7 @@ var RdbmsSchemaBuilder = /** @class */ (function () {
|
|
|
1040
1115
|
return __generator(this, function (_e) {
|
|
1041
1116
|
switch (_e.label) {
|
|
1042
1117
|
case 0:
|
|
1043
|
-
table =
|
|
1118
|
+
table = this_11.queryRunner.loadedTables.find(function (table) { return _this.getTablePath(table) === _this.getTablePath(metadata); });
|
|
1044
1119
|
if (!table)
|
|
1045
1120
|
return [2 /*return*/, "continue"];
|
|
1046
1121
|
primaryMetadataColumns = metadata.columns.filter(function (column) { return column.isPrimary; });
|
|
@@ -1049,7 +1124,7 @@ var RdbmsSchemaBuilder = /** @class */ (function () {
|
|
|
1049
1124
|
changedPrimaryColumns = primaryMetadataColumns.map(function (primaryMetadataColumn) {
|
|
1050
1125
|
return new TableColumn(TableUtils.createTableColumnOptions(primaryMetadataColumn, _this.connection.driver));
|
|
1051
1126
|
});
|
|
1052
|
-
return [4 /*yield*/,
|
|
1127
|
+
return [4 /*yield*/, this_11.queryRunner.updatePrimaryKeys(table, changedPrimaryColumns)];
|
|
1053
1128
|
case 1:
|
|
1054
1129
|
_e.sent();
|
|
1055
1130
|
_e.label = 2;
|
|
@@ -1057,7 +1132,7 @@ var RdbmsSchemaBuilder = /** @class */ (function () {
|
|
|
1057
1132
|
}
|
|
1058
1133
|
});
|
|
1059
1134
|
};
|
|
1060
|
-
|
|
1135
|
+
this_11 = this;
|
|
1061
1136
|
_d.label = 1;
|
|
1062
1137
|
case 1:
|
|
1063
1138
|
_d.trys.push([1, 6, 7, 8]);
|
|
@@ -1075,14 +1150,14 @@ var RdbmsSchemaBuilder = /** @class */ (function () {
|
|
|
1075
1150
|
return [3 /*break*/, 2];
|
|
1076
1151
|
case 5: return [3 /*break*/, 8];
|
|
1077
1152
|
case 6:
|
|
1078
|
-
|
|
1079
|
-
|
|
1153
|
+
e_15_1 = _d.sent();
|
|
1154
|
+
e_15 = { error: e_15_1 };
|
|
1080
1155
|
return [3 /*break*/, 8];
|
|
1081
1156
|
case 7:
|
|
1082
1157
|
try {
|
|
1083
1158
|
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
1084
1159
|
}
|
|
1085
|
-
finally { if (
|
|
1160
|
+
finally { if (e_15) throw e_15.error; }
|
|
1086
1161
|
return [7 /*endfinally*/];
|
|
1087
1162
|
case 8: return [2 /*return*/];
|
|
1088
1163
|
}
|
|
@@ -1095,33 +1170,33 @@ var RdbmsSchemaBuilder = /** @class */ (function () {
|
|
|
1095
1170
|
*/
|
|
1096
1171
|
RdbmsSchemaBuilder.prototype.updateExistColumns = function () {
|
|
1097
1172
|
return __awaiter(this, void 0, void 0, function () {
|
|
1098
|
-
var _loop_13,
|
|
1099
|
-
var
|
|
1173
|
+
var _loop_13, this_12, _a, _b, metadata, e_16_1;
|
|
1174
|
+
var e_16, _c;
|
|
1100
1175
|
var _this = this;
|
|
1101
1176
|
return __generator(this, function (_d) {
|
|
1102
1177
|
switch (_d.label) {
|
|
1103
1178
|
case 0:
|
|
1104
1179
|
_loop_13 = function (metadata) {
|
|
1105
|
-
var table, changedColumns, changedColumns_1, changedColumns_1_1, changedColumn,
|
|
1106
|
-
var
|
|
1180
|
+
var table, changedColumns, changedColumns_1, changedColumns_1_1, changedColumn, e_17_1, changedColumns_2, changedColumns_2_1, changedColumn, e_18_1, changedColumns_3, changedColumns_3_1, changedColumn, e_19_1, newAndOldTableColumns;
|
|
1181
|
+
var e_17, _e, e_18, _f, e_19, _g;
|
|
1107
1182
|
return __generator(this, function (_h) {
|
|
1108
1183
|
switch (_h.label) {
|
|
1109
1184
|
case 0:
|
|
1110
|
-
table =
|
|
1185
|
+
table = this_12.queryRunner.loadedTables.find(function (table) { return _this.getTablePath(table) === _this.getTablePath(metadata); });
|
|
1111
1186
|
if (!table)
|
|
1112
1187
|
return [2 /*return*/, "continue"];
|
|
1113
|
-
changedColumns =
|
|
1188
|
+
changedColumns = this_12.connection.driver.findChangedColumns(table.columns, metadata.columns);
|
|
1114
1189
|
if (changedColumns.length === 0)
|
|
1115
1190
|
return [2 /*return*/, "continue"];
|
|
1116
1191
|
_h.label = 1;
|
|
1117
1192
|
case 1:
|
|
1118
1193
|
_h.trys.push([1, 6, 7, 8]);
|
|
1119
|
-
changedColumns_1 = (
|
|
1194
|
+
changedColumns_1 = (e_17 = void 0, __values(changedColumns)), changedColumns_1_1 = changedColumns_1.next();
|
|
1120
1195
|
_h.label = 2;
|
|
1121
1196
|
case 2:
|
|
1122
1197
|
if (!!changedColumns_1_1.done) return [3 /*break*/, 5];
|
|
1123
1198
|
changedColumn = changedColumns_1_1.value;
|
|
1124
|
-
return [4 /*yield*/,
|
|
1199
|
+
return [4 /*yield*/, this_12.dropColumnReferencedForeignKeys(this_12.getTablePath(metadata), changedColumn.databaseName)];
|
|
1125
1200
|
case 3:
|
|
1126
1201
|
_h.sent();
|
|
1127
1202
|
_h.label = 4;
|
|
@@ -1130,23 +1205,23 @@ var RdbmsSchemaBuilder = /** @class */ (function () {
|
|
|
1130
1205
|
return [3 /*break*/, 2];
|
|
1131
1206
|
case 5: return [3 /*break*/, 8];
|
|
1132
1207
|
case 6:
|
|
1133
|
-
|
|
1134
|
-
|
|
1208
|
+
e_17_1 = _h.sent();
|
|
1209
|
+
e_17 = { error: e_17_1 };
|
|
1135
1210
|
return [3 /*break*/, 8];
|
|
1136
1211
|
case 7:
|
|
1137
1212
|
try {
|
|
1138
1213
|
if (changedColumns_1_1 && !changedColumns_1_1.done && (_e = changedColumns_1.return)) _e.call(changedColumns_1);
|
|
1139
1214
|
}
|
|
1140
|
-
finally { if (
|
|
1215
|
+
finally { if (e_17) throw e_17.error; }
|
|
1141
1216
|
return [7 /*endfinally*/];
|
|
1142
1217
|
case 8:
|
|
1143
1218
|
_h.trys.push([8, 13, 14, 15]);
|
|
1144
|
-
changedColumns_2 = (
|
|
1219
|
+
changedColumns_2 = (e_18 = void 0, __values(changedColumns)), changedColumns_2_1 = changedColumns_2.next();
|
|
1145
1220
|
_h.label = 9;
|
|
1146
1221
|
case 9:
|
|
1147
1222
|
if (!!changedColumns_2_1.done) return [3 /*break*/, 12];
|
|
1148
1223
|
changedColumn = changedColumns_2_1.value;
|
|
1149
|
-
return [4 /*yield*/,
|
|
1224
|
+
return [4 /*yield*/, this_12.dropColumnCompositeIndices(this_12.getTablePath(metadata), changedColumn.databaseName)];
|
|
1150
1225
|
case 10:
|
|
1151
1226
|
_h.sent();
|
|
1152
1227
|
_h.label = 11;
|
|
@@ -1155,26 +1230,26 @@ var RdbmsSchemaBuilder = /** @class */ (function () {
|
|
|
1155
1230
|
return [3 /*break*/, 9];
|
|
1156
1231
|
case 12: return [3 /*break*/, 15];
|
|
1157
1232
|
case 13:
|
|
1158
|
-
|
|
1159
|
-
|
|
1233
|
+
e_18_1 = _h.sent();
|
|
1234
|
+
e_18 = { error: e_18_1 };
|
|
1160
1235
|
return [3 /*break*/, 15];
|
|
1161
1236
|
case 14:
|
|
1162
1237
|
try {
|
|
1163
1238
|
if (changedColumns_2_1 && !changedColumns_2_1.done && (_f = changedColumns_2.return)) _f.call(changedColumns_2);
|
|
1164
1239
|
}
|
|
1165
|
-
finally { if (
|
|
1240
|
+
finally { if (e_18) throw e_18.error; }
|
|
1166
1241
|
return [7 /*endfinally*/];
|
|
1167
1242
|
case 15:
|
|
1168
|
-
if (!!(
|
|
1243
|
+
if (!!(this_12.connection.driver instanceof MysqlDriver || this_12.connection.driver instanceof AuroraDataApiDriver)) return [3 /*break*/, 23];
|
|
1169
1244
|
_h.label = 16;
|
|
1170
1245
|
case 16:
|
|
1171
1246
|
_h.trys.push([16, 21, 22, 23]);
|
|
1172
|
-
changedColumns_3 = (
|
|
1247
|
+
changedColumns_3 = (e_19 = void 0, __values(changedColumns)), changedColumns_3_1 = changedColumns_3.next();
|
|
1173
1248
|
_h.label = 17;
|
|
1174
1249
|
case 17:
|
|
1175
1250
|
if (!!changedColumns_3_1.done) return [3 /*break*/, 20];
|
|
1176
1251
|
changedColumn = changedColumns_3_1.value;
|
|
1177
|
-
return [4 /*yield*/,
|
|
1252
|
+
return [4 /*yield*/, this_12.dropColumnCompositeUniques(this_12.getTablePath(metadata), changedColumn.databaseName)];
|
|
1178
1253
|
case 18:
|
|
1179
1254
|
_h.sent();
|
|
1180
1255
|
_h.label = 19;
|
|
@@ -1183,14 +1258,14 @@ var RdbmsSchemaBuilder = /** @class */ (function () {
|
|
|
1183
1258
|
return [3 /*break*/, 17];
|
|
1184
1259
|
case 20: return [3 /*break*/, 23];
|
|
1185
1260
|
case 21:
|
|
1186
|
-
|
|
1187
|
-
|
|
1261
|
+
e_19_1 = _h.sent();
|
|
1262
|
+
e_19 = { error: e_19_1 };
|
|
1188
1263
|
return [3 /*break*/, 23];
|
|
1189
1264
|
case 22:
|
|
1190
1265
|
try {
|
|
1191
1266
|
if (changedColumns_3_1 && !changedColumns_3_1.done && (_g = changedColumns_3.return)) _g.call(changedColumns_3);
|
|
1192
1267
|
}
|
|
1193
|
-
finally { if (
|
|
1268
|
+
finally { if (e_19) throw e_19.error; }
|
|
1194
1269
|
return [7 /*endfinally*/];
|
|
1195
1270
|
case 23:
|
|
1196
1271
|
newAndOldTableColumns = changedColumns.map(function (changedColumn) {
|
|
@@ -1204,15 +1279,15 @@ var RdbmsSchemaBuilder = /** @class */ (function () {
|
|
|
1204
1279
|
});
|
|
1205
1280
|
if (newAndOldTableColumns.length === 0)
|
|
1206
1281
|
return [2 /*return*/, "continue"];
|
|
1207
|
-
|
|
1208
|
-
return [4 /*yield*/,
|
|
1282
|
+
this_12.connection.logger.logSchemaBuild("columns changed in \"" + table.name + "\". updating: " + changedColumns.map(function (column) { return column.databaseName; }).join(", "));
|
|
1283
|
+
return [4 /*yield*/, this_12.queryRunner.changeColumns(table, newAndOldTableColumns)];
|
|
1209
1284
|
case 24:
|
|
1210
1285
|
_h.sent();
|
|
1211
1286
|
return [2 /*return*/];
|
|
1212
1287
|
}
|
|
1213
1288
|
});
|
|
1214
1289
|
};
|
|
1215
|
-
|
|
1290
|
+
this_12 = this;
|
|
1216
1291
|
_d.label = 1;
|
|
1217
1292
|
case 1:
|
|
1218
1293
|
_d.trys.push([1, 6, 7, 8]);
|
|
@@ -1230,14 +1305,14 @@ var RdbmsSchemaBuilder = /** @class */ (function () {
|
|
|
1230
1305
|
return [3 /*break*/, 2];
|
|
1231
1306
|
case 5: return [3 /*break*/, 8];
|
|
1232
1307
|
case 6:
|
|
1233
|
-
|
|
1234
|
-
|
|
1308
|
+
e_16_1 = _d.sent();
|
|
1309
|
+
e_16 = { error: e_16_1 };
|
|
1235
1310
|
return [3 /*break*/, 8];
|
|
1236
1311
|
case 7:
|
|
1237
1312
|
try {
|
|
1238
1313
|
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
1239
1314
|
}
|
|
1240
|
-
finally { if (
|
|
1315
|
+
finally { if (e_16) throw e_16.error; }
|
|
1241
1316
|
return [7 /*endfinally*/];
|
|
1242
1317
|
case 8: return [2 /*return*/];
|
|
1243
1318
|
}
|
|
@@ -1249,8 +1324,8 @@ var RdbmsSchemaBuilder = /** @class */ (function () {
|
|
|
1249
1324
|
*/
|
|
1250
1325
|
RdbmsSchemaBuilder.prototype.createNewIndices = function () {
|
|
1251
1326
|
return __awaiter(this, void 0, void 0, function () {
|
|
1252
|
-
var _loop_14,
|
|
1253
|
-
var
|
|
1327
|
+
var _loop_14, this_13, _a, _b, metadata, e_20_1;
|
|
1328
|
+
var e_20, _c;
|
|
1254
1329
|
var _this = this;
|
|
1255
1330
|
return __generator(this, function (_d) {
|
|
1256
1331
|
switch (_d.label) {
|
|
@@ -1260,7 +1335,7 @@ var RdbmsSchemaBuilder = /** @class */ (function () {
|
|
|
1260
1335
|
return __generator(this, function (_e) {
|
|
1261
1336
|
switch (_e.label) {
|
|
1262
1337
|
case 0:
|
|
1263
|
-
table =
|
|
1338
|
+
table = this_13.queryRunner.loadedTables.find(function (table) { return _this.getTablePath(table) === _this.getTablePath(metadata); });
|
|
1264
1339
|
if (!table)
|
|
1265
1340
|
return [2 /*return*/, "continue"];
|
|
1266
1341
|
newIndices = metadata.indices
|
|
@@ -1268,15 +1343,15 @@ var RdbmsSchemaBuilder = /** @class */ (function () {
|
|
|
1268
1343
|
.map(function (indexMetadata) { return TableIndex.create(indexMetadata); });
|
|
1269
1344
|
if (newIndices.length === 0)
|
|
1270
1345
|
return [2 /*return*/, "continue"];
|
|
1271
|
-
|
|
1272
|
-
return [4 /*yield*/,
|
|
1346
|
+
this_13.connection.logger.logSchemaBuild("adding new indices " + newIndices.map(function (index) { return "\"" + index.name + "\""; }).join(", ") + " in table \"" + table.name + "\"");
|
|
1347
|
+
return [4 /*yield*/, this_13.queryRunner.createIndices(table, newIndices)];
|
|
1273
1348
|
case 1:
|
|
1274
1349
|
_e.sent();
|
|
1275
1350
|
return [2 /*return*/];
|
|
1276
1351
|
}
|
|
1277
1352
|
});
|
|
1278
1353
|
};
|
|
1279
|
-
|
|
1354
|
+
this_13 = this;
|
|
1280
1355
|
_d.label = 1;
|
|
1281
1356
|
case 1:
|
|
1282
1357
|
_d.trys.push([1, 6, 7, 8]);
|
|
@@ -1294,14 +1369,14 @@ var RdbmsSchemaBuilder = /** @class */ (function () {
|
|
|
1294
1369
|
return [3 /*break*/, 2];
|
|
1295
1370
|
case 5: return [3 /*break*/, 8];
|
|
1296
1371
|
case 6:
|
|
1297
|
-
|
|
1298
|
-
|
|
1372
|
+
e_20_1 = _d.sent();
|
|
1373
|
+
e_20 = { error: e_20_1 };
|
|
1299
1374
|
return [3 /*break*/, 8];
|
|
1300
1375
|
case 7:
|
|
1301
1376
|
try {
|
|
1302
1377
|
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
1303
1378
|
}
|
|
1304
|
-
finally { if (
|
|
1379
|
+
finally { if (e_20) throw e_20.error; }
|
|
1305
1380
|
return [7 /*endfinally*/];
|
|
1306
1381
|
case 8: return [2 /*return*/];
|
|
1307
1382
|
}
|
|
@@ -1310,8 +1385,8 @@ var RdbmsSchemaBuilder = /** @class */ (function () {
|
|
|
1310
1385
|
};
|
|
1311
1386
|
RdbmsSchemaBuilder.prototype.createNewChecks = function () {
|
|
1312
1387
|
return __awaiter(this, void 0, void 0, function () {
|
|
1313
|
-
var _loop_15,
|
|
1314
|
-
var
|
|
1388
|
+
var _loop_15, this_14, _a, _b, metadata, e_21_1;
|
|
1389
|
+
var e_21, _c;
|
|
1315
1390
|
var _this = this;
|
|
1316
1391
|
return __generator(this, function (_d) {
|
|
1317
1392
|
switch (_d.label) {
|
|
@@ -1324,7 +1399,7 @@ var RdbmsSchemaBuilder = /** @class */ (function () {
|
|
|
1324
1399
|
return __generator(this, function (_e) {
|
|
1325
1400
|
switch (_e.label) {
|
|
1326
1401
|
case 0:
|
|
1327
|
-
table =
|
|
1402
|
+
table = this_14.queryRunner.loadedTables.find(function (table) { return _this.getTablePath(table) === _this.getTablePath(metadata); });
|
|
1328
1403
|
if (!table)
|
|
1329
1404
|
return [2 /*return*/, "continue"];
|
|
1330
1405
|
newChecks = metadata.checks
|
|
@@ -1332,15 +1407,15 @@ var RdbmsSchemaBuilder = /** @class */ (function () {
|
|
|
1332
1407
|
.map(function (checkMetadata) { return TableCheck.create(checkMetadata); });
|
|
1333
1408
|
if (newChecks.length === 0)
|
|
1334
1409
|
return [2 /*return*/, "continue"];
|
|
1335
|
-
|
|
1336
|
-
return [4 /*yield*/,
|
|
1410
|
+
this_14.connection.logger.logSchemaBuild("adding new check constraints: " + newChecks.map(function (index) { return "\"" + index.name + "\""; }).join(", ") + " in table \"" + table.name + "\"");
|
|
1411
|
+
return [4 /*yield*/, this_14.queryRunner.createCheckConstraints(table, newChecks)];
|
|
1337
1412
|
case 1:
|
|
1338
1413
|
_e.sent();
|
|
1339
1414
|
return [2 /*return*/];
|
|
1340
1415
|
}
|
|
1341
1416
|
});
|
|
1342
1417
|
};
|
|
1343
|
-
|
|
1418
|
+
this_14 = this;
|
|
1344
1419
|
_d.label = 1;
|
|
1345
1420
|
case 1:
|
|
1346
1421
|
_d.trys.push([1, 6, 7, 8]);
|
|
@@ -1358,14 +1433,14 @@ var RdbmsSchemaBuilder = /** @class */ (function () {
|
|
|
1358
1433
|
return [3 /*break*/, 2];
|
|
1359
1434
|
case 5: return [3 /*break*/, 8];
|
|
1360
1435
|
case 6:
|
|
1361
|
-
|
|
1362
|
-
|
|
1436
|
+
e_21_1 = _d.sent();
|
|
1437
|
+
e_21 = { error: e_21_1 };
|
|
1363
1438
|
return [3 /*break*/, 8];
|
|
1364
1439
|
case 7:
|
|
1365
1440
|
try {
|
|
1366
1441
|
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
1367
1442
|
}
|
|
1368
|
-
finally { if (
|
|
1443
|
+
finally { if (e_21) throw e_21.error; }
|
|
1369
1444
|
return [7 /*endfinally*/];
|
|
1370
1445
|
case 8: return [2 /*return*/];
|
|
1371
1446
|
}
|
|
@@ -1377,8 +1452,8 @@ var RdbmsSchemaBuilder = /** @class */ (function () {
|
|
|
1377
1452
|
*/
|
|
1378
1453
|
RdbmsSchemaBuilder.prototype.createCompositeUniqueConstraints = function () {
|
|
1379
1454
|
return __awaiter(this, void 0, void 0, function () {
|
|
1380
|
-
var _loop_16,
|
|
1381
|
-
var
|
|
1455
|
+
var _loop_16, this_15, _a, _b, metadata, e_22_1;
|
|
1456
|
+
var e_22, _c;
|
|
1382
1457
|
var _this = this;
|
|
1383
1458
|
return __generator(this, function (_d) {
|
|
1384
1459
|
switch (_d.label) {
|
|
@@ -1388,7 +1463,7 @@ var RdbmsSchemaBuilder = /** @class */ (function () {
|
|
|
1388
1463
|
return __generator(this, function (_e) {
|
|
1389
1464
|
switch (_e.label) {
|
|
1390
1465
|
case 0:
|
|
1391
|
-
table =
|
|
1466
|
+
table = this_15.queryRunner.loadedTables.find(function (table) { return _this.getTablePath(table) === _this.getTablePath(metadata); });
|
|
1392
1467
|
if (!table)
|
|
1393
1468
|
return [2 /*return*/, "continue"];
|
|
1394
1469
|
compositeUniques = metadata.uniques
|
|
@@ -1396,15 +1471,15 @@ var RdbmsSchemaBuilder = /** @class */ (function () {
|
|
|
1396
1471
|
.map(function (uniqueMetadata) { return TableUnique.create(uniqueMetadata); });
|
|
1397
1472
|
if (compositeUniques.length === 0)
|
|
1398
1473
|
return [2 /*return*/, "continue"];
|
|
1399
|
-
|
|
1400
|
-
return [4 /*yield*/,
|
|
1474
|
+
this_15.connection.logger.logSchemaBuild("adding new unique constraints: " + compositeUniques.map(function (unique) { return "\"" + unique.name + "\""; }).join(", ") + " in table \"" + table.name + "\"");
|
|
1475
|
+
return [4 /*yield*/, this_15.queryRunner.createUniqueConstraints(table, compositeUniques)];
|
|
1401
1476
|
case 1:
|
|
1402
1477
|
_e.sent();
|
|
1403
1478
|
return [2 /*return*/];
|
|
1404
1479
|
}
|
|
1405
1480
|
});
|
|
1406
1481
|
};
|
|
1407
|
-
|
|
1482
|
+
this_15 = this;
|
|
1408
1483
|
_d.label = 1;
|
|
1409
1484
|
case 1:
|
|
1410
1485
|
_d.trys.push([1, 6, 7, 8]);
|
|
@@ -1422,14 +1497,14 @@ var RdbmsSchemaBuilder = /** @class */ (function () {
|
|
|
1422
1497
|
return [3 /*break*/, 2];
|
|
1423
1498
|
case 5: return [3 /*break*/, 8];
|
|
1424
1499
|
case 6:
|
|
1425
|
-
|
|
1426
|
-
|
|
1500
|
+
e_22_1 = _d.sent();
|
|
1501
|
+
e_22 = { error: e_22_1 };
|
|
1427
1502
|
return [3 /*break*/, 8];
|
|
1428
1503
|
case 7:
|
|
1429
1504
|
try {
|
|
1430
1505
|
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
1431
1506
|
}
|
|
1432
|
-
finally { if (
|
|
1507
|
+
finally { if (e_22) throw e_22.error; }
|
|
1433
1508
|
return [7 /*endfinally*/];
|
|
1434
1509
|
case 8: return [2 /*return*/];
|
|
1435
1510
|
}
|
|
@@ -1441,8 +1516,8 @@ var RdbmsSchemaBuilder = /** @class */ (function () {
|
|
|
1441
1516
|
*/
|
|
1442
1517
|
RdbmsSchemaBuilder.prototype.createNewExclusions = function () {
|
|
1443
1518
|
return __awaiter(this, void 0, void 0, function () {
|
|
1444
|
-
var _loop_17,
|
|
1445
|
-
var
|
|
1519
|
+
var _loop_17, this_16, _a, _b, metadata, e_23_1;
|
|
1520
|
+
var e_23, _c;
|
|
1446
1521
|
var _this = this;
|
|
1447
1522
|
return __generator(this, function (_d) {
|
|
1448
1523
|
switch (_d.label) {
|
|
@@ -1455,7 +1530,7 @@ var RdbmsSchemaBuilder = /** @class */ (function () {
|
|
|
1455
1530
|
return __generator(this, function (_e) {
|
|
1456
1531
|
switch (_e.label) {
|
|
1457
1532
|
case 0:
|
|
1458
|
-
table =
|
|
1533
|
+
table = this_16.queryRunner.loadedTables.find(function (table) { return _this.getTablePath(table) === _this.getTablePath(metadata); });
|
|
1459
1534
|
if (!table)
|
|
1460
1535
|
return [2 /*return*/, "continue"];
|
|
1461
1536
|
newExclusions = metadata.exclusions
|
|
@@ -1463,15 +1538,15 @@ var RdbmsSchemaBuilder = /** @class */ (function () {
|
|
|
1463
1538
|
.map(function (exclusionMetadata) { return TableExclusion.create(exclusionMetadata); });
|
|
1464
1539
|
if (newExclusions.length === 0)
|
|
1465
1540
|
return [2 /*return*/, "continue"];
|
|
1466
|
-
|
|
1467
|
-
return [4 /*yield*/,
|
|
1541
|
+
this_16.connection.logger.logSchemaBuild("adding new exclusion constraints: " + newExclusions.map(function (exclusion) { return "\"" + exclusion.name + "\""; }).join(", ") + " in table \"" + table.name + "\"");
|
|
1542
|
+
return [4 /*yield*/, this_16.queryRunner.createExclusionConstraints(table, newExclusions)];
|
|
1468
1543
|
case 1:
|
|
1469
1544
|
_e.sent();
|
|
1470
1545
|
return [2 /*return*/];
|
|
1471
1546
|
}
|
|
1472
1547
|
});
|
|
1473
1548
|
};
|
|
1474
|
-
|
|
1549
|
+
this_16 = this;
|
|
1475
1550
|
_d.label = 1;
|
|
1476
1551
|
case 1:
|
|
1477
1552
|
_d.trys.push([1, 6, 7, 8]);
|
|
@@ -1489,14 +1564,14 @@ var RdbmsSchemaBuilder = /** @class */ (function () {
|
|
|
1489
1564
|
return [3 /*break*/, 2];
|
|
1490
1565
|
case 5: return [3 /*break*/, 8];
|
|
1491
1566
|
case 6:
|
|
1492
|
-
|
|
1493
|
-
|
|
1567
|
+
e_23_1 = _d.sent();
|
|
1568
|
+
e_23 = { error: e_23_1 };
|
|
1494
1569
|
return [3 /*break*/, 8];
|
|
1495
1570
|
case 7:
|
|
1496
1571
|
try {
|
|
1497
1572
|
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
1498
1573
|
}
|
|
1499
|
-
finally { if (
|
|
1574
|
+
finally { if (e_23) throw e_23.error; }
|
|
1500
1575
|
return [7 /*endfinally*/];
|
|
1501
1576
|
case 8: return [2 /*return*/];
|
|
1502
1577
|
}
|
|
@@ -1508,8 +1583,8 @@ var RdbmsSchemaBuilder = /** @class */ (function () {
|
|
|
1508
1583
|
*/
|
|
1509
1584
|
RdbmsSchemaBuilder.prototype.createForeignKeys = function () {
|
|
1510
1585
|
return __awaiter(this, void 0, void 0, function () {
|
|
1511
|
-
var _loop_18,
|
|
1512
|
-
var
|
|
1586
|
+
var _loop_18, this_17, _a, _b, metadata, e_24_1;
|
|
1587
|
+
var e_24, _c;
|
|
1513
1588
|
var _this = this;
|
|
1514
1589
|
return __generator(this, function (_d) {
|
|
1515
1590
|
switch (_d.label) {
|
|
@@ -1519,7 +1594,7 @@ var RdbmsSchemaBuilder = /** @class */ (function () {
|
|
|
1519
1594
|
return __generator(this, function (_e) {
|
|
1520
1595
|
switch (_e.label) {
|
|
1521
1596
|
case 0:
|
|
1522
|
-
table =
|
|
1597
|
+
table = this_17.queryRunner.loadedTables.find(function (table) { return _this.getTablePath(table) === _this.getTablePath(metadata); });
|
|
1523
1598
|
if (!table)
|
|
1524
1599
|
return [2 /*return*/, "continue"];
|
|
1525
1600
|
newKeys = metadata.foreignKeys
|
|
@@ -1530,15 +1605,15 @@ var RdbmsSchemaBuilder = /** @class */ (function () {
|
|
|
1530
1605
|
if (newKeys.length === 0)
|
|
1531
1606
|
return [2 /*return*/, "continue"];
|
|
1532
1607
|
dbForeignKeys = newKeys.map(function (foreignKeyMetadata) { return TableForeignKey.create(foreignKeyMetadata, _this.connection.driver); });
|
|
1533
|
-
|
|
1534
|
-
return [4 /*yield*/,
|
|
1608
|
+
this_17.connection.logger.logSchemaBuild("creating a foreign keys: " + newKeys.map(function (key) { return key.name; }).join(", ") + " on table \"" + table.name + "\"");
|
|
1609
|
+
return [4 /*yield*/, this_17.queryRunner.createForeignKeys(table, dbForeignKeys)];
|
|
1535
1610
|
case 1:
|
|
1536
1611
|
_e.sent();
|
|
1537
1612
|
return [2 /*return*/];
|
|
1538
1613
|
}
|
|
1539
1614
|
});
|
|
1540
1615
|
};
|
|
1541
|
-
|
|
1616
|
+
this_17 = this;
|
|
1542
1617
|
_d.label = 1;
|
|
1543
1618
|
case 1:
|
|
1544
1619
|
_d.trys.push([1, 6, 7, 8]);
|
|
@@ -1556,14 +1631,14 @@ var RdbmsSchemaBuilder = /** @class */ (function () {
|
|
|
1556
1631
|
return [3 /*break*/, 2];
|
|
1557
1632
|
case 5: return [3 /*break*/, 8];
|
|
1558
1633
|
case 6:
|
|
1559
|
-
|
|
1560
|
-
|
|
1634
|
+
e_24_1 = _d.sent();
|
|
1635
|
+
e_24 = { error: e_24_1 };
|
|
1561
1636
|
return [3 /*break*/, 8];
|
|
1562
1637
|
case 7:
|
|
1563
1638
|
try {
|
|
1564
1639
|
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
1565
1640
|
}
|
|
1566
|
-
finally { if (
|
|
1641
|
+
finally { if (e_24) throw e_24.error; }
|
|
1567
1642
|
return [7 /*endfinally*/];
|
|
1568
1643
|
case 8: return [2 /*return*/];
|
|
1569
1644
|
}
|
|
@@ -1575,8 +1650,8 @@ var RdbmsSchemaBuilder = /** @class */ (function () {
|
|
|
1575
1650
|
*/
|
|
1576
1651
|
RdbmsSchemaBuilder.prototype.dropColumnReferencedForeignKeys = function (tablePath, columnName) {
|
|
1577
1652
|
return __awaiter(this, void 0, void 0, function () {
|
|
1578
|
-
var table, tablesWithFK, columnForeignKey, clonedTable, _loop_19, _a, _b, loadedTable, tablesWithFK_1, tablesWithFK_1_1, tableWithFK,
|
|
1579
|
-
var
|
|
1653
|
+
var table, tablesWithFK, columnForeignKey, clonedTable, _loop_19, _a, _b, loadedTable, tablesWithFK_1, tablesWithFK_1_1, tableWithFK, e_25_1;
|
|
1654
|
+
var e_26, _c, e_25, _d;
|
|
1580
1655
|
var _this = this;
|
|
1581
1656
|
return __generator(this, function (_e) {
|
|
1582
1657
|
switch (_e.label) {
|
|
@@ -1609,12 +1684,12 @@ var RdbmsSchemaBuilder = /** @class */ (function () {
|
|
|
1609
1684
|
_loop_19(loadedTable);
|
|
1610
1685
|
}
|
|
1611
1686
|
}
|
|
1612
|
-
catch (
|
|
1687
|
+
catch (e_26_1) { e_26 = { error: e_26_1 }; }
|
|
1613
1688
|
finally {
|
|
1614
1689
|
try {
|
|
1615
1690
|
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
1616
1691
|
}
|
|
1617
|
-
finally { if (
|
|
1692
|
+
finally { if (e_26) throw e_26.error; }
|
|
1618
1693
|
}
|
|
1619
1694
|
if (!(tablesWithFK.length > 0)) return [3 /*break*/, 8];
|
|
1620
1695
|
_e.label = 1;
|
|
@@ -1635,14 +1710,14 @@ var RdbmsSchemaBuilder = /** @class */ (function () {
|
|
|
1635
1710
|
return [3 /*break*/, 2];
|
|
1636
1711
|
case 5: return [3 /*break*/, 8];
|
|
1637
1712
|
case 6:
|
|
1638
|
-
|
|
1639
|
-
|
|
1713
|
+
e_25_1 = _e.sent();
|
|
1714
|
+
e_25 = { error: e_25_1 };
|
|
1640
1715
|
return [3 /*break*/, 8];
|
|
1641
1716
|
case 7:
|
|
1642
1717
|
try {
|
|
1643
1718
|
if (tablesWithFK_1_1 && !tablesWithFK_1_1.done && (_d = tablesWithFK_1.return)) _d.call(tablesWithFK_1);
|
|
1644
1719
|
}
|
|
1645
|
-
finally { if (
|
|
1720
|
+
finally { if (e_25) throw e_25.error; }
|
|
1646
1721
|
return [7 /*endfinally*/];
|
|
1647
1722
|
case 8: return [2 /*return*/];
|
|
1648
1723
|
}
|