migrations needs order fix, fixing to save
This commit is contained in:
@@ -2,11 +2,20 @@
|
||||
CREATE TABLE table_definitions (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
deleted BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
firma TEXT NOT NULL,
|
||||
table_name TEXT NOT NULL UNIQUE,
|
||||
columns JSONB NOT NULL,
|
||||
indexes JSONB NOT NULL,
|
||||
created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP
|
||||
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 INDEX idx_table_definitions_table_name ON table_definitions (table_name);
|
||||
-- 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);
|
||||
|
||||
9
server/migrations/20250301142238_create_profiles.sql
Normal file
9
server/migrations/20250301142238_create_profiles.sql
Normal file
@@ -0,0 +1,9 @@
|
||||
-- Add migration script here
|
||||
CREATE TABLE profiles (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
name TEXT NOT NULL UNIQUE,
|
||||
created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
-- Create default profile for existing data
|
||||
INSERT INTO profiles (name) VALUES ('default');
|
||||
Reference in New Issue
Block a user