Files
kickkingsapi/schemas/table_matches.md
T
2026-09-04 19:11:49 +00:00

35 lines
1.4 KiB
Markdown

create table public.matches (
id bigint generated by default as identity not null,
created_at timestamp with time zone not null default now(),
user_red bigint null,
user_blue bigint null,
entry_fee bigint null default '34'::bigint,
prize_cc bigint null default '100'::bigint,
red_joined_at timestamp with time zone null,
blue_joined_at timestamp with time zone null,
status smallint null default '0'::smallint,
winner_id bigint null,
escrow_user_id bigint null,
entries_collected_at timestamp with time zone null,
settled_at timestamp with time zone null,
cc_awarded_red boolean null,
cc_awarded_blue boolean null,
red_score smallint null,
blue_score smallint null,
forfeit boolean null,
mmr_delta integer null,
constraint matches_pkey primary key (id),
constraint matches_user_blue_fkey foreign KEY (user_blue) references users (id),
constraint matches_user_red_fkey foreign KEY (user_red) references users (id),
constraint matches_winner_id_fkey foreign KEY (winner_id) references users (id),
constraint matches_escrow_user_id_fkey foreign KEY (escrow_user_id) references users (id)
) TABLESPACE pg_default;
-- Apply migrations/RPCs in order:
-- schemas/alter_matches_escrow.sql
-- schemas/rpc_collect_match_entries.sql
-- schemas/alter_matches_cc_awarded.sql
-- schemas/alter_users_mmr.sql
-- schemas/alter_matches_mmr.sql
-- schemas/rpc_settle_match_reward.sql