--
-- PostgreSQL database dump
--

-- Dumped from database version 18.1 (Debian 18.1-1.pgdg13+2)
-- Dumped by pg_dump version 18.1

-- Started on 2026-02-18 20:07:03 GMT

SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET transaction_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;

--
-- TOC entry 2 (class 3079 OID 20739)
-- Name: pg_trgm; Type: EXTENSION; Schema: -; Owner: -
--

CREATE EXTENSION IF NOT EXISTS pg_trgm WITH SCHEMA public;


--
-- TOC entry 3606 (class 0 OID 0)
-- Dependencies: 2
-- Name: EXTENSION pg_trgm; Type: COMMENT; Schema: -; Owner: 
--

COMMENT ON EXTENSION pg_trgm IS 'text similarity measurement and index searching based on trigrams';


SET default_tablespace = '';

SET default_table_access_method = heap;

--
-- TOC entry 243 (class 1259 OID 19974)
-- Name: circle_comments; Type: TABLE; Schema: public; Owner: admin
--

CREATE TABLE public.circle_comments (
    circle_id bigint NOT NULL,
    comment_id bigint NOT NULL
);


ALTER TABLE public.circle_comments OWNER TO admin;

--
-- TOC entry 230 (class 1259 OID 19837)
-- Name: circles; Type: TABLE; Schema: public; Owner: admin
--

CREATE TABLE public.circles (
    id bigint NOT NULL,
    name character varying(60) NOT NULL,
    is_public boolean DEFAULT false NOT NULL,
    owning_user_id bigint NOT NULL,
    image_path text,
    colour character(7) DEFAULT '#71677C'::bpchar NOT NULL
);


ALTER TABLE public.circles OWNER TO admin;

--
-- TOC entry 229 (class 1259 OID 19836)
-- Name: circles_id_seq; Type: SEQUENCE; Schema: public; Owner: admin
--

CREATE SEQUENCE public.circles_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.circles_id_seq OWNER TO admin;

--
-- TOC entry 3607 (class 0 OID 0)
-- Dependencies: 229
-- Name: circles_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin
--

ALTER SEQUENCE public.circles_id_seq OWNED BY public.circles.id;


--
-- TOC entry 225 (class 1259 OID 16431)
-- Name: claims; Type: TABLE; Schema: public; Owner: admin
--

CREATE TABLE public.claims (
    id bigint NOT NULL,
    name character varying(60) NOT NULL,
    is_default boolean DEFAULT false NOT NULL
);


ALTER TABLE public.claims OWNER TO admin;

--
-- TOC entry 224 (class 1259 OID 16430)
-- Name: claims_id_seq; Type: SEQUENCE; Schema: public; Owner: admin
--

CREATE SEQUENCE public.claims_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.claims_id_seq OWNER TO admin;

--
-- TOC entry 3608 (class 0 OID 0)
-- Dependencies: 224
-- Name: claims_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin
--

ALTER SEQUENCE public.claims_id_seq OWNED BY public.claims.id;


--
-- TOC entry 239 (class 1259 OID 19919)
-- Name: collection_games; Type: TABLE; Schema: public; Owner: admin
--

CREATE TABLE public.collection_games (
    collection_id bigint NOT NULL,
    game_id bigint NOT NULL
);


ALTER TABLE public.collection_games OWNER TO admin;

--
-- TOC entry 238 (class 1259 OID 19905)
-- Name: collections; Type: TABLE; Schema: public; Owner: admin
--

CREATE TABLE public.collections (
    id bigint NOT NULL,
    user_id bigint NOT NULL,
    name character varying(60) NOT NULL
);


ALTER TABLE public.collections OWNER TO admin;

--
-- TOC entry 237 (class 1259 OID 19904)
-- Name: collections_id_seq; Type: SEQUENCE; Schema: public; Owner: admin
--

CREATE SEQUENCE public.collections_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.collections_id_seq OWNER TO admin;

--
-- TOC entry 3609 (class 0 OID 0)
-- Dependencies: 237
-- Name: collections_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin
--

ALTER SEQUENCE public.collections_id_seq OWNED BY public.collections.id;


--
-- TOC entry 241 (class 1259 OID 19940)
-- Name: comments; Type: TABLE; Schema: public; Owner: admin
--

