Add major.minor document versioning

Introduce a two-part version scheme (major.minor) for documents.
Drafts start at 0.1 and increment minor on each new draft. Publishing
as minor keeps the current version, publishing as major bumps to the
next major.0. Both current_published_major and current_published_minor
are tracked on the document for exact version lookups.

Signatures and approval quorums aggregate across all versions sharing
the same major number using CTE joins. Approval page mutations spread
the decision fragment so Relay updates the version row state without
requiring a page refresh.

GraphQL, MCP, and service layer expose separate publishMajor and
publishMinor mutations instead of a single mutation with a type enum.

Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
Sacha Al Himdani
2026-03-27 19:57:58 +01:00
parent c5a412ea41
commit 68bc8cf59a
31 changed files with 877 additions and 417 deletions

View File

@@ -0,0 +1,11 @@
ALTER TABLE document_versions DROP CONSTRAINT document_versions_document_id_version_number_key;
ALTER TABLE document_versions RENAME COLUMN version_number TO major;
ALTER TABLE document_versions ADD COLUMN minor INTEGER NOT NULL DEFAULT 0;
ALTER TABLE document_versions ALTER COLUMN minor DROP DEFAULT;
ALTER TABLE document_versions ADD CONSTRAINT document_versions_document_id_major_minor_key UNIQUE (document_id, major, minor);
ALTER TABLE documents RENAME COLUMN current_published_version TO current_published_major;
ALTER TABLE documents ADD COLUMN current_published_minor INTEGER;
UPDATE documents SET current_published_minor = 0 WHERE current_published_major IS NOT NULL;