@contember/schema-migrations 1.3.2 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contember/schema-migrations",
3
- "version": "1.3.2",
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.2",
16
- "@contember/engine-common": "1.3.2",
17
- "@contember/schema": "1.3.2",
18
- "@contember/schema-utils": "1.3.2",
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.2"
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 entity = this.schema.model.entities[this.data.entityName]
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
- acceptRelationTypeVisitor(this.schema.model, entity, this.data.fieldName, {
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 NO ACTION DEFERRABLE INITIALLY IMMEDIATE;`,
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 NO ACTION DEFERRABLE INITIALLY IMMEDIATE;`,
34
+ ALTER TABLE "post" ADD FOREIGN KEY ("category_id") REFERENCES "category"("id") ON DELETE CASCADE DEFERRABLE INITIALLY IMMEDIATE;`,
35
35
  })