@substrat-run/contract-tests 0.129.0 → 0.130.1
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/directory-restore-suite.d.ts +29 -0
- package/dist/directory-restore-suite.d.ts.map +1 -0
- package/dist/directory-restore-suite.js +330 -0
- package/dist/directory-restore-suite.js.map +1 -0
- package/dist/directory-shapes.d.ts +29 -0
- package/dist/directory-shapes.d.ts.map +1 -0
- package/dist/directory-shapes.js +224 -0
- package/dist/directory-shapes.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/modules.d.ts.map +1 -1
- package/dist/modules.js +20 -1
- package/dist/modules.js.map +1 -1
- package/dist/scope-host-suite.d.ts.map +1 -1
- package/dist/scope-host-suite.js +37 -12
- package/dist/scope-host-suite.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type ScopeDumpTable } from '@substrat-run/contracts';
|
|
2
|
+
/**
|
|
3
|
+
* A directory restore builds every directory table from the running code's schema, and the
|
|
4
|
+
* dump contributes rows only, by column name (#1912). #1898 held the directory's `_substrat_*`
|
|
5
|
+
* tables to that; this holds the platform's registries to it too (`tenants`, `scopes`,
|
|
6
|
+
* `hostnames`, `verticals`, `vertical_versions`, `orgs`, `tenant_stores`, `blob_stores`, …), and
|
|
7
|
+
* refuses a table the directory does not build at all.
|
|
8
|
+
*
|
|
9
|
+
* The harness hands each case a directory of its own, and reads it without writing to it (an
|
|
10
|
+
* export records an access-log row on the host path, which a byte-for-byte comparison would
|
|
11
|
+
* trip over).
|
|
12
|
+
*/
|
|
13
|
+
export interface RestorableDirectory {
|
|
14
|
+
/** Every table as the directory's storage holds it: DDL, columns and rows, in name order. */
|
|
15
|
+
snapshot(): Promise<ScopeDumpTable[]>;
|
|
16
|
+
/** The adapter's directory restore. */
|
|
17
|
+
restore(tables: ScopeDumpTable[]): Promise<void>;
|
|
18
|
+
/** A vertical registered by the adapter's own INSERT, which names no capability column. */
|
|
19
|
+
registerVertical(slug: string): Promise<void>;
|
|
20
|
+
/** Runs what a restore leaves to run after it: the #1764 split, where it is not run inline. */
|
|
21
|
+
settle(): Promise<void>;
|
|
22
|
+
close(): Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
export interface DirectoryRestoreHarness {
|
|
25
|
+
/** A freshly built directory that no other case reads or writes. */
|
|
26
|
+
open(): Promise<RestorableDirectory>;
|
|
27
|
+
}
|
|
28
|
+
export declare function directoryRestoreSuite(name: string, harness: DirectoryRestoreHarness): void;
|
|
29
|
+
//# sourceMappingURL=directory-restore-suite.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"directory-restore-suite.d.ts","sourceRoot":"","sources":["../src/directory-restore-suite.ts"],"names":[],"mappings":"AACA,OAAO,EAAmB,KAAK,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAG/E;;;;;;;;;;GAUG;AACH,MAAM,WAAW,mBAAmB;IAClC,6FAA6F;IAC7F,QAAQ,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC;IACtC,uCAAuC;IACvC,OAAO,CAAC,MAAM,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjD,2FAA2F;IAC3F,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9C,+FAA+F;IAC/F,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACxB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED,MAAM,WAAW,uBAAuB;IACtC,oEAAoE;IACpE,IAAI,IAAI,OAAO,CAAC,mBAAmB,CAAC,CAAC;CACtC;AAmFD,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,uBAAuB,GAAG,IAAI,CA8P1F"}
|
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { namesSpineTable } from '@substrat-run/contracts';
|
|
3
|
+
import { ALTERED_SHAPES, CREATED_SHAPES } from './directory-shapes.js';
|
|
4
|
+
/** The columns a restore could not have filled from the dump, and what today's DDL gives them. */
|
|
5
|
+
const DEFAULTS = {
|
|
6
|
+
status: 'active',
|
|
7
|
+
storage_shape: 'A',
|
|
8
|
+
schema_version: '0',
|
|
9
|
+
migration_attempts: 0,
|
|
10
|
+
canonical: 0,
|
|
11
|
+
listed: 0,
|
|
12
|
+
installs_blocked: 0,
|
|
13
|
+
tenant_provisioner: 0,
|
|
14
|
+
email_sender: 0,
|
|
15
|
+
};
|
|
16
|
+
const INTEGER_COLUMNS = new Set([...Object.keys(DEFAULTS).filter((c) => typeof DEFAULTS[c] === 'number'), 'ordinal']);
|
|
17
|
+
/** A live tenant row's NOT NULL columns. */
|
|
18
|
+
const LIVE_TENANT = { tenant_id: 't-0', status: 'active', created_at: 'c' };
|
|
19
|
+
/** A live pre-directory scope row: its NOT NULL columns, and a NULL slug for the backfill to fill. */
|
|
20
|
+
const LIVE_SCOPE = { tenant_id: 't-0', storage_shape: 'A', status: 'active', schema_version: '0', created_at: 'c' };
|
|
21
|
+
/**
|
|
22
|
+
* The value a crafted row carries in `column`: distinct per table and column, so a value that
|
|
23
|
+
* landed in the wrong column shows. `1` in an integer column, which for the three capability
|
|
24
|
+
* columns is the value a staff grant writes. The #1764 progress columns are dumped as a version
|
|
25
|
+
* the split has not reached, and the manifest as one it can parse.
|
|
26
|
+
*/
|
|
27
|
+
const valueFor = (table, column) => {
|
|
28
|
+
if (column === 'provisioned_by_tenant' || column === 'migration_count' || column === 'migrations_split')
|
|
29
|
+
return null;
|
|
30
|
+
if (column === 'manifest_json')
|
|
31
|
+
return '{"version":"1.0.0"}';
|
|
32
|
+
return INTEGER_COLUMNS.has(column) ? 1 : `${table}.${column}`;
|
|
33
|
+
};
|
|
34
|
+
const find = (tables, name) => {
|
|
35
|
+
const t = tables.find((x) => x.name === name);
|
|
36
|
+
if (!t)
|
|
37
|
+
throw new Error(`no table ${name} in the directory`);
|
|
38
|
+
return t;
|
|
39
|
+
};
|
|
40
|
+
const withTable = (tables, name, edit) => tables.map((t) => (t.name === name ? edit(t) : t));
|
|
41
|
+
const rowOf = (columns, values) => columns.map((c) => values[c] ?? null);
|
|
42
|
+
/** One table's rows as objects, keyed by column name. */
|
|
43
|
+
const recordsOf = (t) => t.rows.map((r) => Object.fromEntries(t.columns.map((c, i) => [c, r[i]])));
|
|
44
|
+
const crafted = (table, columns) => columns.map((c) => valueFor(table, c));
|
|
45
|
+
/** A table in one of its older shapes, holding one crafted row. */
|
|
46
|
+
const inShape = (shape) => ({
|
|
47
|
+
ddl: shape.ddl,
|
|
48
|
+
columns: shape.columns,
|
|
49
|
+
rows: [crafted(shape.table, shape.columns)],
|
|
50
|
+
});
|
|
51
|
+
/**
|
|
52
|
+
* The row a restore of `shape`'s crafted row must leave in today's table: the dumped values by
|
|
53
|
+
* name, today's default for a column the shape did not have, and a pre-directory scope row's
|
|
54
|
+
* naming columns filled the way the legacy backfill fills them. A version's #1764 progress is
|
|
55
|
+
* whatever the split then wrote, so it is asserted apart.
|
|
56
|
+
*/
|
|
57
|
+
const expectedRow = (shape, columns) => {
|
|
58
|
+
const dumped = new Set(shape.columns);
|
|
59
|
+
const out = {};
|
|
60
|
+
for (const c of columns) {
|
|
61
|
+
if (shape.table === 'vertical_versions' && (c === 'migration_count' || c === 'migrations_split'))
|
|
62
|
+
continue;
|
|
63
|
+
out[c] = dumped.has(c) ? valueFor(shape.table, c) : (DEFAULTS[c] ?? null);
|
|
64
|
+
}
|
|
65
|
+
if (shape.table === 'scopes') {
|
|
66
|
+
if (!dumped.has('slug'))
|
|
67
|
+
out.slug = String(out.scope_id).toLowerCase();
|
|
68
|
+
if (!dumped.has('kind'))
|
|
69
|
+
out.kind = 'scope';
|
|
70
|
+
if (!dumped.has('name'))
|
|
71
|
+
out.name = out.slug;
|
|
72
|
+
}
|
|
73
|
+
return out;
|
|
74
|
+
};
|
|
75
|
+
/** The scopes table as the directory's first day built it, before its naming columns. */
|
|
76
|
+
const OLDEST_SCOPES = CREATED_SHAPES.find((s) => s.table === 'scopes');
|
|
77
|
+
/** That table holding one live pre-directory row per id, each with a NULL slug. */
|
|
78
|
+
const oldScopes = (ids) => ({
|
|
79
|
+
name: 'scopes',
|
|
80
|
+
ddl: OLDEST_SCOPES.ddl,
|
|
81
|
+
columns: OLDEST_SCOPES.columns,
|
|
82
|
+
rows: ids.map((id) => rowOf(OLDEST_SCOPES.columns, { ...LIVE_SCOPE, scope_id: id })),
|
|
83
|
+
});
|
|
84
|
+
export function directoryRestoreSuite(name, harness) {
|
|
85
|
+
const using = async (fn) => {
|
|
86
|
+
const dir = await harness.open();
|
|
87
|
+
try {
|
|
88
|
+
return await fn(dir, await dir.snapshot());
|
|
89
|
+
}
|
|
90
|
+
finally {
|
|
91
|
+
await dir.close();
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
/** The directory's tables and their DDL, which a restore must leave as this code builds them. */
|
|
95
|
+
const shapeOf = (tables) => tables.map((t) => [t.name, t.ddl, t.columns]);
|
|
96
|
+
describe(`directory restore builds every table from its own schema (#1912): ${name}`, () => {
|
|
97
|
+
it('a DEFAULT 1 on the three capability columns in the dump does not decide a later registration', async () => {
|
|
98
|
+
await using(async (dir, fresh) => {
|
|
99
|
+
const verticals = find(fresh, 'verticals');
|
|
100
|
+
const granted = ['tenant_provisioner', 'email_sender', 'installs_blocked'];
|
|
101
|
+
let ddl = verticals.ddl;
|
|
102
|
+
for (const c of granted)
|
|
103
|
+
ddl = ddl.replace(new RegExp(`\\b(${c}\\s+INTEGER\\s+NOT NULL\\s+DEFAULT\\s+)0`), (_, head) => `${head}1`);
|
|
104
|
+
expect(ddl.match(/NOT NULL\s+DEFAULT\s+1\b/g)).toHaveLength(granted.length);
|
|
105
|
+
// A row that was granted all three in the copy keeps them: rows are the dump's to say.
|
|
106
|
+
await dir.restore(withTable(fresh, 'verticals', (t) => ({ ...t, ddl, rows: [crafted('verticals', t.columns)] })));
|
|
107
|
+
await dir.registerVertical('registered-after');
|
|
108
|
+
const after = await dir.snapshot();
|
|
109
|
+
expect(find(after, 'verticals').ddl).toBe(verticals.ddl);
|
|
110
|
+
const bySlug = Object.fromEntries(recordsOf(find(after, 'verticals')).map((r) => [r.slug, r]));
|
|
111
|
+
const capabilities = (slug) => Object.fromEntries(granted.map((c) => [c, bySlug[slug]?.[c]]));
|
|
112
|
+
expect(capabilities('registered-after')).toEqual({ tenant_provisioner: 0, email_sender: 0, installs_blocked: 0 });
|
|
113
|
+
expect(capabilities('verticals.slug')).toEqual({ tenant_provisioner: 1, email_sender: 1, installs_blocked: 1 });
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
it('a COLLATE NOCASE on tenants.slug and hostnames.hostname is not carried: case variants are two rows', async () => {
|
|
117
|
+
await using(async (dir, fresh) => {
|
|
118
|
+
const nocase = (ddl, column) => {
|
|
119
|
+
const out = ddl.replace(new RegExp(`\\b(${column}\\s+TEXT)\\s+(NOT NULL|PRIMARY KEY)`), '$1 COLLATE NOCASE $2');
|
|
120
|
+
expect(out).not.toBe(ddl);
|
|
121
|
+
return out;
|
|
122
|
+
};
|
|
123
|
+
let tables = withTable(fresh, 'tenants', (t) => ({
|
|
124
|
+
...t,
|
|
125
|
+
ddl: nocase(t.ddl, 'slug'),
|
|
126
|
+
rows: ['Acme', 'acme'].map((slug, i) => rowOf(t.columns, { ...LIVE_TENANT, tenant_id: `t-${i}`, slug, name: slug })),
|
|
127
|
+
}));
|
|
128
|
+
tables = withTable(tables, 'hostnames', (t) => ({
|
|
129
|
+
...t,
|
|
130
|
+
ddl: nocase(t.ddl, 'hostname'),
|
|
131
|
+
rows: ['App.example.com', 'app.example.com'].map((hostname) => rowOf(t.columns, { hostname, tenant_id: 't-0', scope_id: 's', surface: 'app', status: 'active', canonical: 0, created_at: 'c' })),
|
|
132
|
+
}));
|
|
133
|
+
await dir.restore(tables);
|
|
134
|
+
const after = await dir.snapshot();
|
|
135
|
+
expect(shapeOf(after)).toEqual(shapeOf(fresh));
|
|
136
|
+
expect(recordsOf(find(after, 'tenants')).map((r) => r.slug)).toEqual(['Acme', 'acme']);
|
|
137
|
+
expect(recordsOf(find(after, 'hostnames')).map((r) => r.hostname).sort()).toEqual(['App.example.com', 'app.example.com']);
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
it('a REFERENCES in a registry’s own DDL is not carried', async () => {
|
|
141
|
+
await using(async (dir, fresh) => {
|
|
142
|
+
// Carried, this row would fail the commit: its tenant is not in the dump.
|
|
143
|
+
const tables = withTable(fresh, 'scopes', (t) => ({
|
|
144
|
+
...t,
|
|
145
|
+
ddl: t.ddl.replace(/\b(tenant_id\s+TEXT\s+NOT NULL)/, '$1 REFERENCES tenants(tenant_id)'),
|
|
146
|
+
rows: [crafted('scopes', t.columns)],
|
|
147
|
+
}));
|
|
148
|
+
expect(find(tables, 'scopes').ddl).toMatch(/REFERENCES tenants/);
|
|
149
|
+
await dir.restore(tables);
|
|
150
|
+
const after = await dir.snapshot();
|
|
151
|
+
expect(find(after, 'scopes').ddl).toBe(find(fresh, 'scopes').ddl);
|
|
152
|
+
expect(find(after, 'scopes').rows).toHaveLength(1);
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
it('a registry column this code does not know is kept bare and lowercased, with its values', async () => {
|
|
156
|
+
await using(async (dir, fresh) => {
|
|
157
|
+
const tables = withTable(fresh, 'tenants', (t) => {
|
|
158
|
+
const columns = [...t.columns, 'Future_Note'];
|
|
159
|
+
return {
|
|
160
|
+
...t,
|
|
161
|
+
ddl: t.ddl.replace(/\)\s*$/, ", Future_Note TEXT NOT NULL COLLATE NOCASE DEFAULT 'x')"),
|
|
162
|
+
columns,
|
|
163
|
+
rows: [rowOf(columns, { ...LIVE_TENANT, slug: 'acme', name: 'Acme', Future_Note: 'kept' })],
|
|
164
|
+
};
|
|
165
|
+
});
|
|
166
|
+
await dir.restore(tables);
|
|
167
|
+
const t = find(await dir.snapshot(), 'tenants');
|
|
168
|
+
expect(t.columns.at(-1)).toBe('future_note');
|
|
169
|
+
expect(t.ddl).toMatch(/ "future_note"[,\n)]/);
|
|
170
|
+
expect(t.ddl).not.toMatch(/NOCASE|Future_Note|DEFAULT 'x'/);
|
|
171
|
+
expect(t.rows.map((r) => r.at(-1))).toEqual(['kept']);
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
describe('an older dump of each registry still restores, into today’s table', () => {
|
|
175
|
+
for (const shape of [...CREATED_SHAPES, ...ALTERED_SHAPES]) {
|
|
176
|
+
it(`${shape.table}, ${shape.since}`, async () => {
|
|
177
|
+
await using(async (dir, fresh) => {
|
|
178
|
+
const today = find(fresh, shape.table);
|
|
179
|
+
await dir.restore(withTable(fresh, shape.table, (t) => ({ ...t, ...inShape(shape) })));
|
|
180
|
+
await dir.settle();
|
|
181
|
+
const after = await dir.snapshot();
|
|
182
|
+
expect(shapeOf(after)).toEqual(shapeOf(fresh));
|
|
183
|
+
const [row, ...rest] = recordsOf(find(after, shape.table));
|
|
184
|
+
expect(rest).toEqual([]);
|
|
185
|
+
expect(row).toMatchObject(expectedRow(shape, today.columns));
|
|
186
|
+
// #1764's split still runs over a version the dump stored before it.
|
|
187
|
+
if (shape.table === 'vertical_versions')
|
|
188
|
+
expect(row.migrations_split).toBe(1);
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
it('a directory whose every registry is at its first shape', async () => {
|
|
193
|
+
await using(async (dir, fresh) => {
|
|
194
|
+
const first = new Map();
|
|
195
|
+
for (const s of CREATED_SHAPES)
|
|
196
|
+
if (!first.has(s.table))
|
|
197
|
+
first.set(s.table, s);
|
|
198
|
+
await dir.restore(fresh.map((t) => (first.has(t.name) ? { ...t, ...inShape(first.get(t.name)) } : t)));
|
|
199
|
+
await dir.settle();
|
|
200
|
+
const after = await dir.snapshot();
|
|
201
|
+
expect(shapeOf(after)).toEqual(shapeOf(fresh));
|
|
202
|
+
for (const [table, shape] of first) {
|
|
203
|
+
expect(recordsOf(find(after, table))).toEqual([expect.objectContaining(expectedRow(shape, find(fresh, table).columns))]);
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
it('a directory from before the tenant registry, holding only its scopes', async () => {
|
|
208
|
+
await using(async (dir, fresh) => {
|
|
209
|
+
await dir.restore([{ name: 'scopes', ...inShape(OLDEST_SCOPES) }]);
|
|
210
|
+
const after = await dir.snapshot();
|
|
211
|
+
expect(shapeOf(after)).toEqual(shapeOf(fresh));
|
|
212
|
+
expect(recordsOf(find(after, 'scopes'))).toEqual([expect.objectContaining(expectedRow(OLDEST_SCOPES, find(fresh, 'scopes').columns))]);
|
|
213
|
+
expect(find(after, 'tenants').rows).toEqual([]);
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
it('export → restore → export round-trips, every registry holding a row', async () => {
|
|
218
|
+
await using(async (dir, fresh) => {
|
|
219
|
+
await dir.restore(fresh.map((t) => (!namesSpineTable(t.name) ? { ...t, rows: [crafted(t.name, t.columns)] } : t)));
|
|
220
|
+
// The crafted version is one the #1764 split has not reached; it moves before the copy.
|
|
221
|
+
await dir.settle();
|
|
222
|
+
const before = await dir.snapshot();
|
|
223
|
+
expect(before.filter((t) => !namesSpineTable(t.name) && t.rows.length !== 1)).toEqual([]);
|
|
224
|
+
await dir.restore(before);
|
|
225
|
+
await dir.settle();
|
|
226
|
+
const after = await dir.snapshot();
|
|
227
|
+
expect(shapeOf(after)).toEqual(shapeOf(before));
|
|
228
|
+
for (const t of after) {
|
|
229
|
+
const was = find(before, t.name);
|
|
230
|
+
// The pure adapter records the restore in the admin log it just loaded; the Durable
|
|
231
|
+
// Object leaves that to its host.
|
|
232
|
+
if (t.name === '_substrat_admin_log') {
|
|
233
|
+
const action = t.columns.indexOf('action');
|
|
234
|
+
expect(t.rows.slice(0, was.rows.length)).toEqual(was.rows);
|
|
235
|
+
for (const r of t.rows.slice(was.rows.length))
|
|
236
|
+
expect(r[action]).toBe('restoreDirectory');
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
expect(t.rows).toEqual(was.rows);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
});
|
|
244
|
+
describe('refused, and the directory is left exactly as it was', () => {
|
|
245
|
+
const refusals = [
|
|
246
|
+
[
|
|
247
|
+
// The issue's second case: with foreign keys enforced, a row here would fail the delete
|
|
248
|
+
// of the tenant it names. Named with a second unbuilt table, to show both are named.
|
|
249
|
+
'tables this directory does not build, one of them REFERENCES tenants',
|
|
250
|
+
(tables) => [
|
|
251
|
+
...tables,
|
|
252
|
+
{ name: 'tenant_mirror', ddl: 'CREATE TABLE tenant_mirror (tenant_id TEXT REFERENCES tenants(tenant_id))', columns: ['tenant_id'], rows: [['t-0']] },
|
|
253
|
+
{ name: 'sqlitedata', ddl: 'CREATE TABLE sqlitedata (id INTEGER PRIMARY KEY, v TEXT)', columns: ['id', 'v'], rows: [] },
|
|
254
|
+
],
|
|
255
|
+
/this directory does not build: tenant_mirror, sqlitedata\b/,
|
|
256
|
+
],
|
|
257
|
+
// Both entries would load into the one table SQLite resolves them to, and the second could
|
|
258
|
+
// carry what the first's checks never saw. `assertDumpIdentifiers` folds case, as SQLite does.
|
|
259
|
+
...['tenants', '_substrat_roles'].map((table) => [
|
|
260
|
+
`a table listed twice, differing only in case: ${table}`,
|
|
261
|
+
(tables) => {
|
|
262
|
+
const t = find(tables, table);
|
|
263
|
+
const twin = { ...t, name: table.toUpperCase(), ddl: t.ddl.replace(new RegExp(`^(CREATE TABLE\\s+)"?${table}"?`, 'i'), `$1${table.toUpperCase()}`) };
|
|
264
|
+
return [...tables, twin];
|
|
265
|
+
},
|
|
266
|
+
new RegExp(`"${table.toUpperCase()}" is listed twice`),
|
|
267
|
+
]),
|
|
268
|
+
...['sqlite_master', 'SQLITE_SCHEMA', 'sqlite_sequence', '_cf_METADATA', '_cf_KV'].map((reserved) => [
|
|
269
|
+
`a table named like one SQLite or workerd keeps for itself: ${reserved}`,
|
|
270
|
+
(tables) => [...tables, { name: reserved, ddl: `CREATE TABLE ${reserved} (name TEXT)`, columns: ['name'], rows: [['x']] }],
|
|
271
|
+
new RegExp(`this directory does not build: ${reserved}\\b`),
|
|
272
|
+
]),
|
|
273
|
+
...['rowid', 'OID', '_rowid_'].map((alias) => [
|
|
274
|
+
`a registry column named ${alias}`,
|
|
275
|
+
(tables) => withTable(tables, 'tenants', (t) => ({
|
|
276
|
+
...t,
|
|
277
|
+
ddl: t.ddl.replace(/\)\s*$/, `, ${alias} INTEGER)`),
|
|
278
|
+
columns: [...t.columns, alias],
|
|
279
|
+
rows: t.rows.map((r) => [...r, 7]),
|
|
280
|
+
})),
|
|
281
|
+
new RegExp(`named for SQLite's rowid: ${alias}`),
|
|
282
|
+
]),
|
|
283
|
+
[
|
|
284
|
+
// A column added to one table, then a later table's row refused: the addition goes too.
|
|
285
|
+
'a row that fails after a column was added',
|
|
286
|
+
(tables) => {
|
|
287
|
+
const t = withTable(tables, 'tenants', (x) => ({
|
|
288
|
+
...x,
|
|
289
|
+
ddl: x.ddl.replace(/\)\s*$/, ', note TEXT)'),
|
|
290
|
+
columns: [...x.columns, 'note'],
|
|
291
|
+
rows: x.rows.map((r) => [...r, 'n']),
|
|
292
|
+
}));
|
|
293
|
+
// No `source`, which every shape of the table has required.
|
|
294
|
+
return withTable(t, 'verticals', (x) => {
|
|
295
|
+
const columns = x.columns.filter((c) => c !== 'source');
|
|
296
|
+
return { ...x, columns, rows: [rowOf(columns, { ...DEFAULTS, slug: 'v', name: 'V', created_at: 'c' })] };
|
|
297
|
+
});
|
|
298
|
+
},
|
|
299
|
+
/NOT NULL constraint failed: verticals\.source/,
|
|
300
|
+
],
|
|
301
|
+
[
|
|
302
|
+
// Two pre-directory scope rows whose ids differ only in case: the legacy backfill gives
|
|
303
|
+
// them one slug, which the live-slug index refuses. It runs inside the transaction.
|
|
304
|
+
'a legacy scope backfill that fails',
|
|
305
|
+
(tables) => withTable(tables, 'scopes', () => oldScopes(['Dup', 'dup'])),
|
|
306
|
+
/UNIQUE/,
|
|
307
|
+
],
|
|
308
|
+
];
|
|
309
|
+
for (const [what, craft, message] of refusals) {
|
|
310
|
+
it(what, async () => {
|
|
311
|
+
await using(async (dir, fresh) => {
|
|
312
|
+
// A directory holding something, so a restore that went through would show.
|
|
313
|
+
await dir.restore(withTable(fresh, 'tenants', (t) => ({ ...t, rows: [rowOf(t.columns, { ...LIVE_TENANT, slug: 'kept', name: 'Kept' })] })));
|
|
314
|
+
const before = await dir.snapshot();
|
|
315
|
+
const attempt = craft(withTable(before, 'tenants', (t) => ({ ...t, rows: t.rows.map((r) => r.map((v) => (v === 'Kept' ? 'Changed' : v))) })));
|
|
316
|
+
await expect(dir.restore(attempt)).rejects.toThrow(message);
|
|
317
|
+
expect(await dir.snapshot()).toEqual(before);
|
|
318
|
+
});
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
it('twin: the same dump without the refused parts restores', async () => {
|
|
322
|
+
await using(async (dir, fresh) => {
|
|
323
|
+
await dir.restore(withTable(fresh, 'scopes', () => oldScopes(['Dup', 'other'])));
|
|
324
|
+
expect(recordsOf(find(await dir.snapshot(), 'scopes')).map((r) => r.slug).sort()).toEqual(['dup', 'other']);
|
|
325
|
+
});
|
|
326
|
+
});
|
|
327
|
+
});
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
//# sourceMappingURL=directory-restore-suite.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"directory-restore-suite.js","sourceRoot":"","sources":["../src/directory-restore-suite.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAuB,MAAM,yB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C;wBAC9I,MAAM,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;wBAC5D,MAAM,CAAC,MAAM,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;oBAC/C,CAAC,CAAC,CAAC;gBACL,CAAC,CAAC,CAAC;YACL,CAAC;YAED,EAAE,CAAC,wDAAwD,EAAE,KAAK,IAAI,EAAE;gBACtE,MAAM,KAAK,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE;oBAC/B,MAAM,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;oBACjF,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,QAAQ,EAAE,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC;gBAC9G,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every shape a directory table has had (#1912), as `directoryRestoreSuite` feeds them to a
|
|
3
|
+
* restore. Read off the history of `DIRECTORY_DDL` (`adapter-cloudflare/src/control-plane-do.ts`)
|
|
4
|
+
* and of the pure adapter's `applyDirectorySchema`, which built the same column sets within days
|
|
5
|
+
* of each other, plus one of its own (#1173's scopes): one entry per distinct column set a
|
|
6
|
+
* `CREATE TABLE` ever produced, with the date, commit and PR that introduced it, the DDL as SQLite stored it (comments dropped) and the columns in
|
|
7
|
+
* the order a dump lists them. A directory created on that day and never migrated dumps exactly
|
|
8
|
+
* that; one migrated forward by `ensureDirectoryColumns` dumps the ALTERed-up shapes below.
|
|
9
|
+
*
|
|
10
|
+
* Every `NOT NULL` column without a default is present in each table's first shape, and every
|
|
11
|
+
* later column is nullable or defaulted, so each of these loads by column name into today's table.
|
|
12
|
+
* The spine's own shapes are #1911's, and not listed here.
|
|
13
|
+
*/
|
|
14
|
+
export interface DirectoryShape {
|
|
15
|
+
table: string;
|
|
16
|
+
since: string;
|
|
17
|
+
ddl: string;
|
|
18
|
+
columns: string[];
|
|
19
|
+
}
|
|
20
|
+
/** Each table as a `CREATE TABLE` built it, oldest first. */
|
|
21
|
+
export declare const CREATED_SHAPES: readonly DirectoryShape[];
|
|
22
|
+
/**
|
|
23
|
+
* Each table a directory created on its first day holds after `ensureDirectoryColumns` has
|
|
24
|
+
* ALTERed it forward: the first shape, with every later column appended in the order the Durable
|
|
25
|
+
* Object's pass adds them. SQLite appends each `ADD COLUMN` to the stored DDL, so the column order
|
|
26
|
+
* differs from a table created today, which a load by position would get wrong.
|
|
27
|
+
*/
|
|
28
|
+
export declare const ALTERED_SHAPES: readonly DirectoryShape[];
|
|
29
|
+
//# sourceMappingURL=directory-shapes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"directory-shapes.d.ts","sourceRoot":"","sources":["../src/directory-shapes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,6DAA6D;AAC7D,eAAO,MAAM,cAAc,EAAE,SAAS,cAAc,EAuLnD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,cAAc,EAAE,SAAS,cAAc,EA+BnD,CAAC"}
|