@substrat-run/contract-tests 0.139.0 → 0.141.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.
- package/dist/attachment-text-suite.d.ts.map +1 -1
- package/dist/attachment-text-suite.js +12 -4
- package/dist/attachment-text-suite.js.map +1 -1
- package/dist/capability-attachment-suite.d.ts.map +1 -1
- package/dist/capability-attachment-suite.js +84 -4
- package/dist/capability-attachment-suite.js.map +1 -1
- package/dist/capability-expiry-suite.d.ts.map +1 -1
- package/dist/capability-expiry-suite.js +6 -2
- package/dist/capability-expiry-suite.js.map +1 -1
- package/dist/capability-suite.d.ts.map +1 -1
- package/dist/capability-suite.js +9 -0
- package/dist/capability-suite.js.map +1 -1
- package/dist/caused-by-suite.d.ts.map +1 -1
- package/dist/caused-by-suite.js +54 -10
- package/dist/caused-by-suite.js.map +1 -1
- package/dist/connect-link-suite.d.ts +19 -0
- package/dist/connect-link-suite.d.ts.map +1 -0
- package/dist/connect-link-suite.js +215 -0
- package/dist/connect-link-suite.js.map +1 -0
- package/dist/entity-state-migration-suite.d.ts +16 -0
- package/dist/entity-state-migration-suite.d.ts.map +1 -0
- package/dist/entity-state-migration-suite.js +305 -0
- package/dist/entity-state-migration-suite.js.map +1 -0
- package/dist/entity-state-module.d.ts +183 -0
- package/dist/entity-state-module.d.ts.map +1 -1
- package/dist/entity-state-module.js +139 -1
- package/dist/entity-state-module.js.map +1 -1
- package/dist/entity-state-suite.d.ts.map +1 -1
- package/dist/entity-state-suite.js +35 -12
- package/dist/entity-state-suite.js.map +1 -1
- package/dist/entity-trash-module.d.ts +439 -0
- package/dist/entity-trash-module.d.ts.map +1 -0
- package/dist/entity-trash-module.js +287 -0
- package/dist/entity-trash-module.js.map +1 -0
- package/dist/entity-trash-suite.d.ts +59 -0
- package/dist/entity-trash-suite.d.ts.map +1 -0
- package/dist/entity-trash-suite.js +568 -0
- package/dist/entity-trash-suite.js.map +1 -0
- package/dist/erasure-module.d.ts +259 -0
- package/dist/erasure-module.d.ts.map +1 -0
- package/dist/erasure-module.js +251 -0
- package/dist/erasure-module.js.map +1 -0
- package/dist/index.d.ts +13 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -1
- package/dist/index.js.map +1 -1
- package/dist/job-run-suite.d.ts.map +1 -1
- package/dist/job-run-suite.js +29 -15
- package/dist/job-run-suite.js.map +1 -1
- package/dist/list-suite.d.ts.map +1 -1
- package/dist/list-suite.js +101 -1
- package/dist/list-suite.js.map +1 -1
- package/dist/membership-executor-suite.d.ts.map +1 -1
- package/dist/membership-executor-suite.js +60 -9
- package/dist/membership-executor-suite.js.map +1 -1
- package/dist/migration-comments-suite.d.ts +3 -0
- package/dist/migration-comments-suite.d.ts.map +1 -0
- package/dist/migration-comments-suite.js +92 -0
- package/dist/migration-comments-suite.js.map +1 -0
- package/dist/migration-comments.d.ts +3 -0
- package/dist/migration-comments.d.ts.map +1 -0
- package/dist/migration-comments.js +50 -0
- package/dist/migration-comments.js.map +1 -0
- package/dist/migration-digest-suite.d.ts +3 -0
- package/dist/migration-digest-suite.d.ts.map +1 -0
- package/dist/migration-digest-suite.js +175 -0
- package/dist/migration-digest-suite.js.map +1 -0
- package/dist/modules.d.ts +542 -0
- package/dist/modules.d.ts.map +1 -1
- package/dist/modules.js +167 -7
- package/dist/modules.js.map +1 -1
- package/dist/peer-suite.d.ts +2 -1
- package/dist/peer-suite.d.ts.map +1 -1
- package/dist/peer-suite.js +103 -1
- package/dist/peer-suite.js.map +1 -1
- package/dist/permission-suite.d.ts.map +1 -1
- package/dist/permission-suite.js +515 -2
- package/dist/permission-suite.js.map +1 -1
- package/dist/schedule-suite.d.ts +4 -1
- package/dist/schedule-suite.d.ts.map +1 -1
- package/dist/schedule-suite.js +150 -2
- package/dist/schedule-suite.js.map +1 -1
- package/dist/scope-host-suite.d.ts.map +1 -1
- package/dist/scope-host-suite.js +215 -2
- package/dist/scope-host-suite.js.map +1 -1
- package/dist/split-cases.d.ts +12 -0
- package/dist/split-cases.d.ts.map +1 -0
- package/dist/split-cases.js +59 -0
- package/dist/split-cases.js.map +1 -0
- package/dist/subject-erasure-suite.d.ts +6 -0
- package/dist/subject-erasure-suite.d.ts.map +1 -0
- package/dist/subject-erasure-suite.js +287 -0
- package/dist/subject-erasure-suite.js.map +1 -0
- package/dist/switch-audit-fault.d.ts +48 -0
- package/dist/switch-audit-fault.d.ts.map +1 -0
- package/dist/switch-audit-fault.js +80 -0
- package/dist/switch-audit-fault.js.map +1 -0
- package/dist/system-switch-suite.d.ts +2 -1
- package/dist/system-switch-suite.d.ts.map +1 -1
- package/dist/system-switch-suite.js +90 -0
- package/dist/system-switch-suite.js.map +1 -1
- package/dist/vertical-events-suite.d.ts +41 -0
- package/dist/vertical-events-suite.d.ts.map +1 -1
- package/dist/vertical-events-suite.js +55 -0
- package/dist/vertical-events-suite.js.map +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration-comments.d.ts","sourceRoot":"","sources":["../src/migration-comments.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,kBAAkB,EAAoB,MAAM,sBAAsB,CAAC;AAEjF,eAAO,MAAM,eAAe,EAAE,kBAuC7B,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #2068, Codex #2084 r5: a module's migrations with comments in their DDL, run to completion on
|
|
3
|
+
* every adapter. SQLite stores a `CREATE TABLE` as written and a later `ALTER TABLE … DROP COLUMN`
|
|
4
|
+
* rewrites that stored text; workerd's SQLite fails the rewrite ("incomplete input") when the
|
|
5
|
+
* dropped column is the last one and line comments come before it. The kernel executes migrations
|
|
6
|
+
* comment-blanked (`executableSqlStatements`), so the stored text carries none and the drop runs.
|
|
7
|
+
* The twin: `--` and `/*` inside string literals are data, not comments, and arrive intact.
|
|
8
|
+
*/
|
|
9
|
+
import { moduleManifest } from '@substrat-run/contracts';
|
|
10
|
+
export const commentedDdlMod = {
|
|
11
|
+
manifest: moduleManifest.parse({
|
|
12
|
+
id: '@test/commented-ddl',
|
|
13
|
+
version: '1.0.0',
|
|
14
|
+
kernelContract: '^0.0.1',
|
|
15
|
+
permissions: [],
|
|
16
|
+
events: { emits: [], consumes: [] },
|
|
17
|
+
migrations: { journalDir: './migrations', compatibleFrom: '1.0.0' },
|
|
18
|
+
attachmentTargets: [],
|
|
19
|
+
entitlementKey: 'commented-ddl',
|
|
20
|
+
}),
|
|
21
|
+
migrations: [
|
|
22
|
+
{
|
|
23
|
+
version: '0001-create',
|
|
24
|
+
sql: `
|
|
25
|
+
-- The module's run log. Every column documented in place, as authored DDL tends to be.
|
|
26
|
+
CREATE TABLE cm_runs (
|
|
27
|
+
id TEXT PRIMARY KEY, -- one row per run
|
|
28
|
+
/* what the run was asked to do; free text */
|
|
29
|
+
note TEXT DEFAULT '-- not a comment; /* nor this */',
|
|
30
|
+
-- when it finished, or NULL (its answer came back
|
|
31
|
+
-- too late). Dropped by 0002.
|
|
32
|
+
finished_at TEXT
|
|
33
|
+
);
|
|
34
|
+
INSERT INTO cm_runs (id, note) VALUES ('r1', 'keep -- this; and /* that */ too');`,
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
version: '0002-drop-last',
|
|
38
|
+
sql: '-- the last column goes\nALTER TABLE cm_runs DROP COLUMN finished_at;',
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
operations: {
|
|
42
|
+
'commented-ddl/read': ((ctx) => ({
|
|
43
|
+
columns: ctx.sql.query("SELECT name FROM pragma_table_info('cm_runs')").map((r) => r.name),
|
|
44
|
+
noteDefault: ctx.sql.query("SELECT dflt_value AS d FROM pragma_table_info('cm_runs') WHERE name = 'note'")[0]?.d,
|
|
45
|
+
rows: ctx.sql.query('SELECT id, note FROM cm_runs ORDER BY id'),
|
|
46
|
+
stored: ctx.sql.query("SELECT sql FROM sqlite_master WHERE name = 'cm_runs'")[0]?.sql,
|
|
47
|
+
})),
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=migration-comments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration-comments.js","sourceRoot":"","sources":["../src/migration-comments.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAGzD,MAAM,CAAC,MAAM,eAAe,GAAuB;IACjD,QAAQ,EAAE,cAAc,CAAC,KAAK,CAAC;QAC7B,EAAE,EAAE,qBAAqB;QACzB,OAAO,EAAE,OAAO;QAChB,cAAc,EAAE,QAAQ;QACxB,WAAW,EAAE,EAAE;QACf,MAAM,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE;QACnC,UAAU,EAAE,EAAE,UAAU,EAAE,cAAc,EAAE,cAAc,EAAE,OAAO,EAAE;QACnE,iBAAiB,EAAE,EAAE;QACrB,cAAc,EAAE,eAAe;KAChC,CAAC;IACF,UAAU,EAAE;QACV;YACE,OAAO,EAAE,aAAa;YACtB,GAAG,EAAE;;;;;;;;;;0FAU+E;SACrF;QACD;YACE,OAAO,EAAE,gBAAgB;YACzB,GAAG,EAAE,uEAAuE;SAC7E;KACF;IACD,UAAU,EAAE;QACV,oBAAoB,EAAE,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;YAC/B,OAAO,EAAE,GAAG,CAAC,GAAG,CAAC,KAAK,CAAmB,+CAA+C,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;YAC5G,WAAW,EAAE,GAAG,CAAC,GAAG,CAAC,KAAK,CAAgB,8EAA8E,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAC/H,IAAI,EAAE,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,0CAA0C,CAAC;YAC/D,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC,KAAK,CAAkB,sDAAsD,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG;SACvG,CAAC,CAAqC;KACxC;CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration-digest-suite.d.ts","sourceRoot":"","sources":["../src/migration-digest-suite.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAsB9D,wBAAgB,4BAA4B,CAC1C,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,OAAO,CAAC,gBAAgB,CAAC,GAC3C,IAAI,CA8JN"}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contract suite for the SQL digest a scope's migration journal records (#2066).
|
|
3
|
+
*
|
|
4
|
+
* A scope used to journal an applied migration by `(module_id, version)` alone, so a later
|
|
5
|
+
* migration with the same version and different SQL was skipped as already applied and the
|
|
6
|
+
* scope kept whichever schema it got first. Both adapters now record the SHA-256 of the exact
|
|
7
|
+
* SQL beside the version, and hold an authored migration to it.
|
|
8
|
+
*
|
|
9
|
+
* A scope that "ran different SQL" is made the way an operator would meet one: its own dump,
|
|
10
|
+
* with the journal's digest edited, restored onto it. That is an adapter-neutral door, and a
|
|
11
|
+
* restore refreshes what the host believes was applied, so the next pass reads the edited row.
|
|
12
|
+
*
|
|
13
|
+
* `listMod` because it carries both kinds of migration: two authored versions and the
|
|
14
|
+
* kernel-derived list index, which is versioned by its declaration and not held to a digest.
|
|
15
|
+
*/
|
|
16
|
+
import { describe, it, expect, beforeAll, afterAll } from 'vitest';
|
|
17
|
+
import { platformActorId, principalId, scopeId, tenantId } from '@substrat-run/contracts';
|
|
18
|
+
import { moduleMigrations, ulid } from '@substrat-run/kernel';
|
|
19
|
+
import { listMod } from './modules.js';
|
|
20
|
+
const MODULE = '@test/list';
|
|
21
|
+
/** `_substrat_migrations` as `sqlite_master` held it before #2066 — what a pre-digest dump carries. */
|
|
22
|
+
const PRE_DIGEST_JOURNAL_DDL = `CREATE TABLE _substrat_migrations (
|
|
23
|
+
module_id TEXT NOT NULL,
|
|
24
|
+
version TEXT NOT NULL,
|
|
25
|
+
applied_at TEXT NOT NULL,
|
|
26
|
+
duration_ms INTEGER,
|
|
27
|
+
rows_changed INTEGER,
|
|
28
|
+
PRIMARY KEY (module_id, version)
|
|
29
|
+
)`;
|
|
30
|
+
const AUTHORED = '0001-init';
|
|
31
|
+
/** SHA-256 hex, computed here with Web Crypto rather than through the kernel helper under test. */
|
|
32
|
+
const sha256 = async (text) => [...new Uint8Array(await crypto.subtle.digest('SHA-256', new TextEncoder().encode(text)))]
|
|
33
|
+
.map((b) => b.toString(16).padStart(2, '0'))
|
|
34
|
+
.join('');
|
|
35
|
+
export function migrationDigestContractSuite(adapterName, makeFixture) {
|
|
36
|
+
describe(`migration SQL digests (#2066): ${adapterName}`, () => {
|
|
37
|
+
let fixture;
|
|
38
|
+
let host;
|
|
39
|
+
const t = tenantId.parse(ulid());
|
|
40
|
+
const s = scopeId.parse(ulid());
|
|
41
|
+
const staff = platformActorId.parse(ulid());
|
|
42
|
+
const alice = principalId.parse(ulid());
|
|
43
|
+
/** The scope's own dump, taken once it has migrated — what every case restores from. */
|
|
44
|
+
let clean;
|
|
45
|
+
/** The registered SQL's digest per version, derived set included. */
|
|
46
|
+
let expected;
|
|
47
|
+
const add = async () => (await host.getScope(alice, t, s)).invoke('list/add', { id: ulid(), number: ulid(), status: 'open', kind: 'a' });
|
|
48
|
+
/** This module's journal rows in a dump: version → { digest, appliedAt }. */
|
|
49
|
+
const journalOf = (dump) => {
|
|
50
|
+
const table = dump.tables.find((tbl) => tbl.name === '_substrat_migrations');
|
|
51
|
+
const col = (name) => table.columns.indexOf(name);
|
|
52
|
+
return new Map(table.rows
|
|
53
|
+
.filter((r) => r[col('module_id')] === MODULE)
|
|
54
|
+
.map((r) => [String(r[col('version')]), { digest: r[col('sql_digest')] ?? null, appliedAt: r[col('applied_at')] }]));
|
|
55
|
+
};
|
|
56
|
+
const journal = async () => journalOf(await host.admin.exportScope(staff, t, s));
|
|
57
|
+
/** `clean`, with this module's journal digest rewritten for the versions `edit` names. */
|
|
58
|
+
const restoreWith = async (edit) => {
|
|
59
|
+
const tables = clean.tables.map((tbl) => {
|
|
60
|
+
if (tbl.name !== '_substrat_migrations')
|
|
61
|
+
return tbl;
|
|
62
|
+
const col = (name) => tbl.columns.indexOf(name);
|
|
63
|
+
return {
|
|
64
|
+
...tbl,
|
|
65
|
+
rows: tbl.rows.map((r) => {
|
|
66
|
+
const version = String(r[col('version')]);
|
|
67
|
+
if (r[col('module_id')] !== MODULE || !(version in edit))
|
|
68
|
+
return r;
|
|
69
|
+
const row = [...r];
|
|
70
|
+
row[col('sql_digest')] = edit[version] ?? null;
|
|
71
|
+
return row;
|
|
72
|
+
}),
|
|
73
|
+
};
|
|
74
|
+
});
|
|
75
|
+
await host.restoreScope(staff, t, s, { ...clean, tables });
|
|
76
|
+
};
|
|
77
|
+
beforeAll(async () => {
|
|
78
|
+
fixture = await makeFixture();
|
|
79
|
+
host = fixture.host;
|
|
80
|
+
host.registerModule(listMod);
|
|
81
|
+
await host.admin.createTenant(staff, { id: t, slug: `digest-${ulid().toLowerCase()}`, name: 'Digest' });
|
|
82
|
+
await host.admin.grantEntitlement(staff, t, 'list');
|
|
83
|
+
await host.provisionScope(staff, { tenantId: t, scopeId: s, vertical: 'list-vertical' });
|
|
84
|
+
await host.admin.activateScope(staff, t, s);
|
|
85
|
+
await add();
|
|
86
|
+
clean = await host.admin.exportScope(staff, t, s);
|
|
87
|
+
expected = new Map(await Promise.all(moduleMigrations(listMod).map(async (m) => [m.version, await sha256(m.sql)])));
|
|
88
|
+
});
|
|
89
|
+
afterAll(async () => {
|
|
90
|
+
await fixture?.cleanup();
|
|
91
|
+
});
|
|
92
|
+
it("a fresh scope records the SHA-256 of each migration's exact SQL, derived DDL included", async () => {
|
|
93
|
+
// Three: the two authored versions and the kernel's list index, so neither kind is vacuous.
|
|
94
|
+
expect([...expected.keys()]).toEqual(['0001-init', '0002-hold', expect.stringMatching(/^list\//)]);
|
|
95
|
+
const rows = journalOf(clean);
|
|
96
|
+
expect(new Map([...rows].map(([v, r]) => [v, r.digest]))).toEqual(expected);
|
|
97
|
+
});
|
|
98
|
+
it('the same digest is skipped: nothing re-runs, and the scope serves', async () => {
|
|
99
|
+
const before = await journal();
|
|
100
|
+
await restoreWith({});
|
|
101
|
+
await expect(add()).resolves.toBeDefined();
|
|
102
|
+
// Not re-applied: the rows are the ones the first pass wrote, applied_at and all.
|
|
103
|
+
expect(await journal()).toEqual(before);
|
|
104
|
+
expect((await host.migrateScope(t, s)).status).not.toBe('failed');
|
|
105
|
+
});
|
|
106
|
+
it('a different digest fails the scope closed, naming the module, the version and both digests', async () => {
|
|
107
|
+
const ran = await sha256('CREATE TABLE list_orders (id TEXT PRIMARY KEY);');
|
|
108
|
+
const registered = expected.get(AUTHORED);
|
|
109
|
+
await restoreWith({ [AUTHORED]: ran });
|
|
110
|
+
const named = new RegExp(`migration failed for ${MODULE}@${AUTHORED} — scope fails closed: .*applied sha256 ${ran}, registered sha256 ${registered}`);
|
|
111
|
+
await expect(add()).rejects.toThrow(named);
|
|
112
|
+
// The sweep's door says the same, as the structured failure a failed migration leaves.
|
|
113
|
+
const outcome = await host.migrateScope(t, s);
|
|
114
|
+
expect(outcome).toEqual({ status: 'failed', failure: { version: `${MODULE}@${AUTHORED}`, error: expect.any(String) } });
|
|
115
|
+
const failure = outcome.failure;
|
|
116
|
+
expect(failure.error).toContain(ran);
|
|
117
|
+
expect(failure.error).toContain(registered);
|
|
118
|
+
// Recovery: the scope's journal agrees with the deployment again, and it serves.
|
|
119
|
+
await restoreWith({});
|
|
120
|
+
await expect(add()).resolves.toBeDefined();
|
|
121
|
+
});
|
|
122
|
+
it("a dump whose journal carries a NULL digest is refused, and the scope is left as it was", async () => {
|
|
123
|
+
// A modern dump with an authored digest cleared — corrupted, or edited to hide a mismatch.
|
|
124
|
+
// A NULL cannot say where it came from, so the journal's fence refuses it on the way in.
|
|
125
|
+
const before = await journal();
|
|
126
|
+
await expect(restoreWith({ [AUTHORED]: null })).rejects.toThrow('a migration journal row must carry its sql_digest (#2066)');
|
|
127
|
+
expect(await journal()).toEqual(before);
|
|
128
|
+
await expect(add()).resolves.toBeDefined();
|
|
129
|
+
});
|
|
130
|
+
/** `clean` with the journal reshaped: its `sql_digest` cells dropped, and its DDL set to `ddl`. */
|
|
131
|
+
const withoutDigestColumn = (ddl) => ({
|
|
132
|
+
...clean,
|
|
133
|
+
tables: clean.tables.map((tbl) => {
|
|
134
|
+
if (tbl.name !== '_substrat_migrations')
|
|
135
|
+
return tbl;
|
|
136
|
+
const at = tbl.columns.indexOf('sql_digest');
|
|
137
|
+
return {
|
|
138
|
+
...tbl,
|
|
139
|
+
ddl: ddl ?? tbl.ddl,
|
|
140
|
+
columns: tbl.columns.filter((_, i) => i !== at),
|
|
141
|
+
rows: tbl.rows.map((r) => r.filter((_, i) => i !== at)),
|
|
142
|
+
};
|
|
143
|
+
}),
|
|
144
|
+
});
|
|
145
|
+
it('a dump taken before digests were recorded restores with every journal row marked legacy, and serves', async () => {
|
|
146
|
+
// The journal exactly as a pre-#2066 kernel exported it: the DDL `sqlite_master` held for it
|
|
147
|
+
// then, and the columns that DDL declares.
|
|
148
|
+
await host.restoreScope(staff, t, s, withoutDigestColumn(PRE_DIGEST_JOURNAL_DDL));
|
|
149
|
+
const rows = await journal();
|
|
150
|
+
expect([...rows.values()].map((r) => r.digest)).toEqual([...expected.keys()].map(() => 'legacy'));
|
|
151
|
+
await expect(add()).resolves.toBeDefined();
|
|
152
|
+
expect((await host.migrateScope(t, s)).status).not.toBe('failed');
|
|
153
|
+
await restoreWith({});
|
|
154
|
+
});
|
|
155
|
+
it('a current dump with the digest column stripped is not taken for a legacy one: refused, the scope as it was', async () => {
|
|
156
|
+
// Its journal DDL still declares sql_digest: neither a dump from before digests nor a whole
|
|
157
|
+
// one from after. Read as legacy, it would unprotect every row.
|
|
158
|
+
const before = await journal();
|
|
159
|
+
await expect(host.restoreScope(staff, t, s, withoutDigestColumn())).rejects.toThrow("the dump's _substrat_migrations declares sql_digest in its DDL but carries no such column");
|
|
160
|
+
expect(await journal()).toEqual(before);
|
|
161
|
+
await expect(add()).resolves.toBeDefined();
|
|
162
|
+
});
|
|
163
|
+
it('derived DDL is held to its declaration, not its digest', async () => {
|
|
164
|
+
const derived = [...expected.keys()].find((v) => v.startsWith('list/'));
|
|
165
|
+
const other = await sha256('-- the kernel spelled this index another way');
|
|
166
|
+
await restoreWith({ [derived]: other });
|
|
167
|
+
await expect(add()).resolves.toBeDefined();
|
|
168
|
+
expect((await host.migrateScope(t, s)).status).not.toBe('failed');
|
|
169
|
+
// Recorded as what ran, never rewritten.
|
|
170
|
+
expect((await journal()).get(derived)?.digest).toBe(other);
|
|
171
|
+
await restoreWith({});
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
//# sourceMappingURL=migration-digest-suite.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration-digest-suite.js","sourceRoot":"","sources":["../src/migration-digest-suite.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAkB,MAAM,yBAAyB,CAAC;AAC1G,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAkB,MAAM,sBAAsB,CAAC;AAE9E,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,MAAM,MAAM,GAAG,YAAY,CAAC;AAE5B,uGAAuG;AACvG,MAAM,sBAAsB,GAAG;;;;;;;IAO3B,CAAC;AACL,MAAM,QAAQ,GAAG,WAAW,CAAC;AAE7B,mGAAmG;AACnG,MAAM,MAAM,GAAG,KAAK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