Skip to content

Commit 4d13582

Browse files
committed
reorganize schema files
1 parent cb9946b commit 4d13582

4 files changed

Lines changed: 15 additions & 16 deletions

File tree

databases/catdat/schema/001_structures.sql

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,19 @@ CREATE TABLE structure_comments (
4141

4242
CREATE INDEX idx_structure_comments ON structure_comments (structure_id);
4343

44+
CREATE TABLE tags (
45+
id INTEGER PRIMARY KEY,
46+
tag TEXT NOT NULL,
47+
type TEXT NOT NULL,
48+
UNIQUE (tag, type),
49+
FOREIGN KEY (type) REFERENCES structure_types (type) ON DELETE RESTRICT
50+
);
4451

52+
CREATE TABLE structure_tag_assignments (
53+
structure_id TEXT NOT NULL,
54+
type TEXT NOT NULL,
55+
tag TEXT NOT NULL,
56+
PRIMARY KEY (structure_id, type, tag),
57+
FOREIGN KEY (structure_id, type) REFERENCES structures (id, type) ON DELETE CASCADE,
58+
FOREIGN KEY (tag, type) REFERENCES tags (tag, type) ON DELETE CASCADE
59+
);
File renamed without changes.

databases/catdat/schema/002_tags.sql

Lines changed: 0 additions & 16 deletions
This file was deleted.
File renamed without changes.

0 commit comments

Comments
 (0)