Q30: documents keep every version
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
794fa372c9
commit
4c475e5ceb
9 files changed
+183
-23
No files matched your search
@@ -0,0 +1,26 @@
|
||||
export const documentVersionsSchema = `
|
||||
alter table documents add column version integer not null default 1;
|
||||
|
||||
create table if not exists document_versions (
|
||||
id text primary key,
|
||||
org_id text not null references organizations(id) on delete cascade,
|
||||
document_id text not null,
|
||||
version integer not null,
|
||||
title text not null,
|
||||
content text not null,
|
||||
status text not null,
|
||||
changed_by_type text not null,
|
||||
changed_by_id text,
|
||||
reason text not null,
|
||||
created_at text not null,
|
||||
unique (document_id, version)
|
||||
);
|
||||
|
||||
insert into document_versions(id, org_id, document_id, version, title, content, status, changed_by_type, changed_by_id, reason, created_at)
|
||||
select 'dov_' || lower(hex(randomblob(16))), org_id, id, 1, title, content, status,
|
||||
case when author_agent_id is null then 'employee' else 'agent' end, author_agent_id, 'created', created_at
|
||||
from documents;
|
||||
|
||||
insert into schema_migrations(version, name, applied_at)
|
||||
values (65, 'document_versions', datetime('now'));
|
||||
`;
|
||||
@@ -63,6 +63,7 @@ import { taskRunContextSchema } from "./migrations/061-task-run-context";
|
||||
import { providerContextWindowSchema } from "./migrations/062-provider-context-window";
|
||||
import { knowledgeScopeSchema } from "./migrations/063-knowledge-scope";
|
||||
import { knowledgeRevisionsSchema } from "./migrations/064-knowledge-revisions";
|
||||
import { documentVersionsSchema } from "./migrations/065-document-versions";
|
||||
|
||||
interface Migration {
|
||||
version: number;
|
||||
@@ -135,6 +136,7 @@ const MIGRATIONS: Migration[] = [
|
||||
{ version: 62, name: "provider_context_window", sql: providerContextWindowSchema },
|
||||
{ version: 63, name: "knowledge_scope", sql: knowledgeScopeSchema },
|
||||
{ version: 64, name: "knowledge_revisions", sql: knowledgeRevisionsSchema },
|
||||
{ version: 65, name: "document_versions", sql: documentVersionsSchema },
|
||||
];
|
||||
|
||||
const SCHEMA_VERSION = MIGRATIONS[MIGRATIONS.length - 1].version;
|
||||
|
||||
Reference in new issue
Block a user