--
-- PostgreSQL database dump
--

\restrict LjcixPEhzdGZTDOeT0xiA6Nnvqs2Sbw4952NFQkgwZk6ZS2kxgRTfjtlR2rk6pg

-- Dumped from database version 17.6
-- Dumped by pg_dump version 17.6

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;

--
-- Name: public; Type: SCHEMA; Schema: -; Owner: -
--

-- *not* creating schema, since initdb creates it


--
-- Name: uuid-ossp; Type: EXTENSION; Schema: -; Owner: -
--

CREATE EXTENSION IF NOT EXISTS "uuid-ossp" WITH SCHEMA public;


--
-- Name: EXTENSION "uuid-ossp"; Type: COMMENT; Schema: -; Owner: -
--

COMMENT ON EXTENSION "uuid-ossp" IS 'generate universally unique identifiers (UUIDs)';


SET default_tablespace = '';

SET default_table_access_method = heap;

--
-- Name: blacklist; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.blacklist (
    id bigint NOT NULL,
    player_name text NOT NULL,
    place_id bigint,
    reason text DEFAULT ''::text,
    actor text DEFAULT ''::text,
    created_at timestamp with time zone DEFAULT now(),
    expires_at timestamp with time zone,
    note text DEFAULT ''::text
);


--
-- Name: blacklist_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: blacklist_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.blacklist_id_seq OWNED BY public.blacklist.id;


--
-- Name: player_stats; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.player_stats (
    id integer NOT NULL,
    player_name text NOT NULL,
    hand_money bigint DEFAULT 0,
    bank_money bigint DEFAULT 0,
    inventory jsonb DEFAULT '[]'::jsonb,
    last_seen timestamp with time zone DEFAULT now() NOT NULL,
    queue_pos integer,
    metadata jsonb DEFAULT '{}'::jsonb,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    ts timestamp with time zone,
    note text,
    jobid text,
    server_player text,
    totalplayer integer
);


--
-- Name: player_stats_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: player_stats_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.player_stats_id_seq OWNED BY public.player_stats.id;


--
-- Name: player_stats_logs; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.player_stats_logs (
    id integer NOT NULL,
    player_id integer,
    actor text,
    action text,
    details jsonb DEFAULT '{}'::jsonb,
    created_at timestamp with time zone DEFAULT now() NOT NULL
);


--
-- Name: player_stats_logs_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: player_stats_logs_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.player_stats_logs_id_seq OWNED BY public.player_stats_logs.id;


--
-- Name: room_logs; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.room_logs (
    id integer NOT NULL,
    room_id integer,
    actor text,
    action text,
    details jsonb DEFAULT '{}'::jsonb,
    created_at timestamp with time zone DEFAULT now() NOT NULL
);


--
-- Name: room_logs_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: room_logs_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.room_logs_id_seq OWNED BY public.room_logs.id;


--
-- Name: room_whitelist; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.room_whitelist (
    id integer NOT NULL,
    room_id integer NOT NULL,
    player_name text NOT NULL
);


--
-- Name: room_whitelist_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: room_whitelist_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.room_whitelist_id_seq OWNED BY public.room_whitelist.id;


--
-- Name: rooms; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.rooms (
    id integer NOT NULL,
    filename text NOT NULL,
    player text,
    access_code text NOT NULL,
    place_id text,
    job_id text,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    last_seen timestamp with time zone DEFAULT now() NOT NULL,
    active boolean DEFAULT true NOT NULL,
    metadata jsonb DEFAULT '{}'::jsonb,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    merge_cash boolean DEFAULT true,
    "accessCode" text
);


--
-- Name: rooms_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: rooms_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.rooms_id_seq OWNED BY public.rooms.id;


--
-- Name: settings; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.settings (
    key text NOT NULL,
    value text,
    updated_at timestamp with time zone DEFAULT now()
);


--
-- Name: blacklist id; Type: DEFAULT; Schema: public; Owner: -
--

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


--
-- Name: player_stats id; Type: DEFAULT; Schema: public; Owner: -
--

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


--
-- Name: player_stats_logs id; Type: DEFAULT; Schema: public; Owner: -
--

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


--
-- Name: room_logs id; Type: DEFAULT; Schema: public; Owner: -
--

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


--
-- Name: room_whitelist id; Type: DEFAULT; Schema: public; Owner: -
--

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


--
-- Name: rooms id; Type: DEFAULT; Schema: public; Owner: -
--

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


