Update foreign key constraints in database migrations

This commit is contained in:
Luis Eduardo Jeréz Girón
2024-07-22 23:29:25 -06:00
parent 4612eac0fd
commit 6798397dc6
3 changed files with 4 additions and 4 deletions

View File

@@ -2,7 +2,7 @@
-- +goose StatementBegin
CREATE TABLE IF NOT EXISTS sessions (
id UUID NOT NULL DEFAULT uuid_generate_v4() PRIMARY KEY,
user_id UUID NOT NULL REFERENCES users(id),
user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
token TEXT NOT NULL UNIQUE,

View File

@@ -2,8 +2,8 @@
-- +goose StatementBegin
CREATE TABLE IF NOT EXISTS backups (
id UUID NOT NULL DEFAULT uuid_generate_v4() PRIMARY KEY,
database_id UUID NOT NULL REFERENCES databases(id),
destination_id UUID NOT NULL REFERENCES destinations(id),
database_id UUID NOT NULL REFERENCES databases(id) ON DELETE CASCADE,
destination_id UUID NOT NULL REFERENCES destinations(id) ON DELETE CASCADE,
name TEXT NOT NULL,
cron_expression TEXT NOT NULL UNIQUE,

View File

@@ -2,7 +2,7 @@
-- +goose StatementBegin
CREATE TABLE IF NOT EXISTS executions (
id UUID NOT NULL DEFAULT uuid_generate_v4() PRIMARY KEY,
backup_id UUID NOT NULL REFERENCES backups(id),
backup_id UUID NOT NULL REFERENCES backups(id) ON DELETE CASCADE,
status TEXT NOT NULL CHECK (
status IN ('running', 'success', 'failed', 'deleted')