Full document, spreadsheet, slideshow, and diagram tooling
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix(db): add 'calendar' to documents type CHECK constraint

The SQLite CHECK constraint on the documents table didn't include
'calendar', causing a 500 error when creating calendar documents.
Updated both the initial schema and the migration to include it.

Closes #481

+5 -5
+5 -5
server/db.ts
··· 34 34 db.exec(` 35 35 CREATE TABLE IF NOT EXISTS documents ( 36 36 id TEXT PRIMARY KEY, 37 - type TEXT NOT NULL CHECK(type IN ('doc','sheet','form','slide','diagram')), 37 + type TEXT NOT NULL CHECK(type IN ('doc','sheet','form','slide','diagram','calendar')), 38 38 name_encrypted TEXT, 39 39 snapshot BLOB, 40 40 share_mode TEXT DEFAULT 'edit', ··· 79 79 console.log('Migrated: added owner column'); 80 80 } 81 81 82 - // Expand type CHECK constraint to include form, slide, diagram 82 + // Expand type CHECK constraint to include form, slide, diagram, calendar 83 83 try { 84 84 const tableInfo = db.prepare("SELECT sql FROM sqlite_master WHERE type='table' AND name='documents'").get() as { sql: string } | undefined; 85 - if (tableInfo && !tableInfo.sql.includes("'slide'")) { 85 + if (tableInfo && !tableInfo.sql.includes("'calendar'")) { 86 86 db.exec("DROP TABLE IF EXISTS documents_new"); 87 87 db.exec(` 88 88 CREATE TABLE documents_new ( 89 89 id TEXT PRIMARY KEY, 90 - type TEXT NOT NULL CHECK(type IN ('doc','sheet','form','slide','diagram')), 90 + type TEXT NOT NULL CHECK(type IN ('doc','sheet','form','slide','diagram','calendar')), 91 91 name_encrypted TEXT, 92 92 snapshot BLOB, 93 93 share_mode TEXT DEFAULT 'edit', ··· 102 102 DROP TABLE documents; 103 103 ALTER TABLE documents_new RENAME TO documents; 104 104 `); 105 - console.log('Migrated: expanded type CHECK for slide/diagram/form'); 105 + console.log('Migrated: expanded type CHECK for calendar'); 106 106 } 107 107 } catch (e) { 108 108 console.log('Type migration skipped:', (e as Error).message);