--
-- Name: blacklist blacklist_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.blacklist
    ADD CONSTRAINT blacklist_pkey PRIMARY KEY (id);


--
-- Name: blacklist blacklist_player_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.blacklist
    ADD CONSTRAINT blacklist_player_unique UNIQUE (player_name);


--
-- Name: player_stats_logs player_stats_logs_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.player_stats_logs
    ADD CONSTRAINT player_stats_logs_pkey PRIMARY KEY (id);


--
-- Name: player_stats player_stats_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.player_stats
    ADD CONSTRAINT player_stats_pkey PRIMARY KEY (id);


--
-- Name: player_stats player_stats_player_name_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.player_stats
    ADD CONSTRAINT player_stats_player_name_key UNIQUE (player_name);


--
-- Name: room_logs room_logs_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.room_logs
    ADD CONSTRAINT room_logs_pkey PRIMARY KEY (id);


--
-- Name: room_whitelist room_whitelist_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.room_whitelist
    ADD CONSTRAINT room_whitelist_pkey PRIMARY KEY (id);


--
-- Name: room_whitelist room_whitelist_room_id_player_name_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.room_whitelist
    ADD CONSTRAINT room_whitelist_room_id_player_name_key UNIQUE (room_id, player_name);


--
-- Name: rooms rooms_filename_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.rooms
    ADD CONSTRAINT rooms_filename_key UNIQUE (filename);


--
-- Name: rooms rooms_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.rooms
    ADD CONSTRAINT rooms_pkey PRIMARY KEY (id);


--
-- Name: settings settings_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.settings
    ADD CONSTRAINT settings_pkey PRIMARY KEY (key);


--
-- Name: blacklist_place_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX blacklist_place_idx ON public.blacklist USING btree (place_id);


--
-- Name: blacklist_player_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX blacklist_player_idx ON public.blacklist USING btree (player_name);


--
-- Name: idx_logs_room; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_logs_room ON public.room_logs USING btree (room_id);


--
-- Name: idx_player_stats_created; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_player_stats_created ON public.player_stats USING btree (created_at);


--
-- Name: idx_player_stats_created_at; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_player_stats_created_at ON public.player_stats USING btree (created_at);


--
-- Name: idx_player_stats_lastseen; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_player_stats_lastseen ON public.player_stats USING btree (last_seen);


--
-- Name: idx_player_stats_name; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_player_stats_name ON public.player_stats USING btree (player_name);


--
-- Name: idx_player_stats_player; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_player_stats_player ON public.player_stats USING btree (player_name);


--
-- Name: idx_player_stats_queue; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_player_stats_queue ON public.player_stats USING btree (queue_pos) WHERE (queue_pos IS NOT NULL);


--
-- Name: idx_player_stats_ts; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_player_stats_ts ON public.player_stats USING btree (ts);


--
-- Name: idx_room_whitelist_player; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_room_whitelist_player ON public.room_whitelist USING btree (player_name);


--
-- Name: idx_room_whitelist_room; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_room_whitelist_room ON public.room_whitelist USING btree (room_id);


--
-- Name: idx_rooms_active; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_rooms_active ON public.rooms USING btree (active);


--
-- Name: idx_rooms_filename; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_rooms_filename ON public.rooms USING btree (filename);


--
-- Name: idx_whitelist_player; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_whitelist_player ON public.room_whitelist USING btree (player_name);


--
-- Name: idx_whitelist_room; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_whitelist_room ON public.room_whitelist USING btree (room_id);


--
-- Name: player_stats_logs player_stats_logs_player_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.player_stats_logs
    ADD CONSTRAINT player_stats_logs_player_id_fkey FOREIGN KEY (player_id) REFERENCES public.player_stats(id) ON DELETE CASCADE;


--
-- Name: room_logs room_logs_room_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.room_logs
    ADD CONSTRAINT room_logs_room_id_fkey FOREIGN KEY (room_id) REFERENCES public.rooms(id) ON DELETE SET NULL;


--
-- Name: room_whitelist room_whitelist_room_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.room_whitelist
    ADD CONSTRAINT room_whitelist_room_id_fkey FOREIGN KEY (room_id) REFERENCES public.rooms(id) ON DELETE CASCADE;


--
-- PostgreSQL database dump complete
--

\unrestrict LjcixPEhzdGZTDOeT0xiA6Nnvqs2Sbw4952NFQkgwZk6ZS2kxgRTfjtlR2rk6pg

