@xemahq/biome-database-nest 0.36.0 → 0.37.0
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { OperatorMigrationDatabase } from './operator-migration';
|
|
2
|
-
export declare const OPERATOR_MIGRATION_LEDGER_DDL = "CREATE TABLE IF NOT EXISTS \"xema_operator_migrations\" (\n \"migration_id\" TEXT NOT NULL,\n \"phase\" TEXT NOT NULL,\n \"artifact_sha256\" CHAR(64) NOT NULL,\n \"completed_at\"
|
|
2
|
+
export declare const OPERATOR_MIGRATION_LEDGER_DDL = "CREATE TABLE IF NOT EXISTS \"xema_operator_migrations\" (\n \"migration_id\" TEXT NOT NULL,\n \"phase\" TEXT NOT NULL,\n \"artifact_sha256\" CHAR(64) NOT NULL,\n \"completed_at\" TIMESTAMPTZ(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,\n CONSTRAINT \"xema_operator_migrations_pkey\" PRIMARY KEY (\"migration_id\", \"phase\"),\n CONSTRAINT \"xema_operator_migrations_id_ck\"\n CHECK (\"migration_id\" ~ '^[a-z][a-z0-9-]{0,126}$'),\n CONSTRAINT \"xema_operator_migrations_phase_ck\"\n CHECK (\"phase\" IN ('verified', 'contracted')),\n CONSTRAINT \"xema_operator_migrations_hash_ck\"\n CHECK (\"artifact_sha256\" ~ '^[a-f0-9]{64}$')\n)";
|
|
3
3
|
export declare function ensureOperatorMigrationLedger(database: OperatorMigrationDatabase): Promise<void>;
|
|
4
4
|
//# sourceMappingURL=operator-migration-ledger.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operator-migration-ledger.d.ts","sourceRoot":"","sources":["../../src/lib/operator-migration-ledger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAQtE,eAAO,MAAM,6BAA6B,
|
|
1
|
+
{"version":3,"file":"operator-migration-ledger.d.ts","sourceRoot":"","sources":["../../src/lib/operator-migration-ledger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAQtE,eAAO,MAAM,6BAA6B,yoBAYxC,CAAC;AA8BH,wBAAsB,6BAA6B,CACjD,QAAQ,EAAE,yBAAyB,GAClC,OAAO,CAAC,IAAI,CAAC,CA8Bf"}
|
|
@@ -7,7 +7,7 @@ exports.OPERATOR_MIGRATION_LEDGER_DDL = `CREATE TABLE IF NOT EXISTS "xema_operat
|
|
|
7
7
|
"migration_id" TEXT NOT NULL,
|
|
8
8
|
"phase" TEXT NOT NULL,
|
|
9
9
|
"artifact_sha256" CHAR(64) NOT NULL,
|
|
10
|
-
"completed_at"
|
|
10
|
+
"completed_at" TIMESTAMPTZ(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
11
11
|
CONSTRAINT "xema_operator_migrations_pkey" PRIMARY KEY ("migration_id", "phase"),
|
|
12
12
|
CONSTRAINT "xema_operator_migrations_id_ck"
|
|
13
13
|
CHECK ("migration_id" ~ '^[a-z][a-z0-9-]{0,126}$'),
|
|
@@ -16,6 +16,14 @@ exports.OPERATOR_MIGRATION_LEDGER_DDL = `CREATE TABLE IF NOT EXISTS "xema_operat
|
|
|
16
16
|
CONSTRAINT "xema_operator_migrations_hash_ck"
|
|
17
17
|
CHECK ("artifact_sha256" ~ '^[a-f0-9]{64}$')
|
|
18
18
|
)`;
|
|
19
|
+
const COMPLETED_AT_TYPE_SQL = `SELECT format_type(a.atttypid, a.atttypmod) AS type
|
|
20
|
+
FROM pg_attribute a
|
|
21
|
+
WHERE a.attrelid = to_regclass('"xema_operator_migrations"')
|
|
22
|
+
AND a.attname = 'completed_at'
|
|
23
|
+
AND NOT a.attisdropped`;
|
|
24
|
+
const COMPLETED_AT_CONVERT_SQL = `ALTER TABLE "xema_operator_migrations"
|
|
25
|
+
ALTER COLUMN "completed_at" TYPE timestamptz(3)
|
|
26
|
+
USING "completed_at" AT TIME ZONE 'UTC'`;
|
|
19
27
|
const ensuredDatabases = new WeakSet();
|
|
20
28
|
async function ensureOperatorMigrationLedger(database) {
|
|
21
29
|
if (ensuredDatabases.has(database)) {
|
|
@@ -25,6 +33,10 @@ async function ensureOperatorMigrationLedger(database) {
|
|
|
25
33
|
try {
|
|
26
34
|
await database.query(`SELECT pg_advisory_xact_lock(hashtextextended($1, 0))`, [LEDGER_LOCK_KEY]);
|
|
27
35
|
await database.query(exports.OPERATOR_MIGRATION_LEDGER_DDL);
|
|
36
|
+
const column = await database.query(COMPLETED_AT_TYPE_SQL);
|
|
37
|
+
if (/^timestamp(\(\d+\))? without time zone$/u.test(column.rows[0]?.type ?? '')) {
|
|
38
|
+
await database.query(COMPLETED_AT_CONVERT_SQL);
|
|
39
|
+
}
|
|
28
40
|
await database.query('COMMIT');
|
|
29
41
|
}
|
|
30
42
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operator-migration-ledger.js","sourceRoot":"","sources":["../../src/lib/operator-migration-ledger.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"operator-migration-ledger.js","sourceRoot":"","sources":["../../src/lib/operator-migration-ledger.ts"],"names":[],"mappings":";;;AAkDA,sEAgCC;AAhFD,MAAM,eAAe,GAAG,gCAAgC,CAAC;AAM5C,QAAA,6BAA6B,GAAG;;;;;;;;;;;;EAY3C,CAAC;AAGH,MAAM,qBAAqB,GAAG;;;;2BAIH,CAAC;AAO5B,MAAM,wBAAwB,GAAG;;0CAES,CAAC;AAE3C,MAAM,gBAAgB,GAAG,IAAI,OAAO,EAA6B,CAAC;AAY3D,KAAK,UAAU,6BAA6B,CACjD,QAAmC;IAEnC,IAAI,gBAAgB,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;QACnC,OAAO;IACT,CAAC;IACD,MAAM,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC9B,IAAI,CAAC;QACH,MAAM,QAAQ,CAAC,KAAK,CAClB,uDAAuD,EACvD,CAAC,eAAe,CAAC,CAClB,CAAC;QACF,MAAM,QAAQ,CAAC,KAAK,CAAC,qCAA6B,CAAC,CAAC;QACpD,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,KAAK,CACjC,qBAAqB,CACtB,CAAC;QACF,IAAI,0CAA0C,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,IAAI,EAAE,CAAC,EAAE,CAAC;YAChF,MAAM,QAAQ,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;QACjD,CAAC;QACD,MAAM,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IACjC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC;YACH,MAAM,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QACnC,CAAC;QAAC,OAAO,aAAa,EAAE,CAAC;YACvB,MAAM,IAAI,cAAc,CACtB,CAAC,KAAK,EAAE,aAAa,CAAC,EACtB,yFAAyF,CAC1F,CAAC;QACJ,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;IACD,gBAAgB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AACjC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xemahq/biome-database-nest",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.37.0",
|
|
4
4
|
"description": "Explicit database migration ownership, least-privilege runtime verification, and schema-qualified Prisma wiring for Xema biome services.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Neuralchowder Inc. <developer@xema.dev> (https://xema.dev)",
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"prisma": "7.8.0",
|
|
40
40
|
"ts-jest": "^29.4.9",
|
|
41
41
|
"typescript": "5.9.3",
|
|
42
|
-
"@xemahq/eslint-config": "0.12.2",
|
|
43
42
|
"@xemahq/xema-decorators": "0.24.0",
|
|
43
|
+
"@xemahq/eslint-config": "0.12.2",
|
|
44
44
|
"@xemahq/service-registry-nest": "0.21.0"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
@@ -78,6 +78,6 @@
|
|
|
78
78
|
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
79
79
|
},
|
|
80
80
|
"xemaRelease": {
|
|
81
|
-
"sourceDigest": "sha256:
|
|
81
|
+
"sourceDigest": "sha256:12656945a9569d08eff67912de1d0196221a8378cba483d62fe7f150be99f02c"
|
|
82
82
|
}
|
|
83
83
|
}
|