@contember/schema-migrations 1.3.0-beta.2 → 1.3.0-beta.4

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.0-beta.2",
3
+ "version": "1.3.0-beta.4",
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.0-beta.2",
16
- "@contember/engine-common": "1.3.0-beta.2",
17
- "@contember/schema": "1.3.0-beta.2",
18
- "@contember/schema-utils": "1.3.0-beta.2",
15
+ "@contember/database-migrations": "1.3.0-beta.4",
16
+ "@contember/engine-common": "1.3.0-beta.4",
17
+ "@contember/schema": "1.3.0-beta.4",
18
+ "@contember/schema-utils": "1.3.0-beta.4",
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.0-beta.2"
23
+ "@contember/schema-definition": "1.3.0-beta.4"
24
24
  },
25
25
  "peerDependencies": {
26
26
  "pg": "^8.9.0"
@@ -27,6 +27,10 @@ export const fillSeed = ({ builder, fillValue, copyValue, entity, columnName, nu
27
27
  throw new ImplementationException()
28
28
  }
29
29
 
30
+ // event log uses deferred constraint triggers, we need to fire them before ALTER
31
+ builder.sql(`SET CONSTRAINTS ALL IMMEDIATE`)
32
+ builder.sql(`SET CONSTRAINTS ALL DEFERRED`)
33
+
30
34
  if (!nullable) {
31
35
  builder.alterColumn(entity.tableName, columnName, {
32
36
  notNull: true,
@@ -32,6 +32,7 @@ testMigrations('create a column with default value', {
32
32
  ],
33
33
  sql: SQL`ALTER TABLE "author" ADD "name" text;
34
34
  UPDATE "author" SET "name" = $pga$unnamed author$pga$;
35
+ SET CONSTRAINTS ALL IMMEDIATE; SET CONSTRAINTS ALL DEFERRED;
35
36
  ALTER TABLE "author" ALTER "name" SET NOT NULL;`,
36
37
  })
37
38
 
@@ -64,5 +65,6 @@ testMigrations('create a column with copy value', {
64
65
  noDiff: true,
65
66
  sql: SQL`ALTER TABLE "author" ADD "name" text;
66
67
  UPDATE "author" SET "name" = "email"::text;
68
+ SET CONSTRAINTS ALL IMMEDIATE; SET CONSTRAINTS ALL DEFERRED;
67
69
  ALTER TABLE "author" ALTER "name" SET NOT NULL;`,
68
70
  })
@@ -197,6 +197,7 @@ testMigrations('set not null and fill', {
197
197
  }),
198
198
  ],
199
199
  sql: SQL`
200
- UPDATE "author" SET "name" = $pga$unnamed$pga$ WHERE "name" IS NULL;
200
+ UPDATE "author" SET "name" = $pga$unnamed$pga$ WHERE "name" IS NULL;
201
+ SET CONSTRAINTS ALL IMMEDIATE; SET CONSTRAINTS ALL DEFERRED;
201
202
  ALTER TABLE "author" ALTER "name" SET NOT NULL;`,
202
203
  })