CREATE TABLE public.comments (
    id bigint NOT NULL,
    created_by_user_id bigint NOT NULL,
    created_at timestamp(6) with time zone DEFAULT now() NOT NULL,
    content text NOT NULL
);


ALTER TABLE public.comments OWNER TO admin;

--
-- TOC entry 240 (class 1259 OID 19939)
-- Name: comments_id_seq; Type: SEQUENCE; Schema: public; Owner: admin
--

CREATE SEQUENCE public.comments_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.comments_id_seq OWNER TO admin;

--
-- TOC entry 3610 (class 0 OID 0)
-- Dependencies: 240
-- Name: comments_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin
--

ALTER SEQUENCE public.comments_id_seq OWNED BY public.comments.id;


--
-- TOC entry 232 (class 1259 OID 19848)
-- Name: games; Type: TABLE; Schema: public; Owner: admin
--

CREATE TABLE public.games (
    id bigint NOT NULL,
    name character varying(60) CONSTRAINT games_names_not_null NOT NULL,
    image_path text,
    bgg_id bigint
);


ALTER TABLE public.games OWNER TO admin;

--
-- TOC entry 231 (class 1259 OID 19847)
-- Name: games_id_seq; Type: SEQUENCE; Schema: public; Owner: admin
--

CREATE SEQUENCE public.games_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.games_id_seq OWNER TO admin;

--
-- TOC entry 3611 (class 0 OID 0)
-- Dependencies: 231
-- Name: games_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin
--

ALTER SEQUENCE public.games_id_seq OWNED BY public.games.id;


--
-- TOC entry 242 (class 1259 OID 19959)
-- Name: match_comments; Type: TABLE; Schema: public; Owner: admin
--

CREATE TABLE public.match_comments (
    match_id bigint NOT NULL,
    comment_id bigint NOT NULL
);


ALTER TABLE public.match_comments OWNER TO admin;

--
-- TOC entry 235 (class 1259 OID 19872)
-- Name: match_players; Type: TABLE; Schema: public; Owner: admin
--

CREATE TABLE public.match_players (
    match_id bigint NOT NULL,
    player_id bigint NOT NULL,
    standing integer NOT NULL,
    elo_change integer NOT NULL
);


ALTER TABLE public.match_players OWNER TO admin;

--
-- TOC entry 234 (class 1259 OID 19859)
-- Name: matches; Type: TABLE; Schema: public; Owner: admin
--

CREATE TABLE public.matches (
    id bigint NOT NULL,
    game_id bigint NOT NULL,
    owning_user_id bigint NOT NULL
);


ALTER TABLE public.matches OWNER TO admin;

--
-- TOC entry 233 (class 1259 OID 19858)
-- Name: matches_id_seq; Type: SEQUENCE; Schema: public; Owner: admin
--

CREATE SEQUENCE public.matches_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.matches_id_seq OWNER TO admin;

--
-- TOC entry 3612 (class 0 OID 0)
-- Dependencies: 233
-- Name: matches_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin
--

ALTER SEQUENCE public.matches_id_seq OWNED BY public.matches.id;


--
-- TOC entry 236 (class 1259 OID 19889)
-- Name: player_circles; Type: TABLE; Schema: public; Owner: admin
--

CREATE TABLE public.player_circles (
    player_id bigint NOT NULL,
    circle_id bigint NOT NULL
);


ALTER TABLE public.player_circles OWNER TO admin;

--
-- TOC entry 228 (class 1259 OID 19809)
-- Name: players; Type: TABLE; Schema: public; Owner: admin
--

CREATE TABLE public.players (
    id bigint NOT NULL,
    name text NOT NULL,
    elo integer DEFAULT 1000 NOT NULL,
    is_rating_locked boolean DEFAULT false NOT NULL,
    can_be_multiple boolean DEFAULT false NOT NULL
);


ALTER TABLE public.players OWNER TO admin;

--
-- TOC entry 227 (class 1259 OID 19808)
-- Name: players_id_seq; Type: SEQUENCE; Schema: public; Owner: admin
--

CREATE SEQUENCE public.players_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.players_id_seq OWNER TO admin;

--
-- TOC entry 3613 (class 0 OID 0)
-- Dependencies: 227
-- Name: players_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin
--

ALTER SEQUENCE public.players_id_seq OWNED BY public.players.id;


