sorarebuddy/db/migrations/00004_club_memberships.sql
2024-06-06 09:52:54 +04:00

15 lines
513 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;