@plakboek/db 0.6.0 → 0.7.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/README.md +7 -1
- package/dist/index.js +46 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -83,7 +83,13 @@ content engine tables (`content_types`, `content_type_fields`,
|
|
|
83
83
|
settings tables) used by `@plakboek/content`. `0003_page_block_engine`
|
|
84
84
|
creates the page and block-tree tables (`pages`, `page_blocks`,
|
|
85
85
|
`block_revisions`, `page_publications`, `page_url_history`,
|
|
86
|
-
`page_engine_settings`) used by `@plakboek/pages`.
|
|
86
|
+
`page_engine_settings`) used by `@plakboek/pages`. `0004_block_layout` adds
|
|
87
|
+
a nullable `layout` column to `page_blocks` and `block_revisions`, holding
|
|
88
|
+
section column ratios and alignment and block fill separately from `props`.
|
|
89
|
+
`0005_revision_block_ref` adds `block_revisions.subject_block_id`, which keeps
|
|
90
|
+
the revised block's id once the block row is deleted, so a deleted subtree can
|
|
91
|
+
be restored with its parent links intact.
|
|
92
|
+
See
|
|
87
93
|
[`MIGRATIONS.md`](./MIGRATIONS.md) for how later migrations are added, the
|
|
88
94
|
transactional-vs-existence-guarded-statement decision, and what each thrown
|
|
89
95
|
error class means.
|
package/dist/index.js
CHANGED
|
@@ -152,6 +152,10 @@ async function withMigrationLock(client, fn, options) {
|
|
|
152
152
|
* and the audit log. `0002_content_engine` is the second: the content-type,
|
|
153
153
|
* field and entry tables `@plakboek/content` builds on. `0003_page_block_engine`
|
|
154
154
|
* is the third: the page and block-tree tables `@plakboek/pages` builds on.
|
|
155
|
+
* `0004_block_layout` is the fourth: the nullable `layout` column on
|
|
156
|
+
* `page_blocks` and `block_revisions`. `0005_revision_block_ref` is the fifth:
|
|
157
|
+
* `block_revisions.subject_block_id`, the revised block's id kept as plain data
|
|
158
|
+
* after the block row (and so `block_id`) is gone.
|
|
155
159
|
* The runner's failure modes (ordering, checksums, partial application,
|
|
156
160
|
* locking) are exercised through fixture registries in this package's own
|
|
157
161
|
* tests (tests/fixtures/migrations.ts).
|
|
@@ -698,6 +702,48 @@ CREATE INDEX IF NOT EXISTS "page_publications_page_draft_published_idx"
|
|
|
698
702
|
ON "page_publications" USING btree ("page_id", "is_draft", "published_at" DESC);
|
|
699
703
|
CREATE INDEX IF NOT EXISTS "page_url_history_locale_path_idx"
|
|
700
704
|
ON "page_url_history" USING btree ("locale", "old_path");
|
|
705
|
+
`
|
|
706
|
+
},
|
|
707
|
+
{
|
|
708
|
+
name: "0004_block_layout",
|
|
709
|
+
transactional: true,
|
|
710
|
+
sql: `
|
|
711
|
+
ALTER TABLE "page_blocks" ADD COLUMN IF NOT EXISTS "layout" jsonb;
|
|
712
|
+
|
|
713
|
+
ALTER TABLE "block_revisions" ADD COLUMN IF NOT EXISTS "layout" jsonb;
|
|
714
|
+
|
|
715
|
+
DO $$
|
|
716
|
+
BEGIN
|
|
717
|
+
IF NOT EXISTS (
|
|
718
|
+
SELECT 1 FROM pg_constraint WHERE conname = 'page_blocks_layout_object_check'
|
|
719
|
+
) THEN
|
|
720
|
+
ALTER TABLE "page_blocks"
|
|
721
|
+
ADD CONSTRAINT "page_blocks_layout_object_check"
|
|
722
|
+
CHECK ("layout" IS NULL OR jsonb_typeof("layout") = 'object');
|
|
723
|
+
END IF;
|
|
724
|
+
END $$;
|
|
725
|
+
|
|
726
|
+
DO $$
|
|
727
|
+
BEGIN
|
|
728
|
+
IF NOT EXISTS (
|
|
729
|
+
SELECT 1 FROM pg_constraint WHERE conname = 'block_revisions_layout_object_check'
|
|
730
|
+
) THEN
|
|
731
|
+
ALTER TABLE "block_revisions"
|
|
732
|
+
ADD CONSTRAINT "block_revisions_layout_object_check"
|
|
733
|
+
CHECK ("layout" IS NULL OR jsonb_typeof("layout") = 'object');
|
|
734
|
+
END IF;
|
|
735
|
+
END $$;
|
|
736
|
+
`
|
|
737
|
+
},
|
|
738
|
+
{
|
|
739
|
+
name: "0005_revision_block_ref",
|
|
740
|
+
transactional: true,
|
|
741
|
+
sql: `
|
|
742
|
+
ALTER TABLE "block_revisions" ADD COLUMN IF NOT EXISTS "subject_block_id" uuid;
|
|
743
|
+
|
|
744
|
+
UPDATE "block_revisions"
|
|
745
|
+
SET "subject_block_id" = "block_id"
|
|
746
|
+
WHERE "subject_block_id" IS NULL AND "block_id" IS NOT NULL;
|
|
701
747
|
`
|
|
702
748
|
}
|
|
703
749
|
]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plakboek/db",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Postgres connection factory and migration-lock primitives for Plakboek CMS installations",
|
|
5
5
|
"homepage": "https://github.com/flovan/plakboek/tree/main/packages/db#readme",
|
|
6
6
|
"bugs": {
|