-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathschema.sql
More file actions
53 lines (49 loc) · 2.18 KB
/
schema.sql
File metadata and controls
53 lines (49 loc) · 2.18 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
41
42
43
44
45
46
47
48
49
50
51
52
53
-- Canonical schema for fresh deployments of open-studio.
-- Applied once to an empty D1 on first provision. After deployment, the
-- agent appends migrations and this file is auto-regenerated from the
-- live D1 by Clawnify's build pipeline.
--
-- Maintainers: edit this file directly to evolve the schema for new
-- deployments. Never add migration files in this repo — those are
-- instance-only.
--
-- IF NOT EXISTS is retained for local-dev idempotence (`pnpm dev` re-applies
-- this file on every startup against the local --local D1). In production
-- the cloud pipeline applies this against an empty D1 once and switches
-- to migration-tracked deploys; the clauses are harmless either way.
--
-- The inline runtime migration in src/server/index.ts still applies the
-- same schema defensively on every cold start. Once the new migration
-- system is fully verified, that inline block can be removed.
CREATE TABLE IF NOT EXISTS workflows (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL DEFAULT 'Untitled Workflow',
nodes TEXT NOT NULL DEFAULT '[]',
edges TEXT NOT NULL DEFAULT '[]',
viewport TEXT NOT NULL DEFAULT '{"x":0,"y":0,"zoom":1}',
created_at TEXT NOT NULL DEFAULT (datetime('now')),
updated_at TEXT NOT NULL DEFAULT (datetime('now'))
);
CREATE TABLE IF NOT EXISTS generations (
id INTEGER PRIMARY KEY AUTOINCREMENT,
workflow_id INTEGER NOT NULL DEFAULT 0,
node_id TEXT NOT NULL,
prompt TEXT NOT NULL,
model TEXT NOT NULL,
image_url TEXT,
status TEXT NOT NULL DEFAULT 'pending',
error TEXT,
run_id INTEGER,
created_at TEXT NOT NULL DEFAULT (datetime('now'))
);
CREATE TABLE IF NOT EXISTS workflow_runs (
id INTEGER PRIMARY KEY AUTOINCREMENT,
workflow_id INTEGER NOT NULL,
snapshot TEXT,
status TEXT NOT NULL DEFAULT 'pending',
created_at TEXT NOT NULL DEFAULT (datetime('now')),
completed_at TEXT
);
CREATE INDEX IF NOT EXISTS idx_generations_workflow ON generations(workflow_id);
CREATE INDEX IF NOT EXISTS idx_generations_run ON generations(run_id);
CREATE INDEX IF NOT EXISTS idx_workflow_runs_workflow ON workflow_runs(workflow_id);