@contember/schema-migrations 1.3.0 → 1.3.3
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/dist/src/modifications/relations/UpdateRelationOnDeleteModification.d.ts.map +1 -1
- package/dist/src/modifications/relations/UpdateRelationOnDeleteModification.js +3 -2
- package/dist/src/modifications/relations/UpdateRelationOnDeleteModification.js.map +1 -1
- package/dist/src/tsconfig.tsbuildinfo +1 -1
- package/dist/tests/cases/integration/createRelationInverseSide.test.js +1 -1
- package/dist/tests/cases/integration/createRelationInverseSide.test.js.map +1 -1
- package/dist/tests/cases/integration/updateRelationOnDelete.test.js +1 -1
- package/dist/tests/cases/integration/updateRelationOnDelete.test.js.map +1 -1
- package/dist/tests/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -6
- package/src/modifications/relations/UpdateRelationOnDeleteModification.ts +4 -2
- package/tests/cases/integration/createRelationInverseSide.test.ts +1 -1
- package/tests/cases/integration/updateRelationOnDelete.test.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contember/schema-migrations",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.3",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"typings": "dist/src/index.d.ts",
|
|
@@ -12,15 +12,15 @@
|
|
|
12
12
|
"test": "vitest --dir ./tests/cases"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@contember/database-migrations": "1.3.
|
|
16
|
-
"@contember/engine-common": "1.3.
|
|
17
|
-
"@contember/schema": "1.3.
|
|
18
|
-
"@contember/schema-utils": "1.3.
|
|
15
|
+
"@contember/database-migrations": "1.3.3",
|
|
16
|
+
"@contember/engine-common": "1.3.3",
|
|
17
|
+
"@contember/schema": "1.3.3",
|
|
18
|
+
"@contember/schema-utils": "1.3.3",
|
|
19
19
|
"fast-deep-equal": "^3.1.3",
|
|
20
20
|
"rfc6902": "^5.0.1"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@contember/schema-definition": "1.3.
|
|
23
|
+
"@contember/schema-definition": "1.3.3"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"pg": "^8.9.0"
|
|
@@ -19,11 +19,13 @@ export class UpdateRelationOnDeleteModificationHandler implements ModificationHa
|
|
|
19
19
|
) {}
|
|
20
20
|
|
|
21
21
|
public createSql(builder: MigrationBuilder, { databaseMetadata, invalidateDatabaseMetadata }: ModificationHandlerCreateSqlOptions): void {
|
|
22
|
-
const
|
|
22
|
+
const updatedSchema = this.getSchemaUpdater()({ schema: this.schema })
|
|
23
|
+
const entity = updatedSchema.model.entities[this.data.entityName]
|
|
23
24
|
if (entity.view) {
|
|
24
25
|
return
|
|
25
26
|
}
|
|
26
|
-
|
|
27
|
+
|
|
28
|
+
acceptRelationTypeVisitor(updatedSchema.model, entity, this.data.fieldName, {
|
|
27
29
|
visitManyHasOne: ({ entity, relation, targetEntity }) => {
|
|
28
30
|
addForeignKeyConstraint({ builder, entity, targetEntity, relation, recreate: true, databaseMetadata, invalidateDatabaseMetadata })
|
|
29
31
|
},
|
|
@@ -64,5 +64,5 @@ testMigrations('create inverse side relation together with changing onDelete beh
|
|
|
64
64
|
},
|
|
65
65
|
},
|
|
66
66
|
],
|
|
67
|
-
sql: SQL`ALTER TABLE "post_locale" DROP CONSTRAINT "fk_post_locale_post_id_post_id"; ALTER TABLE "post_locale" ADD FOREIGN KEY ("post_id") REFERENCES "post"("id") ON DELETE
|
|
67
|
+
sql: SQL`ALTER TABLE "post_locale" DROP CONSTRAINT "fk_post_locale_post_id_post_id"; ALTER TABLE "post_locale" ADD FOREIGN KEY ("post_id") REFERENCES "post"("id") ON DELETE CASCADE DEFERRABLE INITIALLY IMMEDIATE;`,
|
|
68
68
|
})
|
|
@@ -31,5 +31,5 @@ testMigrations('update relation ondelete to cascade', {
|
|
|
31
31
|
},
|
|
32
32
|
],
|
|
33
33
|
sql: SQL`ALTER TABLE "post" DROP CONSTRAINT "fk_post_category_id_category_id";
|
|
34
|
-
ALTER TABLE "post" ADD FOREIGN KEY ("category_id") REFERENCES "category"("id") ON DELETE
|
|
34
|
+
ALTER TABLE "post" ADD FOREIGN KEY ("category_id") REFERENCES "category"("id") ON DELETE CASCADE DEFERRABLE INITIALLY IMMEDIATE;`,
|
|
35
35
|
})
|