sorarebuddy/db/migrations/00004_club_memberships.sql
2024-05-23 08:18:54 +04:00

15 lines
499 B
SQL

-- +goose Up
CREATE TABLE IF NOT EXISTS club_memberships(
id TEXT PRIMARY KEY,
player_slug TEXT NOT NULL REFERENCES players(slug),
club_slug TEXT NOT NULL REFERENCES teams(slug),
start_date DATE NOT NULL,
end_date DATE
);
CREATE INDEX IF NOT EXISTS club_memberships_player_slug_start_date_end_date_idx ON club_memberships(player_slug, start_date, end_date);
-- +goose Down
DROP INDEX IF EXISTS club_memberships_player_slug_start_date_end_date_idx;
DROP TABLE IF EXISTS club_memberships;