diff options
| author | soryu <soryu@soryu.co> | 2026-05-02 15:07:33 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-05-02 15:07:33 +0100 |
| commit | 760516b2e7b97fa389fb3902e8d2314eea052ff0 (patch) | |
| tree | 69eb1dd212ef924ee9e451d8d88806f899c03e84 /makima/migrations/20260502000000_create_directive_documents.sql | |
| parent | e11759447b1ac00becfb1e979e488f7f9c9cf478 (diff) | |
| download | soryu-760516b2e7b97fa389fb3902e8d2314eea052ff0.tar.gz soryu-760516b2e7b97fa389fb3902e8d2314eea052ff0.zip | |
feat: multi-document directives with ephemeral task lifecycle (#119)
* feat: soryu-co/soryu - makima: Fix folder/file naming and breadcrumb hash bugs
* WIP: heartbeat checkpoint
* WIP: heartbeat checkpoint
* WIP: heartbeat checkpoint
* feat: soryu-co/soryu - makima: Frontend: render multiple documents per directive folder
* WIP: heartbeat checkpoint
* WIP: heartbeat checkpoint
* WIP: heartbeat checkpoint
* Fix DirectiveRevision import in openapi.rs after merge
* Fix document-directives.tsx merge artifacts and add inactive status
Diffstat (limited to 'makima/migrations/20260502000000_create_directive_documents.sql')
| -rw-r--r-- | makima/migrations/20260502000000_create_directive_documents.sql | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/makima/migrations/20260502000000_create_directive_documents.sql b/makima/migrations/20260502000000_create_directive_documents.sql new file mode 100644 index 0000000..99871b5 --- /dev/null +++ b/makima/migrations/20260502000000_create_directive_documents.sql @@ -0,0 +1,50 @@ +-- Multi-document model under directives. +-- +-- A directive is a folder that owns N documents (the user calls these +-- "directive contracts"). Each document has its own markdown body, status, +-- and may end up attached to a PR. Multiple documents can be active at the +-- same time. When a doc ships (PR raised) it transitions to 'shipped'; +-- editing a shipped doc later flips it back to 'active' (handled in repo +-- update logic — wired into handlers in a later step). +-- +-- Today, directives.goal IS the single contract document, so we backfill +-- one document per existing directive populated from directives.goal so the +-- existing UI keeps working. + +CREATE TABLE directive_documents ( + id UUID PRIMARY KEY DEFAULT gen_random_uuid(), + directive_id UUID NOT NULL REFERENCES directives(id) ON DELETE CASCADE, + title VARCHAR(500) NOT NULL DEFAULT '', + body TEXT NOT NULL DEFAULT '', + status VARCHAR(32) NOT NULL DEFAULT 'draft' + CHECK (status IN ('draft', 'active', 'shipped', 'archived')), + pr_url TEXT, + pr_branch TEXT, + shipped_at TIMESTAMPTZ, + archived_at TIMESTAMPTZ, + version INTEGER NOT NULL DEFAULT 1, + created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), + updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW() +); + +CREATE INDEX idx_directive_documents_directive_id + ON directive_documents(directive_id); +CREATE INDEX idx_directive_documents_status + ON directive_documents(directive_id, status); + +-- Backfill: one document per existing directive, copying the current goal +-- so the existing UI keeps showing what it shows today. Directives that +-- already have a PR url are seeded as 'shipped' (with shipped_at set), +-- everything else as 'active'. COALESCE protects against any unexpected +-- NULL goal rows even though the column is currently NOT NULL. +INSERT INTO directive_documents ( + directive_id, title, body, status, pr_url, shipped_at +) +SELECT + d.id, + d.title, + COALESCE(d.goal, ''), + CASE WHEN d.pr_url IS NOT NULL THEN 'shipped' ELSE 'active' END, + d.pr_url, + CASE WHEN d.pr_url IS NOT NULL THEN NOW() ELSE NULL END +FROM directives d; |
