verstak/internal/core/storage/migrations.go

30 lines
796 B
Go

package storage
// migration001 — initial schema: nodes + node_meta.
const migration001 = `
CREATE TABLE IF NOT EXISTS nodes (
id TEXT PRIMARY KEY,
parent_id TEXT NULL REFERENCES nodes(id),
type TEXT NOT NULL,
title TEXT NOT NULL,
slug TEXT NOT NULL,
path TEXT NULL,
sort_order INTEGER NOT NULL DEFAULT 0,
created_at TEXT NOT NULL,
updated_at TEXT NOT NULL,
deleted_at TEXT NULL,
revision INTEGER NOT NULL DEFAULT 1,
device_id TEXT NULL
);
CREATE TABLE IF NOT EXISTS node_meta (
node_id TEXT NOT NULL REFERENCES nodes(id),
key TEXT NOT NULL,
value TEXT NOT NULL,
PRIMARY KEY (node_id, key)
);
CREATE INDEX IF NOT EXISTS idx_nodes_parent ON nodes(parent_id);
CREATE INDEX IF NOT EXISTS idx_nodes_deleted ON nodes(deleted_at);
`