very general setup with custom profiles

This commit is contained in:
filipriec
2025-03-01 16:28:33 +01:00
parent b31242e63b
commit 1fa69d8d88
2 changed files with 56 additions and 39 deletions

View File

@@ -0,0 +1,21 @@
-- Add migration script here
CREATE TABLE table_definitions (
id BIGSERIAL PRIMARY KEY,
deleted BOOLEAN NOT NULL DEFAULT FALSE,
table_name TEXT NOT NULL UNIQUE,
columns JSONB NOT NULL,
indexes JSONB NOT NULL,
created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP,
profile_id BIGINT NOT NULL REFERENCES profiles(id) DEFAULT 1,
linked_table_id BIGINT REFERENCES table_definitions(id)
);
-- Create composite unique index for profile+table combination
CREATE UNIQUE INDEX idx_table_definitions_profile_table
ON table_definitions (profile_id, table_name);
-- Add self-referential foreign key constraint
ALTER TABLE table_definitions
ADD CONSTRAINT fk_linked_table
FOREIGN KEY (linked_table_id)
REFERENCES table_definitions(id);