@byline/cli 4.14.1 → 4.15.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/lib/baseline-drift.test.js +22 -25
- package/dist/lib/baseline-drift.test.js.map +1 -1
- package/dist/lib/baseline.d.ts +5 -3
- package/dist/lib/baseline.d.ts.map +1 -1
- package/dist/lib/baseline.js +5 -3
- package/dist/lib/baseline.js.map +1 -1
- package/dist/templates/migrations/mysql/{0000_fast_rick_jones.sql → 0000_spooky_starjammers.sql} +48 -0
- package/dist/templates/migrations/mysql/meta/_journal.json +2 -2
- package/dist/templates/migrations/postgres/{0000_small_rhodey.sql → 0000_colossal_morbius.sql} +46 -0
- package/dist/templates/migrations/postgres/meta/_journal.json +2 -2
- package/package.json +1 -1
|
@@ -17,7 +17,7 @@ afterEach(() => {
|
|
|
17
17
|
rmSync(fixture, { recursive: true, force: true });
|
|
18
18
|
});
|
|
19
19
|
describe.each(['postgres', 'mysql'])('bundled %s baseline', (dialect) => {
|
|
20
|
-
it('matches the adapter source as one complete runtime migration', () => {
|
|
20
|
+
it('matches the adapter source as one complete runtime migration bundle', () => {
|
|
21
21
|
expect(() => assertBaselineContract(adapterSources[dialect], baselineDir(templates, dialect))).not.toThrow();
|
|
22
22
|
});
|
|
23
23
|
});
|
|
@@ -36,44 +36,41 @@ it('rejects a partial bundle when the source contains a second migration', () =>
|
|
|
36
36
|
})}\n`;
|
|
37
37
|
writeFileSync(resolve(source, 'meta/_journal.json'), journal);
|
|
38
38
|
writeFileSync(resolve(bundled, 'meta/_journal.json'), journal);
|
|
39
|
-
expect(() => assertBaselineContract(source, bundled)).toThrow('source
|
|
39
|
+
expect(() => assertBaselineContract(source, bundled)).toThrow('source and bundle SQL inventories differ');
|
|
40
40
|
});
|
|
41
41
|
function assertBaselineContract(source, bundled) {
|
|
42
42
|
const sourceSql = sqlFiles(source);
|
|
43
43
|
const bundledSql = sqlFiles(bundled);
|
|
44
|
-
if (sourceSql.length
|
|
45
|
-
throw new Error(
|
|
46
|
-
}
|
|
47
|
-
if (bundledSql.length !== 1) {
|
|
48
|
-
throw new Error(`bundle must contain exactly one SQL migration; found ${bundledSql.length}`);
|
|
49
|
-
}
|
|
44
|
+
if (sourceSql.length === 0)
|
|
45
|
+
throw new Error('source must contain at least one SQL migration');
|
|
50
46
|
if (JSON.stringify(sourceSql) !== JSON.stringify(bundledSql)) {
|
|
51
47
|
throw new Error(`source and bundle SQL inventories differ: ${sourceSql.join(', ')} != ${bundledSql.join(', ')}`);
|
|
52
48
|
}
|
|
53
|
-
const
|
|
54
|
-
if (!sqlName)
|
|
55
|
-
throw new Error('source SQL inventory unexpectedly became empty');
|
|
56
|
-
const expectedInventory = [sqlName, 'meta/_journal.json'].sort();
|
|
49
|
+
const expectedInventory = [...sourceSql, 'meta/_journal.json'].sort();
|
|
57
50
|
const bundledInventory = fileInventory(bundled);
|
|
58
51
|
if (JSON.stringify(bundledInventory) !== JSON.stringify(expectedInventory)) {
|
|
59
52
|
throw new Error(`bundle inventory differs: ${bundledInventory.join(', ')} != ${expectedInventory.join(', ')}`);
|
|
60
53
|
}
|
|
61
|
-
const sourceJournal = readFileSync(resolve(source, 'meta/_journal.json'), 'utf8');
|
|
62
|
-
const bundledJournal = readFileSync(resolve(bundled, 'meta/_journal.json'), 'utf8');
|
|
63
|
-
if (sourceJournal !== bundledJournal)
|
|
54
|
+
const sourceJournal = JSON.parse(readFileSync(resolve(source, 'meta/_journal.json'), 'utf8'));
|
|
55
|
+
const bundledJournal = JSON.parse(readFileSync(resolve(bundled, 'meta/_journal.json'), 'utf8'));
|
|
56
|
+
if (JSON.stringify(sourceJournal) !== JSON.stringify(bundledJournal)) {
|
|
64
57
|
throw new Error('source and bundle journals differ');
|
|
65
|
-
const journal = JSON.parse(sourceJournal);
|
|
66
|
-
if (!Array.isArray(journal.entries) || journal.entries.length !== 1) {
|
|
67
|
-
throw new Error('journal must contain exactly one entry');
|
|
68
58
|
}
|
|
69
|
-
const
|
|
70
|
-
if (journal.entries
|
|
71
|
-
throw new Error(
|
|
59
|
+
const journal = sourceJournal;
|
|
60
|
+
if (!Array.isArray(journal.entries) || journal.entries.length !== sourceSql.length) {
|
|
61
|
+
throw new Error('journal must contain exactly one entry per SQL migration');
|
|
62
|
+
}
|
|
63
|
+
for (const [index, sqlName] of sourceSql.entries()) {
|
|
64
|
+
const expectedTag = sqlName.slice(0, -'.sql'.length);
|
|
65
|
+
if (journal.entries[index]?.tag !== expectedTag) {
|
|
66
|
+
throw new Error(`journal tag does not match SQL migration: ${journal.entries[index]?.tag}`);
|
|
67
|
+
}
|
|
68
|
+
const sourceSqlText = readFileSync(resolve(source, sqlName), 'utf8');
|
|
69
|
+
const bundledSqlText = readFileSync(resolve(bundled, sqlName), 'utf8');
|
|
70
|
+
if (sourceSqlText !== bundledSqlText) {
|
|
71
|
+
throw new Error(`source and bundle SQL differ: ${sqlName}`);
|
|
72
|
+
}
|
|
72
73
|
}
|
|
73
|
-
const sourceSqlText = readFileSync(resolve(source, sqlName), 'utf8');
|
|
74
|
-
const bundledSqlText = readFileSync(resolve(bundled, sqlName), 'utf8');
|
|
75
|
-
if (sourceSqlText !== bundledSqlText)
|
|
76
|
-
throw new Error('source and bundle SQL differ');
|
|
77
74
|
}
|
|
78
75
|
function sqlFiles(root) {
|
|
79
76
|
return readdirSync(root)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"baseline-drift.test.js","sourceRoot":"","sources":["../../src/lib/baseline-drift.test.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,WAAW,EACX,WAAW,EACX,YAAY,EACZ,MAAM,EACN,QAAQ,EACR,aAAa,GACd,MAAM,SAAS,CAAA;AAChB,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAChC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,C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AS,aAAa,CAAC,IAAY;IACjC,MAAM,KAAK,GAAa,EAAE,CAAA;IAC1B,SAAS,IAAI,CAAC,SAAiB;QAC7B,KAAK,MAAM,IAAI,IAAI,WAAW,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;YACjD,MAAM,IAAI,GAAG,OAAO,CAAC,SAAS,EAAE,IAAI,CAAC,CAAA;YACrC,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE;gBAAE,IAAI,CAAC,IAAI,CAAC,CAAA;;gBACvC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAA;QAC7D,CAAC;IACH,CAAC;IACD,IAAI,CAAC,IAAI,CAAC,CAAA;IACV,OAAO,KAAK,CAAC,IAAI,EAAE,CAAA;AACrB,CAAC"}
|
package/dist/lib/baseline.d.ts
CHANGED
|
@@ -2,9 +2,11 @@ import type { DatabaseAdapterId } from '../types.js';
|
|
|
2
2
|
/**
|
|
3
3
|
* Resolve the current release's fresh-install baseline for a database dialect.
|
|
4
4
|
*
|
|
5
|
-
* The directory contains
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* The directory contains the current release's complete Drizzle migration
|
|
6
|
+
* bundle and its journal. A release normally squashes that bundle to one SQL
|
|
7
|
+
* file, but development branches may contain later migrations. It is never an
|
|
8
|
+
* upgrade stream; existing installations use the adapters' native SQL
|
|
9
|
+
* directories.
|
|
8
10
|
*/
|
|
9
11
|
export declare function baselineDir(templatesDir: string, dialect: DatabaseAdapterId): string;
|
|
10
12
|
//# sourceMappingURL=baseline.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"baseline.d.ts","sourceRoot":"","sources":["../../src/lib/baseline.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAEpD
|
|
1
|
+
{"version":3,"file":"baseline.d.ts","sourceRoot":"","sources":["../../src/lib/baseline.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAEpD;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,GAAG,MAAM,CAEpF"}
|
package/dist/lib/baseline.js
CHANGED
|
@@ -2,9 +2,11 @@ import { resolve } from 'node:path';
|
|
|
2
2
|
/**
|
|
3
3
|
* Resolve the current release's fresh-install baseline for a database dialect.
|
|
4
4
|
*
|
|
5
|
-
* The directory contains
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* The directory contains the current release's complete Drizzle migration
|
|
6
|
+
* bundle and its journal. A release normally squashes that bundle to one SQL
|
|
7
|
+
* file, but development branches may contain later migrations. It is never an
|
|
8
|
+
* upgrade stream; existing installations use the adapters' native SQL
|
|
9
|
+
* directories.
|
|
8
10
|
*/
|
|
9
11
|
export function baselineDir(templatesDir, dialect) {
|
|
10
12
|
return resolve(templatesDir, 'migrations', dialect);
|
package/dist/lib/baseline.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"baseline.js","sourceRoot":"","sources":["../../src/lib/baseline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAInC
|
|
1
|
+
{"version":3,"file":"baseline.js","sourceRoot":"","sources":["../../src/lib/baseline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAInC;;;;;;;;GAQG;AACH,MAAM,UAAU,WAAW,CAAC,YAAoB,EAAE,OAA0B;IAC1E,OAAO,OAAO,CAAC,YAAY,EAAE,YAAY,EAAE,OAAO,CAAC,CAAA;AACrD,CAAC"}
|
package/dist/templates/migrations/mysql/{0000_fast_rick_jones.sql → 0000_spooky_starjammers.sql}
RENAMED
|
@@ -169,6 +169,30 @@ CREATE TABLE `byline_document_paths` (
|
|
|
169
169
|
CONSTRAINT `idx_document_paths_collection_locale_path` UNIQUE(`collection_id`,`locale`,`path`,`alive`)
|
|
170
170
|
);
|
|
171
171
|
--> statement-breakpoint
|
|
172
|
+
CREATE TABLE `byline_document_publish_schedules` (
|
|
173
|
+
`document_id` char(36) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
|
|
174
|
+
`collection_id` char(36) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
|
|
175
|
+
`target_version_id` char(36) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
|
|
176
|
+
`publish_at` datetime(6) NOT NULL,
|
|
177
|
+
`state` varchar(32) NOT NULL DEFAULT 'armed',
|
|
178
|
+
`suspended_at` datetime(6),
|
|
179
|
+
`suspended_reason` varchar(32),
|
|
180
|
+
`scheduled_by` char(36) CHARACTER SET ascii COLLATE ascii_bin,
|
|
181
|
+
`last_authorized_by` char(36) CHARACTER SET ascii COLLATE ascii_bin,
|
|
182
|
+
`last_authorized_at` datetime(6) NOT NULL,
|
|
183
|
+
`scheduled_at` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
|
|
184
|
+
`updated_at` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
|
|
185
|
+
`execution_token` char(36) CHARACTER SET ascii COLLATE ascii_bin,
|
|
186
|
+
`execution_expires_at` datetime(6),
|
|
187
|
+
`last_attempt_at` datetime(6),
|
|
188
|
+
`next_attempt_at` datetime(6) NOT NULL,
|
|
189
|
+
`attempt_count` int NOT NULL DEFAULT 0,
|
|
190
|
+
`last_error` text,
|
|
191
|
+
CONSTRAINT `byline_document_publish_schedules_document_id` PRIMARY KEY(`document_id`),
|
|
192
|
+
CONSTRAINT `check_publish_schedules_state` CHECK(`byline_document_publish_schedules`.`state` IN ('armed', 'needs_reconfirm')),
|
|
193
|
+
CONSTRAINT `check_publish_schedules_suspended_reason` CHECK(`byline_document_publish_schedules`.`suspended_reason` IS NULL OR `byline_document_publish_schedules`.`suspended_reason` = 'content_edited')
|
|
194
|
+
);
|
|
195
|
+
--> statement-breakpoint
|
|
172
196
|
CREATE TABLE `byline_document_relationships` (
|
|
173
197
|
`child_document_id` char(36) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
|
|
174
198
|
`parent_document_id` char(36) CHARACTER SET ascii COLLATE ascii_bin,
|
|
@@ -288,6 +312,25 @@ CREATE TABLE `byline_store_numeric` (
|
|
|
288
312
|
CONSTRAINT `unique_numeric_field` UNIQUE(`document_version_id`,`field_path`,`locale`)
|
|
289
313
|
);
|
|
290
314
|
--> statement-breakpoint
|
|
315
|
+
CREATE TABLE `byline_recurring_tasks` (
|
|
316
|
+
`name` varchar(255) NOT NULL,
|
|
317
|
+
`interval_ms` bigint NOT NULL,
|
|
318
|
+
`next_run_at` datetime(6) NOT NULL,
|
|
319
|
+
`lease_token` char(36) CHARACTER SET ascii COLLATE ascii_bin,
|
|
320
|
+
`lease_owner` varchar(255),
|
|
321
|
+
`lease_expires_at` datetime(6),
|
|
322
|
+
`last_started_at` datetime(6),
|
|
323
|
+
`last_succeeded_at` datetime(6),
|
|
324
|
+
`last_failed_at` datetime(6),
|
|
325
|
+
`last_duration_ms` bigint,
|
|
326
|
+
`consecutive_failures` int NOT NULL DEFAULT 0,
|
|
327
|
+
`last_status` varchar(32) NOT NULL DEFAULT 'never_run',
|
|
328
|
+
`last_error` text,
|
|
329
|
+
`created_at` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
|
|
330
|
+
`updated_at` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
|
|
331
|
+
CONSTRAINT `byline_recurring_tasks_name` PRIMARY KEY(`name`)
|
|
332
|
+
);
|
|
333
|
+
--> statement-breakpoint
|
|
291
334
|
CREATE TABLE `byline_store_relation` (
|
|
292
335
|
`id` char(36) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
|
|
293
336
|
`document_version_id` char(36) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
|
|
@@ -335,6 +378,9 @@ ALTER TABLE `byline_document_available_locales` ADD CONSTRAINT `fk_document_avai
|
|
|
335
378
|
ALTER TABLE `byline_document_available_locales` ADD CONSTRAINT `fk_document_available_locales_collection_id` FOREIGN KEY (`collection_id`) REFERENCES `byline_collections`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
336
379
|
ALTER TABLE `byline_document_paths` ADD CONSTRAINT `fk_document_paths_document_id` FOREIGN KEY (`document_id`) REFERENCES `byline_documents`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
337
380
|
ALTER TABLE `byline_document_paths` ADD CONSTRAINT `fk_document_paths_collection_id` FOREIGN KEY (`collection_id`) REFERENCES `byline_collections`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
381
|
+
ALTER TABLE `byline_document_publish_schedules` ADD CONSTRAINT `fk_publish_schedules_document` FOREIGN KEY (`document_id`) REFERENCES `byline_documents`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
382
|
+
ALTER TABLE `byline_document_publish_schedules` ADD CONSTRAINT `fk_publish_schedules_collection` FOREIGN KEY (`collection_id`) REFERENCES `byline_collections`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
383
|
+
ALTER TABLE `byline_document_publish_schedules` ADD CONSTRAINT `fk_publish_schedules_target_version` FOREIGN KEY (`target_version_id`) REFERENCES `byline_document_versions`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
338
384
|
ALTER TABLE `byline_document_relationships` ADD CONSTRAINT `fk_document_relationships_child_document_id` FOREIGN KEY (`child_document_id`) REFERENCES `byline_documents`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
339
385
|
ALTER TABLE `byline_document_relationships` ADD CONSTRAINT `fk_document_relationships_parent_document_id` FOREIGN KEY (`parent_document_id`) REFERENCES `byline_documents`(`id`) ON DELETE set null ON UPDATE no action;--> statement-breakpoint
|
|
340
386
|
ALTER TABLE `byline_document_version_locales` ADD CONSTRAINT `fk_document_version_locales_document_version_id` FOREIGN KEY (`document_version_id`) REFERENCES `byline_document_versions`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
@@ -373,6 +419,8 @@ CREATE INDEX `idx_datetime_path_date` ON `byline_store_datetime` (`field_path`,`
|
|
|
373
419
|
CREATE INDEX `idx_datetime_collection_date` ON `byline_store_datetime` (`collection_id`,`value_timestamp_tz`);--> statement-breakpoint
|
|
374
420
|
CREATE INDEX `idx_document_available_locales_document_id` ON `byline_document_available_locales` (`document_id`);--> statement-breakpoint
|
|
375
421
|
CREATE INDEX `idx_document_paths_document_id` ON `byline_document_paths` (`document_id`);--> statement-breakpoint
|
|
422
|
+
CREATE INDEX `idx_document_publish_schedules_due` ON `byline_document_publish_schedules` (`state`,`next_attempt_at`,`publish_at`);--> statement-breakpoint
|
|
423
|
+
CREATE INDEX `idx_document_publish_schedules_execution_expiry` ON `byline_document_publish_schedules` (`execution_expires_at`);--> statement-breakpoint
|
|
376
424
|
CREATE INDEX `idx_document_relationships_parent_order` ON `byline_document_relationships` (`parent_document_id`,`order_key`);--> statement-breakpoint
|
|
377
425
|
CREATE INDEX `idx_documents_document_id` ON `byline_document_versions` (`document_id`);--> statement-breakpoint
|
|
378
426
|
CREATE INDEX `idx_documents_collection_document_deleted` ON `byline_document_versions` (`collection_id`,`document_id`,`is_deleted`);--> statement-breakpoint
|
package/dist/templates/migrations/postgres/{0000_small_rhodey.sql → 0000_colossal_morbius.sql}
RENAMED
|
@@ -159,6 +159,29 @@ CREATE TABLE "byline_document_paths" (
|
|
|
159
159
|
CONSTRAINT "idx_document_paths_collection_locale_path" UNIQUE("collection_id","locale","path","alive")
|
|
160
160
|
);
|
|
161
161
|
--> statement-breakpoint
|
|
162
|
+
CREATE TABLE "byline_document_publish_schedules" (
|
|
163
|
+
"document_id" uuid PRIMARY KEY NOT NULL,
|
|
164
|
+
"collection_id" uuid NOT NULL,
|
|
165
|
+
"target_version_id" uuid NOT NULL,
|
|
166
|
+
"publish_at" timestamp (6) with time zone NOT NULL,
|
|
167
|
+
"state" varchar(32) DEFAULT 'armed' NOT NULL,
|
|
168
|
+
"suspended_at" timestamp (6) with time zone,
|
|
169
|
+
"suspended_reason" varchar(32),
|
|
170
|
+
"scheduled_by" uuid,
|
|
171
|
+
"last_authorized_by" uuid,
|
|
172
|
+
"last_authorized_at" timestamp (6) with time zone NOT NULL,
|
|
173
|
+
"scheduled_at" timestamp (6) with time zone DEFAULT now() NOT NULL,
|
|
174
|
+
"updated_at" timestamp (6) with time zone DEFAULT now() NOT NULL,
|
|
175
|
+
"execution_token" uuid,
|
|
176
|
+
"execution_expires_at" timestamp (6) with time zone,
|
|
177
|
+
"last_attempt_at" timestamp (6) with time zone,
|
|
178
|
+
"next_attempt_at" timestamp (6) with time zone NOT NULL,
|
|
179
|
+
"attempt_count" integer DEFAULT 0 NOT NULL,
|
|
180
|
+
"last_error" text,
|
|
181
|
+
CONSTRAINT "check_document_publish_schedules_state" CHECK ("byline_document_publish_schedules"."state" IN ('armed', 'needs_reconfirm')),
|
|
182
|
+
CONSTRAINT "check_document_publish_schedules_suspended_reason" CHECK ("byline_document_publish_schedules"."suspended_reason" IS NULL OR "byline_document_publish_schedules"."suspended_reason" = 'content_edited')
|
|
183
|
+
);
|
|
184
|
+
--> statement-breakpoint
|
|
162
185
|
CREATE TABLE "byline_document_relationships" (
|
|
163
186
|
"child_document_id" uuid NOT NULL,
|
|
164
187
|
"parent_document_id" uuid,
|
|
@@ -272,6 +295,24 @@ CREATE TABLE "byline_store_numeric" (
|
|
|
272
295
|
CONSTRAINT "unique_numeric_field" UNIQUE("document_version_id","field_path","locale")
|
|
273
296
|
);
|
|
274
297
|
--> statement-breakpoint
|
|
298
|
+
CREATE TABLE "byline_recurring_tasks" (
|
|
299
|
+
"name" varchar(255) PRIMARY KEY NOT NULL,
|
|
300
|
+
"interval_ms" bigint NOT NULL,
|
|
301
|
+
"next_run_at" timestamp with time zone NOT NULL,
|
|
302
|
+
"lease_token" uuid,
|
|
303
|
+
"lease_owner" varchar(255),
|
|
304
|
+
"lease_expires_at" timestamp with time zone,
|
|
305
|
+
"last_started_at" timestamp with time zone,
|
|
306
|
+
"last_succeeded_at" timestamp with time zone,
|
|
307
|
+
"last_failed_at" timestamp with time zone,
|
|
308
|
+
"last_duration_ms" bigint,
|
|
309
|
+
"consecutive_failures" integer DEFAULT 0 NOT NULL,
|
|
310
|
+
"last_status" varchar(32) DEFAULT 'never_run' NOT NULL,
|
|
311
|
+
"last_error" text,
|
|
312
|
+
"created_at" timestamp (6) with time zone DEFAULT now() NOT NULL,
|
|
313
|
+
"updated_at" timestamp (6) with time zone DEFAULT now() NOT NULL
|
|
314
|
+
);
|
|
315
|
+
--> statement-breakpoint
|
|
275
316
|
CREATE TABLE "byline_store_relation" (
|
|
276
317
|
"id" uuid PRIMARY KEY NOT NULL,
|
|
277
318
|
"document_version_id" uuid NOT NULL,
|
|
@@ -317,6 +358,9 @@ ALTER TABLE "byline_document_available_locales" ADD CONSTRAINT "byline_document_
|
|
|
317
358
|
ALTER TABLE "byline_document_available_locales" ADD CONSTRAINT "byline_document_available_locales_collection_id_byline_collections_id_fk" FOREIGN KEY ("collection_id") REFERENCES "public"."byline_collections"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
318
359
|
ALTER TABLE "byline_document_paths" ADD CONSTRAINT "byline_document_paths_document_id_byline_documents_id_fk" FOREIGN KEY ("document_id") REFERENCES "public"."byline_documents"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
319
360
|
ALTER TABLE "byline_document_paths" ADD CONSTRAINT "byline_document_paths_collection_id_byline_collections_id_fk" FOREIGN KEY ("collection_id") REFERENCES "public"."byline_collections"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
361
|
+
ALTER TABLE "byline_document_publish_schedules" ADD CONSTRAINT "byline_document_publish_schedules_document_id_byline_documents_id_fk" FOREIGN KEY ("document_id") REFERENCES "public"."byline_documents"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
362
|
+
ALTER TABLE "byline_document_publish_schedules" ADD CONSTRAINT "byline_document_publish_schedules_collection_id_byline_collections_id_fk" FOREIGN KEY ("collection_id") REFERENCES "public"."byline_collections"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
363
|
+
ALTER TABLE "byline_document_publish_schedules" ADD CONSTRAINT "byline_document_publish_schedules_target_version_id_byline_document_versions_id_fk" FOREIGN KEY ("target_version_id") REFERENCES "public"."byline_document_versions"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
320
364
|
ALTER TABLE "byline_document_relationships" ADD CONSTRAINT "byline_document_relationships_child_document_id_byline_documents_id_fk" FOREIGN KEY ("child_document_id") REFERENCES "public"."byline_documents"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
321
365
|
ALTER TABLE "byline_document_relationships" ADD CONSTRAINT "byline_document_relationships_parent_document_id_byline_documents_id_fk" FOREIGN KEY ("parent_document_id") REFERENCES "public"."byline_documents"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
|
|
322
366
|
ALTER TABLE "byline_document_version_locales" ADD CONSTRAINT "byline_document_version_locales_document_version_id_byline_document_versions_id_fk" FOREIGN KEY ("document_version_id") REFERENCES "public"."byline_document_versions"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
@@ -355,6 +399,8 @@ CREATE INDEX "idx_datetime_path_date" ON "byline_store_datetime" USING btree ("f
|
|
|
355
399
|
CREATE INDEX "idx_datetime_collection_date" ON "byline_store_datetime" USING btree ("collection_id","value_timestamp_tz");--> statement-breakpoint
|
|
356
400
|
CREATE INDEX "idx_document_available_locales_document_id" ON "byline_document_available_locales" USING btree ("document_id");--> statement-breakpoint
|
|
357
401
|
CREATE INDEX "idx_document_paths_document_id" ON "byline_document_paths" USING btree ("document_id");--> statement-breakpoint
|
|
402
|
+
CREATE INDEX "idx_document_publish_schedules_due" ON "byline_document_publish_schedules" USING btree ("next_attempt_at","publish_at") WHERE "byline_document_publish_schedules"."state" = 'armed';--> statement-breakpoint
|
|
403
|
+
CREATE INDEX "idx_document_publish_schedules_execution_expiry" ON "byline_document_publish_schedules" USING btree ("execution_expires_at");--> statement-breakpoint
|
|
358
404
|
CREATE INDEX "idx_document_relationships_parent_order" ON "byline_document_relationships" USING btree ("parent_document_id","order_key");--> statement-breakpoint
|
|
359
405
|
CREATE INDEX "idx_documents_document_id" ON "byline_document_versions" USING btree ("document_id");--> statement-breakpoint
|
|
360
406
|
CREATE INDEX "idx_documents_collection_document_deleted" ON "byline_document_versions" USING btree ("collection_id","document_id","is_deleted");--> statement-breakpoint
|