--
-- TOC entry 226 (class 1259 OID 16439)
-- Name: user_claims; Type: TABLE; Schema: public; Owner: admin
--

CREATE TABLE public.user_claims (
    user_id bigint,
    claim_id integer
);


ALTER TABLE public.user_claims OWNER TO admin;

--
-- TOC entry 223 (class 1259 OID 16392)
-- Name: users; Type: TABLE; Schema: public; Owner: admin
--

CREATE TABLE public.users (
    id bigint NOT NULL,
    username character varying(20) NOT NULL,
    pass_hash text NOT NULL,
    is_active boolean DEFAULT true CONSTRAINT users_active_not_null NOT NULL,
    is_admin boolean DEFAULT false NOT NULL,
    player_id bigint NOT NULL,
    failed_attempts integer DEFAULT 0 NOT NULL,
    last_login_attempt date,
    require_new_password boolean DEFAULT false NOT NULL,
    refresh_count bigint DEFAULT 0 NOT NULL
);


ALTER TABLE public.users OWNER TO admin;

--
-- TOC entry 220 (class 1259 OID 16389)
-- Name: users_id_seq; Type: SEQUENCE; Schema: public; Owner: admin
--

CREATE SEQUENCE public.users_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.users_id_seq OWNER TO admin;

--
-- TOC entry 3614 (class 0 OID 0)
-- Dependencies: 220
-- Name: users_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin
--

ALTER SEQUENCE public.users_id_seq OWNED BY public.users.id;


--
-- TOC entry 222 (class 1259 OID 16391)
-- Name: users_pass_hash_seq; Type: SEQUENCE; Schema: public; Owner: admin
--

CREATE SEQUENCE public.users_pass_hash_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.users_pass_hash_seq OWNER TO admin;

--
-- TOC entry 3615 (class 0 OID 0)
-- Dependencies: 222
-- Name: users_pass_hash_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin
--

ALTER SEQUENCE public.users_pass_hash_seq OWNED BY public.users.pass_hash;


--
-- TOC entry 221 (class 1259 OID 16390)
-- Name: users_username_seq; Type: SEQUENCE; Schema: public; Owner: admin
--

CREATE SEQUENCE public.users_username_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.users_username_seq OWNER TO admin;

--
-- TOC entry 3616 (class 0 OID 0)
-- Dependencies: 221
-- Name: users_username_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin
--

ALTER SEQUENCE public.users_username_seq OWNED BY public.users.username;


--
-- TOC entry 3412 (class 2604 OID 19840)
-- Name: circles id; Type: DEFAULT; Schema: public; Owner: admin
--

ALTER TABLE ONLY public.circles ALTER COLUMN id SET DEFAULT nextval('public.circles_id_seq'::regclass);


--
-- TOC entry 3406 (class 2604 OID 20726)
-- Name: claims id; Type: DEFAULT; Schema: public; Owner: admin
--

ALTER TABLE ONLY public.claims ALTER COLUMN id SET DEFAULT nextval('public.claims_id_seq'::regclass);


--
-- TOC entry 3417 (class 2604 OID 19908)
-- Name: collections id; Type: DEFAULT; Schema: public; Owner: admin
--

ALTER TABLE ONLY public.collections ALTER COLUMN id SET DEFAULT nextval('public.collections_id_seq'::regclass);


--
-- TOC entry 3418 (class 2604 OID 19943)
-- Name: comments id; Type: DEFAULT; Schema: public; Owner: admin
--

ALTER TABLE ONLY public.comments ALTER COLUMN id SET DEFAULT nextval('public.comments_id_seq'::regclass);


--
-- TOC entry 3415 (class 2604 OID 19851)
-- Name: games id; Type: DEFAULT; Schema: public; Owner: admin
--

ALTER TABLE ONLY public.games ALTER COLUMN id SET DEFAULT nextval('public.games_id_seq'::regclass);


--
-- TOC entry 3416 (class 2604 OID 19862)
-- Name: matches id; Type: DEFAULT; Schema: public; Owner: admin
--

ALTER TABLE ONLY public.matches ALTER COLUMN id SET DEFAULT nextval('public.matches_id_seq'::regclass);


--
-- TOC entry 3408 (class 2604 OID 19812)
-- Name: players id; Type: DEFAULT; Schema: public; Owner: admin
--

