changing profile id to schema in the whole project

This commit is contained in:
filipriec
2025-06-21 09:57:14 +02:00
parent 9477f53432
commit 63f1b4da2e
8 changed files with 84 additions and 64 deletions

View File

@@ -1,9 +1,12 @@
-- Add migration script here
CREATE TABLE profiles (
CREATE TABLE schemas (
id BIGSERIAL PRIMARY KEY,
name TEXT NOT NULL UNIQUE,
created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP
created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP,
description TEXT,
is_active BOOLEAN DEFAULT TRUE
);
-- Create default profile for existing data
INSERT INTO profiles (name) VALUES ('default');
INSERT INTO schemas (name) VALUES ('default');
CREATE SCHEMA IF NOT EXISTS "default";

View File

@@ -1,5 +1,4 @@
-- Main table definitions
CREATE SCHEMA IF NOT EXISTS gen;
CREATE TABLE table_definitions (
id BIGSERIAL PRIMARY KEY,
@@ -8,7 +7,7 @@ CREATE TABLE table_definitions (
columns JSONB NOT NULL,
indexes JSONB NOT NULL,
created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP,
profile_id BIGINT NOT NULL REFERENCES profiles(id) DEFAULT 1
schema_id BIGINT NOT NULL REFERENCES schemas(id)
);
-- Relationship table for multiple links
@@ -20,9 +19,10 @@ CREATE TABLE table_definition_links (
PRIMARY KEY (source_table_id, linked_table_id)
);
-- Create composite unique index for profile+table combination
CREATE UNIQUE INDEX idx_table_definitions_profile_table
ON table_definitions (profile_id, table_name);
-- Create composite unique index for schema+table combination
CREATE UNIQUE INDEX idx_table_definitions_schema_table
ON table_definitions (schema_id, table_name);
CREATE INDEX idx_links_source ON table_definition_links (source_table_id);
CREATE INDEX idx_links_target ON table_definition_links (linked_table_id);

View File

@@ -8,7 +8,7 @@ CREATE TABLE table_scripts (
script TEXT NOT NULL,
description TEXT,
created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
profile_id BIGINT NOT NULL REFERENCES profiles(id) DEFAULT 1,
schema_id BIGINT NOT NULL REFERENCES schemas(id),
UNIQUE(table_definitions_id, target_column)
);