persmgr/migrations/20250913111748_records_awards.up.sql
2025-09-13 15:52:49 +03:00

12 lines
469 B
SQL

CREATE TABLE IF NOT EXISTS records_awards (
id BIGSERIAL PRIMARY KEY NOT NULL,
user_id BIGINT NOT NULL,
award_id BIGINT NOT NULL,
author_id BIGINT NOT NULL,
created_at BIGINT NOT NULL,
CONSTRAINT fk_user FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE,
CONSTRAINT fk_author FOREIGN KEY(author_id) REFERENCES users(id) ON DELETE SET NULL,
CONSTRAINT fk_award FOREIGN KEY (award_id) REFERENCES awards(id) ON DELETE CASCADE
);