Move document type from document to document version
Follow the same pattern used for classification: document type now lives exclusively on DocumentVersion. A migration copies existing values from documents to their versions. The document filter uses a subquery on the latest version. All three API surfaces (GraphQL, MCP, CLI), resolvers, frontend, and e2e tests are updated accordingly. Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
12
pkg/coredata/migrations/20260331T120000Z.sql
Normal file
12
pkg/coredata/migrations/20260331T120000Z.sql
Normal file
@@ -0,0 +1,12 @@
|
||||
-- Add document_type column to document_versions, copying from parent document.
|
||||
ALTER TABLE document_versions ADD COLUMN document_type document_type NOT NULL DEFAULT 'OTHER';
|
||||
|
||||
UPDATE document_versions dv
|
||||
SET document_type = d.document_type
|
||||
FROM documents d
|
||||
WHERE dv.document_id = d.id;
|
||||
|
||||
ALTER TABLE document_versions ALTER COLUMN document_type DROP DEFAULT;
|
||||
|
||||
-- TODO: drop the document_type column from documents.
|
||||
ALTER TABLE documents ALTER COLUMN document_type SET DEFAULT 'OTHER';
|
||||
Reference in New Issue
Block a user