diff --git a/api/migrations/2025-01-27-235752_metric_files/down.sql b/api/migrations/2025-01-27-235752_metric_files/down.sql new file mode 100644 index 000000000..6ee033ab0 --- /dev/null +++ b/api/migrations/2025-01-27-235752_metric_files/down.sql @@ -0,0 +1,12 @@ +-- This file should undo anything in `up.sql` +-- Drop trigger +DROP TRIGGER IF EXISTS set_timestamp ON metric_files; + +-- Drop indexes +DROP INDEX IF EXISTS metric_files_deleted_at_idx; +DROP INDEX IF EXISTS metric_files_created_by_idx; +DROP INDEX IF EXISTS metric_files_organization_id_idx; + +-- Drop table +DROP TABLE IF EXISTS metric_files; + diff --git a/api/migrations/2025-01-27-235752_metric_files/up.sql b/api/migrations/2025-01-27-235752_metric_files/up.sql new file mode 100644 index 000000000..b55f01b44 --- /dev/null +++ b/api/migrations/2025-01-27-235752_metric_files/up.sql @@ -0,0 +1,27 @@ +-- Your SQL goes here +CREATE TABLE metric_files ( + id UUID PRIMARY KEY DEFAULT gen_random_uuid(), + name VARCHAR NOT NULL, + file_name VARCHAR NOT NULL, + content JSONB NOT NULL, + verification BOOLEAN DEFAULT FALSE, + evaluation_obj JSONB, + evaluation_summary TEXT, + evaluation_score FLOAT, + organization_id UUID NOT NULL, + created_by UUID NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP, + deleted_at TIMESTAMP WITH TIME ZONE +); + +-- Add indexes +CREATE INDEX metric_files_organization_id_idx ON metric_files(organization_id); +CREATE INDEX metric_files_created_by_idx ON metric_files(created_by); +CREATE INDEX metric_files_deleted_at_idx ON metric_files(deleted_at); + +-- Add trigger to update updated_at timestamp +CREATE TRIGGER set_timestamp + BEFORE UPDATE ON metric_files + FOR EACH ROW + EXECUTE PROCEDURE trigger_set_timestamp(); diff --git a/api/migrations/2025-01-27-235858_dashboard_files/down.sql b/api/migrations/2025-01-27-235858_dashboard_files/down.sql new file mode 100644 index 000000000..d9a93fe9a --- /dev/null +++ b/api/migrations/2025-01-27-235858_dashboard_files/down.sql @@ -0,0 +1 @@ +-- This file should undo anything in `up.sql` diff --git a/api/migrations/2025-01-27-235858_dashboard_files/up.sql b/api/migrations/2025-01-27-235858_dashboard_files/up.sql new file mode 100644 index 000000000..b37f10d95 --- /dev/null +++ b/api/migrations/2025-01-27-235858_dashboard_files/up.sql @@ -0,0 +1 @@ +-- Your SQL goes here