@davoodmehraban89 / VELYQOR / commits / 76010a9
Fork 0

Intelligence, Advanced Charting & Trading Platform

feat(db): add portable workspace persistence schema

davoodmehraban89 committed Oct 5, 2026 at 09:51 UTC 76010a90fc214d9118583cceda15646cb3d1d490
1 file changed +31
db/migrations/0002_workspaces.sql new
+31
@@ -0,0 +1,31 @@
1 +BEGIN;
2 +
3 +CREATE TABLE app_users (
4 + id UUID PRIMARY KEY,
5 + created_at TIMESTAMPTZ NOT NULL DEFAULT now()
6 +);
7 +
8 +CREATE TABLE workspaces (
9 + id UUID PRIMARY KEY,
10 + user_id UUID NOT NULL REFERENCES app_users(id) ON DELETE CASCADE,
11 + name TEXT NOT NULL,
12 + active_symbol TEXT NOT NULL REFERENCES instruments(symbol),
13 + timeframe TEXT NOT NULL,
14 + layout JSONB NOT NULL DEFAULT '{}'::jsonb,
15 + created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
16 + updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
17 +);
18 +CREATE INDEX workspaces_user_idx ON workspaces (user_id, updated_at DESC);
19 +
20 +CREATE TABLE drawings (
21 + id UUID PRIMARY KEY,
22 + workspace_id UUID NOT NULL REFERENCES workspaces(id) ON DELETE CASCADE,
23 + instrument_id BIGINT NOT NULL REFERENCES instruments(id),
24 + drawing_type TEXT NOT NULL,
25 + payload JSONB NOT NULL,
26 + created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
27 + updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
28 +);
29 +CREATE INDEX drawings_workspace_idx ON drawings (workspace_id, instrument_id);
30 +
31 +COMMIT;