feat(#221): add V39 migration for tag hierarchy and colors
Adds parent_id FK (ON DELETE SET NULL), self-reference check constraint, parent_id index, and nullable color column to the tag table. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
-- Add self-referencing parent FK for tag hierarchy (adjacency list model).
|
||||
-- ON DELETE SET NULL: deleting a parent promotes its children to root level.
|
||||
ALTER TABLE tag ADD COLUMN parent_id UUID REFERENCES tag(id) ON DELETE SET NULL;
|
||||
ALTER TABLE tag ADD CONSTRAINT chk_tag_no_self_reference CHECK (parent_id != id);
|
||||
CREATE INDEX idx_tag_parent_id ON tag(parent_id);
|
||||
|
||||
-- Optional color token (e.g. "sage", "teal") for root-level tags.
|
||||
-- Validated against the allowed palette in TagService before save.
|
||||
ALTER TABLE tag ADD COLUMN color VARCHAR(20);
|
||||
Reference in New Issue
Block a user