refactor(db): split revision preview from meta_json
Preview BIRD-фрагменты в config_revision_preview; meta_json только счётчик префиксов. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
UPDATE config_revision cr
|
||||
SET meta_json = cr.meta_json || jsonb_build_object('preview_fragments', COALESCE(p.fragments, '{}'::jsonb))
|
||||
FROM config_revision_preview p
|
||||
WHERE p.revision_id = cr.id;
|
||||
|
||||
DROP TABLE IF EXISTS config_revision_preview;
|
||||
@@ -0,0 +1,15 @@
|
||||
-- Split BIRD preview fragments out of config_revision.meta_json (H1).
|
||||
|
||||
CREATE TABLE config_revision_preview (
|
||||
revision_id UUID PRIMARY KEY REFERENCES config_revision (id) ON DELETE CASCADE,
|
||||
fragments JSONB NOT NULL DEFAULT '{}'
|
||||
);
|
||||
|
||||
INSERT INTO config_revision_preview (revision_id, fragments)
|
||||
SELECT id, COALESCE(meta_json->'preview_fragments', '{}'::jsonb)
|
||||
FROM config_revision
|
||||
WHERE meta_json ? 'preview_fragments';
|
||||
|
||||
UPDATE config_revision
|
||||
SET meta_json = meta_json - 'preview_fragments'
|
||||
WHERE meta_json ? 'preview_fragments';
|
||||
Reference in New Issue
Block a user