ALTER TABLE ONLY public.players ALTER COLUMN id SET DEFAULT nextval('public.players_id_seq'::regclass);


--
-- TOC entry 3398 (class 2604 OID 16395)
-- Name: users id; Type: DEFAULT; Schema: public; Owner: admin
--

ALTER TABLE ONLY public.users ALTER COLUMN id SET DEFAULT nextval('public.users_id_seq'::regclass);


--
-- TOC entry 3399 (class 2604 OID 16405)
-- Name: users username; Type: DEFAULT; Schema: public; Owner: admin
--

ALTER TABLE ONLY public.users ALTER COLUMN username SET DEFAULT nextval('public.users_username_seq'::regclass);


--
-- TOC entry 3400 (class 2604 OID 16411)
-- Name: users pass_hash; Type: DEFAULT; Schema: public; Owner: admin
--

ALTER TABLE ONLY public.users ALTER COLUMN pass_hash SET DEFAULT nextval('public.users_pass_hash_seq'::regclass);


--
-- TOC entry 3427 (class 2606 OID 19846)
-- Name: circles circles_pkey; Type: CONSTRAINT; Schema: public; Owner: admin
--

ALTER TABLE ONLY public.circles
    ADD CONSTRAINT circles_pkey PRIMARY KEY (id);


--
-- TOC entry 3423 (class 2606 OID 20728)
-- Name: claims claims_pkey; Type: CONSTRAINT; Schema: public; Owner: admin
--

ALTER TABLE ONLY public.claims
    ADD CONSTRAINT claims_pkey PRIMARY KEY (id);


--
-- TOC entry 3433 (class 2606 OID 19913)
-- Name: collections collections_pkey; Type: CONSTRAINT; Schema: public; Owner: admin
--

ALTER TABLE ONLY public.collections
    ADD CONSTRAINT collections_pkey PRIMARY KEY (id);


--
-- TOC entry 3435 (class 2606 OID 19952)
-- Name: comments comments_pkey; Type: CONSTRAINT; Schema: public; Owner: admin
--

ALTER TABLE ONLY public.comments
    ADD CONSTRAINT comments_pkey PRIMARY KEY (id);


--
-- TOC entry 3429 (class 2606 OID 19857)
-- Name: games games_pkey; Type: CONSTRAINT; Schema: public; Owner: admin
--

ALTER TABLE ONLY public.games
    ADD CONSTRAINT games_pkey PRIMARY KEY (id);


--
-- TOC entry 3431 (class 2606 OID 19866)
-- Name: matches matches_pkey; Type: CONSTRAINT; Schema: public; Owner: admin
--

ALTER TABLE ONLY public.matches
    ADD CONSTRAINT matches_pkey PRIMARY KEY (id);


--
-- TOC entry 3425 (class 2606 OID 19824)
-- Name: players players_pkey; Type: CONSTRAINT; Schema: public; Owner: admin
--

ALTER TABLE ONLY public.players
    ADD CONSTRAINT players_pkey PRIMARY KEY (id);


--
-- TOC entry 3421 (class 2606 OID 16403)
-- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: admin
--

ALTER TABLE ONLY public.users
    ADD CONSTRAINT users_pkey PRIMARY KEY (id);


--
-- TOC entry 3452 (class 2606 OID 19979)
-- Name: circle_comments circle_comments_circles_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin
--

ALTER TABLE ONLY public.circle_comments
    ADD CONSTRAINT circle_comments_circles_fkey FOREIGN KEY (circle_id) REFERENCES public.circles(id);


--
-- TOC entry 3453 (class 2606 OID 19984)
-- Name: circle_comments circle_comments_comment_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin
--

ALTER TABLE ONLY public.circle_comments
    ADD CONSTRAINT circle_comments_comment_fkey FOREIGN KEY (comment_id) REFERENCES public.comments(id);


--
-- TOC entry 3439 (class 2606 OID 20708)
-- Name: circles circles_users_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin
--

ALTER TABLE ONLY public.circles
    ADD CONSTRAINT circles_users_fkey FOREIGN KEY (owning_user_id) REFERENCES public.users(id) NOT VALID;


--
-- TOC entry 3447 (class 2606 OID 19924)
-- Name: collection_games collection_games_collections_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin
--

