From e4aeded6c105de6c8af6a931d5c24a659dcbd138 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Wed, 31 Dec 2025 16:07:00 +0900 Subject: feat(crdt): add database migration for crdt_documents table MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add Drizzle migration to create the crdt_documents table with: - UUID primary key with auto-generation - Foreign key to users table with cascade delete - Unique index on (user_id, entity_type, entity_id) - Indexes for entity_type and sync_version queries 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- src/server/db/schema-crdt.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/server/db/schema-crdt.ts') diff --git a/src/server/db/schema-crdt.ts b/src/server/db/schema-crdt.ts index 2567609..c5ed4bc 100644 --- a/src/server/db/schema-crdt.ts +++ b/src/server/db/schema-crdt.ts @@ -15,10 +15,11 @@ import { integer, pgTable, timestamp, + uniqueIndex, uuid, varchar, } from "drizzle-orm/pg-core"; -import { users } from "./schema.js"; +import { users } from "./schema"; /** * Valid entity types for CRDT documents @@ -70,7 +71,7 @@ export const crdtDocuments = pgTable( }, (table) => [ // Unique constraint on (user_id, entity_type, entity_id) - index("crdt_documents_user_entity_idx").on( + uniqueIndex("crdt_documents_user_entity_idx").on( table.userId, table.entityType, table.entityId, -- cgit v1.2.3-70-g09d2