From 0b528605f24ea176bfb20113032e1fe1817de97d Mon Sep 17 00:00:00 2001 From: Thomas Krampl Date: Mon, 19 Feb 2024 14:01:39 +0100 Subject: [PATCH] Move foreign key to end of schema --- internal/database/migrations/0001_schema.sql | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/database/migrations/0001_schema.sql b/internal/database/migrations/0001_schema.sql index 290514e4b..ed4fd2302 100644 --- a/internal/database/migrations/0001_schema.sql +++ b/internal/database/migrations/0001_schema.sql @@ -74,7 +74,7 @@ CREATE TABLE audit_logs ( CREATE TABLE cost ( id serial PRIMARY KEY, environment text, - team_slug slug REFERENCES teams(slug) ON DELETE CASCADE, + team_slug slug, app text NOT NULL, cost_type text NOT NULL, date date NOT NULL, @@ -337,6 +337,9 @@ ALTER TABLE user_roles ALTER TABLE vulnerability_metrics ADD FOREIGN KEY (dependencytrack_project_id) REFERENCES dependencytrack_projects(id) ON DELETE CASCADE; +ALTER TABLE cost + ADD FOREIGN KEY (team_slug) REFERENCES teams(slug) ON DELETE CASCADE; + -- triggers CREATE TRIGGER reconciler_states_set_updated BEFORE UPDATE