ALTER TABLE ONLY public.collection_games
    ADD CONSTRAINT collection_games_collections_fkey FOREIGN KEY (collection_id) REFERENCES public.collections(id);


--
-- TOC entry 3448 (class 2606 OID 19929)
-- Name: collection_games collection_games_games_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin
--

ALTER TABLE ONLY public.collection_games
    ADD CONSTRAINT collection_games_games_fkey FOREIGN KEY (game_id) REFERENCES public.games(id);


--
-- TOC entry 3446 (class 2606 OID 19914)
-- Name: collections collections_users_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin
--

ALTER TABLE ONLY public.collections
    ADD CONSTRAINT collections_users_fkey FOREIGN KEY (user_id) REFERENCES public.users(id);


--
-- TOC entry 3449 (class 2606 OID 19953)
-- Name: comments comments_users_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin
--

ALTER TABLE ONLY public.comments
    ADD CONSTRAINT comments_users_fkey FOREIGN KEY (created_by_user_id) REFERENCES public.users(id);


--
-- TOC entry 3450 (class 2606 OID 19969)
-- Name: match_comments match_comments_comments_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin
--

ALTER TABLE ONLY public.match_comments
    ADD CONSTRAINT match_comments_comments_fkey FOREIGN KEY (comment_id) REFERENCES public.comments(id);


--
-- TOC entry 3451 (class 2606 OID 19964)
-- Name: match_comments match_comments_matches_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin
--

ALTER TABLE ONLY public.match_comments
    ADD CONSTRAINT match_comments_matches_fkey FOREIGN KEY (match_id) REFERENCES public.matches(id);


--
-- TOC entry 3442 (class 2606 OID 19884)
-- Name: match_players match_players_matches_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin
--

ALTER TABLE ONLY public.match_players
    ADD CONSTRAINT match_players_matches_fkey FOREIGN KEY (match_id) REFERENCES public.matches(id);


--
-- TOC entry 3443 (class 2606 OID 19879)
-- Name: match_players match_players_players_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin
--

ALTER TABLE ONLY public.match_players
    ADD CONSTRAINT match_players_players_fkey FOREIGN KEY (player_id) REFERENCES public.players(id);


--
-- TOC entry 3440 (class 2606 OID 19867)
-- Name: matches matches_games_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin
--

ALTER TABLE ONLY public.matches
    ADD CONSTRAINT matches_games_fkey FOREIGN KEY (game_id) REFERENCES public.games(id);


--
-- TOC entry 3441 (class 2606 OID 20721)
-- Name: matches matches_users_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin
--

ALTER TABLE ONLY public.matches
    ADD CONSTRAINT matches_users_fkey FOREIGN KEY (owning_user_id) REFERENCES public.users(id) NOT VALID;


--
-- TOC entry 3444 (class 2606 OID 19899)
-- Name: player_circles player_circles_circles_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin
--

ALTER TABLE ONLY public.player_circles
    ADD CONSTRAINT player_circles_circles_fkey FOREIGN KEY (circle_id) REFERENCES public.circles(id);


--
-- TOC entry 3445 (class 2606 OID 19894)
-- Name: player_circles player_circles_players_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin
--

ALTER TABLE ONLY public.player_circles
    ADD CONSTRAINT player_circles_players_fkey FOREIGN KEY (player_id) REFERENCES public.players(id);


--
-- TOC entry 3437 (class 2606 OID 20730)
-- Name: user_claims user_claims_claimid_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin
--

ALTER TABLE ONLY public.user_claims
    ADD CONSTRAINT user_claims_claimid_fkey FOREIGN KEY (claim_id) REFERENCES public.claims(id);


--
-- TOC entry 3438 (class 2606 OID 16442)
-- Name: user_claims user_claims_userid_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin
--

ALTER TABLE ONLY public.user_claims
    ADD CONSTRAINT user_claims_userid_fkey FOREIGN KEY (user_id) REFERENCES public.users(id);


--
-- TOC entry 3436 (class 2606 OID 19830)
-- Name: users users_players_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin
--

ALTER TABLE ONLY public.users
    ADD CONSTRAINT users_players_fkey FOREIGN KEY (player_id) REFERENCES public.players(id) NOT VALID;


-- Completed on 2026-02-18 20:07:03 GMT

--
-- PostgreSQL database dump complete
--
