-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathschema.sql
More file actions
40 lines (35 loc) · 1.69 KB
/
Copy pathschema.sql
File metadata and controls
40 lines (35 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
CREATE TABLE IF NOT EXISTS designs (
id TEXT PRIMARY KEY DEFAULT (lower(hex(randomblob(4)) || '-' || hex(randomblob(2)) || '-4' || substr(hex(randomblob(2)),2) || '-' || substr('89ab',abs(random()) % 4 + 1, 1) || substr(hex(randomblob(2)),2) || '-' || hex(randomblob(6)))),
name TEXT DEFAULT 'Untitled Design',
canvas_json TEXT DEFAULT '{}',
width INTEGER DEFAULT 1080,
height INTEGER DEFAULT 1080,
thumbnail_url TEXT,
created_at TEXT DEFAULT (datetime('now')),
updated_at TEXT DEFAULT (datetime('now'))
);
CREATE TABLE IF NOT EXISTS templates (
id TEXT PRIMARY KEY,
name TEXT NOT NULL,
category TEXT NOT NULL,
canvas_json TEXT NOT NULL,
width INTEGER NOT NULL,
height INTEGER NOT NULL,
thumbnail_url TEXT,
sort_order INTEGER DEFAULT 0
);
CREATE TABLE IF NOT EXISTS pages (
id TEXT PRIMARY KEY DEFAULT (lower(hex(randomblob(4)) || '-' || hex(randomblob(2)) || '-4' || substr(hex(randomblob(2)),2) || '-' || substr('89ab',abs(random()) % 4 + 1, 1) || substr(hex(randomblob(2)),2) || '-' || hex(randomblob(6)))),
design_id TEXT NOT NULL,
title TEXT DEFAULT 'Page 1',
canvas_json TEXT DEFAULT '{}',
sort_order INTEGER DEFAULT 0,
created_at TEXT DEFAULT (datetime('now')),
FOREIGN KEY (design_id) REFERENCES designs(id) ON DELETE CASCADE
);
CREATE INDEX IF NOT EXISTS idx_pages_design ON pages(design_id);
CREATE INDEX IF NOT EXISTS idx_templates_category ON templates(category);
-- Starter templates are NOT seeded here. Clawnify applies this file as DDL
-- only — any non-DDL statement (INSERT, UPDATE, PRAGMA, ...) fails the whole
-- deploy — so the template rows live in src/server/seed-templates.ts and are
-- inserted by ensureSeeded() in src/server/index.ts on first request.