aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2025-12-31 16:07:00 +0900
committernsfisis <nsfisis@gmail.com>2025-12-31 16:07:46 +0900
commite4aeded6c105de6c8af6a931d5c24a659dcbd138 (patch)
tree7d04ec5e875c1e4d0e0ae8e8c31b02235267b4e5 /src
parent3f9165e4fcbd83b7f98875a4a3de4036b67dde37 (diff)
downloadkioku-e4aeded6c105de6c8af6a931d5c24a659dcbd138.tar.gz
kioku-e4aeded6c105de6c8af6a931d5c24a659dcbd138.tar.zst
kioku-e4aeded6c105de6c8af6a931d5c24a659dcbd138.zip
feat(crdt): add database migration for crdt_documents table
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 <noreply@anthropic.com>
Diffstat (limited to 'src')
-rw-r--r--src/server/db/schema-crdt.ts5
-rw-r--r--src/server/db/schema.ts3
2 files changed, 6 insertions, 2 deletions
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,
diff --git a/src/server/db/schema.ts b/src/server/db/schema.ts
index 0471a92..50caf85 100644
--- a/src/server/db/schema.ts
+++ b/src/server/db/schema.ts
@@ -199,3 +199,6 @@ export const reviewLogs = pgTable("review_logs", {
durationMs: integer("duration_ms"),
syncVersion: integer("sync_version").notNull().default(0),
});
+
+// Re-export CRDT schema
+export * from "./schema-crdt";