--
-- PostgreSQL database dump
--

\restrict rPXEgF1VaYgsz0ptn4X1KcYROWRPYlYb6daN4zAOY961hMNjxCs5gLhsUZO9N0E

-- Dumped from database version 18.3(ServBay)
-- Dumped by pg_dump version 18.3(ServBay)

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;

SET default_tablespace = '';

SET default_table_access_method = heap;

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

CREATE TABLE public.admin_action_catalog (
    id bigint NOT NULL,
    code character varying(64) NOT NULL,
    name character varying(64) NOT NULL,
    sort_order integer DEFAULT 0 NOT NULL,
    status smallint DEFAULT '1'::smallint NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


--
-- Name: COLUMN admin_action_catalog.status; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN public.admin_action_catalog.status IS '1=enabled,0=disabled';


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

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


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

ALTER SEQUENCE public.admin_action_catalog_id_seq OWNED BY public.admin_action_catalog.id;


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

CREATE TABLE public.admin_api_resource_bindings (
    id bigint NOT NULL,
    api_resource_id bigint NOT NULL,
    menu_action_id bigint NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


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

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


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

ALTER SEQUENCE public.admin_api_resource_bindings_id_seq OWNED BY public.admin_api_resource_bindings.id;


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

CREATE TABLE public.admin_api_resources (
    id bigint NOT NULL,
    code character varying(128) NOT NULL,
    module_code character varying(64) NOT NULL,
    name character varying(128) NOT NULL,
    http_method character varying(16) NOT NULL,
    uri_pattern character varying(255) NOT NULL,
    route_name character varying(255),
    auth_mode character varying(24) DEFAULT 'permission_required'::character varying NOT NULL,
    is_audit_required boolean DEFAULT false NOT NULL,
    status smallint DEFAULT '1'::smallint NOT NULL,
    meta_json json,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


--
-- Name: COLUMN admin_api_resources.auth_mode; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN public.admin_api_resources.auth_mode IS 'login_only|permission_required|internal_only';


--
-- Name: COLUMN admin_api_resources.status; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN public.admin_api_resources.status IS '1=enabled,0=disabled';


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

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


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

ALTER SEQUENCE public.admin_api_resources_id_seq OWNED BY public.admin_api_resources.id;


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

CREATE TABLE public.admin_menu_actions (
    id bigint NOT NULL,
    menu_id bigint NOT NULL,
    action_id bigint NOT NULL,
    permission_code character varying(128) NOT NULL,
    name character varying(128) NOT NULL,
    status smallint DEFAULT '1'::smallint NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


--
-- Name: COLUMN admin_menu_actions.status; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN public.admin_menu_actions.status IS '1=enabled,0=disabled';


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

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


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

ALTER SEQUENCE public.admin_menu_actions_id_seq OWNED BY public.admin_menu_actions.id;


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

CREATE TABLE public.admin_menus (
    id bigint NOT NULL,
    parent_id bigint,
    menu_type character varying(24) NOT NULL,
    code character varying(128) NOT NULL,
    name character varying(128) NOT NULL,
    path character varying(255),
    route_name character varying(255),
    component character varying(255),
    icon character varying(128),
    active_menu_code character varying(128),
    sort_order integer DEFAULT 0 NOT NULL,
    is_visible boolean DEFAULT true NOT NULL,
    is_cache boolean DEFAULT false NOT NULL,
    is_external boolean DEFAULT false NOT NULL,
    status smallint DEFAULT '1'::smallint NOT NULL,
    meta_json json,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


--
-- Name: COLUMN admin_menus.menu_type; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN public.admin_menus.menu_type IS 'directory|menu|page';


--
-- Name: COLUMN admin_menus.status; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN public.admin_menus.status IS '1=enabled,0=disabled';


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

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


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

ALTER SEQUENCE public.admin_menus_id_seq OWNED BY public.admin_menus.id;


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

CREATE TABLE public.admin_role_menu_actions (
    role_id bigint NOT NULL,
    menu_action_id bigint NOT NULL
);


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

CREATE TABLE public.admin_roles (
    id bigint NOT NULL,
    slug character varying(64) NOT NULL,
    name character varying(128) NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    code character varying(64) NOT NULL,
    description text,
    status smallint DEFAULT '1'::smallint NOT NULL,
    is_system boolean DEFAULT false NOT NULL,
    sort_order integer DEFAULT 0 NOT NULL,
    owner_agent_id bigint,
    delegated_from_role_id bigint,
    scope_type character varying(16) DEFAULT 'system'::character varying NOT NULL
);


--
-- Name: COLUMN admin_roles.status; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN public.admin_roles.status IS '1=enabled,0=disabled';


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

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


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

ALTER SEQUENCE public.admin_roles_id_seq OWNED BY public.admin_roles.id;


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

CREATE TABLE public.admin_sites (
    id bigint NOT NULL,
    code character varying(64) NOT NULL,
    name character varying(128) NOT NULL,
    currency_code character varying(16) DEFAULT 'NPR'::character varying NOT NULL,
    status smallint DEFAULT '1'::smallint NOT NULL,
    is_default boolean DEFAULT false NOT NULL,
    extra_json json,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    wallet_api_url character varying(512),
    wallet_debit_path character varying(128) DEFAULT '/wallet/debit-for-lottery'::character varying NOT NULL,
    wallet_credit_path character varying(128) DEFAULT '/wallet/credit-from-lottery'::character varying NOT NULL,
    wallet_balance_path character varying(128) DEFAULT '/wallet/balance'::character varying NOT NULL,
    wallet_api_key_encrypted text,
    sso_jwt_secret_encrypted text,
    wallet_timeout_seconds smallint DEFAULT '10'::smallint NOT NULL,
    iframe_allowed_origins json,
    lottery_h5_base_url character varying(512),
    notes text
);


--
-- Name: COLUMN admin_sites.status; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN public.admin_sites.status IS '1=enabled,0=disabled';


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

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


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

ALTER SEQUENCE public.admin_sites_id_seq OWNED BY public.admin_sites.id;


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

CREATE TABLE public.admin_user_agent_roles (
    admin_user_id bigint NOT NULL,
    agent_node_id bigint NOT NULL,
    role_id bigint NOT NULL,
    granted_at timestamp(0) without time zone
);


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

CREATE TABLE public.admin_user_agents (
    admin_user_id bigint NOT NULL,
    agent_node_id bigint NOT NULL,
    is_primary boolean DEFAULT true NOT NULL,
    granted_at timestamp(0) without time zone
);


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

CREATE TABLE public.admin_user_menu_actions (
    admin_user_id bigint NOT NULL,
    site_id bigint NOT NULL,
    menu_action_id bigint NOT NULL,
    granted_at timestamp(0) without time zone
);


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

CREATE TABLE public.admin_user_site_roles (
    admin_user_id bigint NOT NULL,
    site_id bigint NOT NULL,
    role_id bigint NOT NULL,
    granted_at timestamp(0) without time zone
);


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

CREATE TABLE public.admin_users (
    id bigint NOT NULL,
    name character varying(128) NOT NULL,
    email character varying(255),
    email_verified_at timestamp(0) without time zone,
    password character varying(255) NOT NULL,
    status smallint DEFAULT '0'::smallint NOT NULL,
    last_login_at timestamp(0) without time zone,
    remember_token character varying(100),
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    username character varying(64) NOT NULL
);


--
-- Name: COLUMN admin_users.status; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN public.admin_users.status IS '0=active,1=disabled';


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

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


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

ALTER SEQUENCE public.admin_users_id_seq OWNED BY public.admin_users.id;


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

CREATE TABLE public.agent_delegation_grants (
    id bigint NOT NULL,
    parent_agent_id bigint NOT NULL,
    child_agent_id bigint NOT NULL,
    menu_action_id bigint NOT NULL,
    can_delegate boolean DEFAULT false NOT NULL,
    granted_by bigint,
    granted_at timestamp(0) without time zone,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


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

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


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

ALTER SEQUENCE public.agent_delegation_grants_id_seq OWNED BY public.agent_delegation_grants.id;


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

CREATE TABLE public.agent_nodes (
    id bigint NOT NULL,
    admin_site_id bigint NOT NULL,
    parent_id bigint,
    path character varying(512) NOT NULL,
    depth smallint DEFAULT '0'::smallint NOT NULL,
    code character varying(64) NOT NULL,
    name character varying(128) NOT NULL,
    status smallint DEFAULT '1'::smallint NOT NULL,
    created_by bigint,
    extra_json json,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    risk_tags json
);


--
-- Name: COLUMN agent_nodes.status; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN public.agent_nodes.status IS '1=enabled,0=disabled';


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

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


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

ALTER SEQUENCE public.agent_nodes_id_seq OWNED BY public.agent_nodes.id;


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

CREATE TABLE public.agent_profiles (
    agent_node_id bigint NOT NULL,
    total_share_rate numeric(5,2) DEFAULT '0'::numeric NOT NULL,
    credit_limit bigint DEFAULT '0'::bigint NOT NULL,
    allocated_credit bigint DEFAULT '0'::bigint NOT NULL,
    used_credit bigint DEFAULT '0'::bigint NOT NULL,
    rebate_limit numeric(8,4) DEFAULT '0'::numeric NOT NULL,
    default_player_rebate numeric(8,4) DEFAULT '0'::numeric NOT NULL,
    settlement_cycle character varying(16) DEFAULT 'weekly'::character varying NOT NULL,
    can_grant_extra_rebate boolean DEFAULT false NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    can_create_child_agent boolean DEFAULT false NOT NULL,
    can_create_player boolean DEFAULT true NOT NULL
);


--
-- Name: COLUMN agent_profiles.total_share_rate; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN public.agent_profiles.total_share_rate IS '总占成 0-100';


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

CREATE TABLE public.audit_logs (
    id bigint NOT NULL,
    operator_type character varying(16) NOT NULL,
    operator_id bigint DEFAULT '0'::bigint NOT NULL,
    module_code character varying(32),
    action_code character varying(32),
    target_type character varying(128),
    target_id character varying(64),
    before_json json,
    after_json json,
    ip character varying(64),
    user_agent character varying(255),
    created_at timestamp(0) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL
);


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

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


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

ALTER SEQUENCE public.audit_logs_id_seq OWNED BY public.audit_logs.id;


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

CREATE TABLE public.cache (
    key character varying(255) NOT NULL,
    value text NOT NULL,
    expiration bigint NOT NULL
);


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

CREATE TABLE public.cache_locks (
    key character varying(255) NOT NULL,
    owner character varying(255) NOT NULL,
    expiration bigint NOT NULL
);


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

CREATE TABLE public.credit_ledger (
    id bigint NOT NULL,
    owner_type character varying(16) NOT NULL,
    owner_id bigint NOT NULL,
    amount bigint NOT NULL,
    reason character varying(64) NOT NULL,
    ref_type character varying(32),
    ref_id bigint,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


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

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


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

ALTER SEQUENCE public.credit_ledger_id_seq OWNED BY public.credit_ledger.id;


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

CREATE TABLE public.currencies (
    id bigint NOT NULL,
    code character varying(16) NOT NULL,
    name character varying(64) NOT NULL,
    decimal_places smallint DEFAULT '2'::smallint NOT NULL,
    is_enabled boolean DEFAULT true NOT NULL,
    is_bettable boolean DEFAULT false NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


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

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


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

ALTER SEQUENCE public.currencies_id_seq OWNED BY public.currencies.id;


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

CREATE TABLE public.draw_result_batches (
    id bigint NOT NULL,
    draw_id bigint NOT NULL,
    result_version integer NOT NULL,
    source_type character varying(16) NOT NULL,
    rng_seed_hash character varying(128),
    raw_seed_encrypted text,
    status character varying(32) NOT NULL,
    created_by bigint,
    confirmed_by bigint,
    confirmed_at timestamp(0) without time zone,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


--
-- Name: COLUMN draw_result_batches.source_type; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN public.draw_result_batches.source_type IS 'rng|manual';


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

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


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

ALTER SEQUENCE public.draw_result_batches_id_seq OWNED BY public.draw_result_batches.id;


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

CREATE TABLE public.draw_result_items (
    id bigint NOT NULL,
    draw_id bigint NOT NULL,
    result_batch_id bigint NOT NULL,
    prize_type character varying(32) NOT NULL,
    prize_index integer DEFAULT 0 NOT NULL,
    number_4d character(4) NOT NULL,
    suffix_3d character(3),
    suffix_2d character(2),
    head_digit smallint,
    tail_digit smallint,
    created_at timestamp(0) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL
);


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

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


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

ALTER SEQUENCE public.draw_result_items_id_seq OWNED BY public.draw_result_items.id;


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

CREATE TABLE public.draws (
    id bigint NOT NULL,
    draw_no character varying(32) NOT NULL,
    business_date date NOT NULL,
    sequence_no integer NOT NULL,
    status character varying(32) NOT NULL,
    start_time timestamp(0) without time zone,
    close_time timestamp(0) without time zone,
    draw_time timestamp(0) without time zone,
    cooling_end_time timestamp(0) without time zone,
    result_source character varying(16),
    current_result_version integer DEFAULT 0 NOT NULL,
    settle_version integer DEFAULT 0 NOT NULL,
    is_reopened boolean DEFAULT false NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


--
-- Name: COLUMN draws.result_source; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN public.draws.result_source IS 'rng|manual';


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

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


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

ALTER SEQUENCE public.draws_id_seq OWNED BY public.draws.id;


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

CREATE TABLE public.failed_jobs (
    id bigint NOT NULL,
    uuid character varying(255) NOT NULL,
    connection text NOT NULL,
    queue text NOT NULL,
    payload text NOT NULL,
    exception text NOT NULL,
    failed_at timestamp(0) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL
);


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

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


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

ALTER SEQUENCE public.failed_jobs_id_seq OWNED BY public.failed_jobs.id;


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

CREATE TABLE public.jackpot_contributions (
    id bigint NOT NULL,
    jackpot_pool_id bigint NOT NULL,
    draw_id bigint NOT NULL,
    player_id bigint NOT NULL,
    ticket_item_id bigint,
    contribution_amount bigint DEFAULT '0'::bigint NOT NULL,
    currency_code character varying(16) NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


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

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


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

ALTER SEQUENCE public.jackpot_contributions_id_seq OWNED BY public.jackpot_contributions.id;


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

CREATE TABLE public.jackpot_payout_logs (
    id bigint NOT NULL,
    draw_id bigint NOT NULL,
    jackpot_pool_id bigint NOT NULL,
    trigger_type character varying(32) NOT NULL,
    total_payout_amount bigint DEFAULT '0'::bigint NOT NULL,
    winner_count integer DEFAULT 0 NOT NULL,
    trigger_snapshot_json json,
    created_at timestamp(0) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL
);


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

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


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

ALTER SEQUENCE public.jackpot_payout_logs_id_seq OWNED BY public.jackpot_payout_logs.id;


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

CREATE TABLE public.jackpot_pool_adjustments (
    id bigint NOT NULL,
    adjustment_no character varying(32) NOT NULL,
    jackpot_pool_id bigint NOT NULL,
    admin_user_id bigint NOT NULL,
    amount_delta bigint NOT NULL,
    balance_before bigint NOT NULL,
    balance_after bigint NOT NULL,
    reason character varying(500) NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


--
-- Name: COLUMN jackpot_pool_adjustments.amount_delta; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN public.jackpot_pool_adjustments.amount_delta IS 'signed minor units; + increase pool';


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

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


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

ALTER SEQUENCE public.jackpot_pool_adjustments_id_seq OWNED BY public.jackpot_pool_adjustments.id;


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

CREATE TABLE public.jackpot_pools (
    id bigint NOT NULL,
    currency_code character varying(16) NOT NULL,
    current_amount bigint DEFAULT '0'::bigint NOT NULL,
    contribution_rate numeric(8,4) DEFAULT '0'::numeric NOT NULL,
    trigger_threshold bigint DEFAULT '0'::bigint NOT NULL,
    payout_rate numeric(8,4) DEFAULT '0'::numeric NOT NULL,
    force_trigger_draw_gap integer DEFAULT 0 NOT NULL,
    min_bet_amount bigint DEFAULT '0'::bigint NOT NULL,
    status smallint DEFAULT '0'::smallint NOT NULL,
    last_trigger_draw_id bigint,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    combo_trigger_play_codes json
);


--
-- Name: COLUMN jackpot_pools.status; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN public.jackpot_pools.status IS '0=off,1=on';


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

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


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

ALTER SEQUENCE public.jackpot_pools_id_seq OWNED BY public.jackpot_pools.id;


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

CREATE TABLE public.job_batches (
    id character varying(255) NOT NULL,
    name character varying(255) NOT NULL,
    total_jobs integer NOT NULL,
    pending_jobs integer NOT NULL,
    failed_jobs integer NOT NULL,
    failed_job_ids text NOT NULL,
    options text,
    cancelled_at integer,
    created_at integer NOT NULL,
    finished_at integer
);


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

CREATE TABLE public.jobs (
    id bigint NOT NULL,
    queue character varying(255) NOT NULL,
    payload text NOT NULL,
    attempts smallint NOT NULL,
    reserved_at integer,
    available_at integer NOT NULL,
    created_at integer NOT NULL
);


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

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


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

ALTER SEQUENCE public.jobs_id_seq OWNED BY public.jobs.id;


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

CREATE TABLE public.lottery_settings (
    id bigint NOT NULL,
    setting_key character varying(160) NOT NULL,
    value_json json NOT NULL,
    group_name character varying(64) DEFAULT 'general'::character varying NOT NULL,
    description_zh character varying(255),
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


--
-- Name: COLUMN lottery_settings.group_name; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN public.lottery_settings.group_name IS '控制台分组展示用';


--
-- Name: COLUMN lottery_settings.description_zh; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN public.lottery_settings.description_zh IS '运维说明';


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

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


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

ALTER SEQUENCE public.lottery_settings_id_seq OWNED BY public.lottery_settings.id;


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

CREATE TABLE public.migrations (
    id integer NOT NULL,
    migration character varying(255) NOT NULL,
    batch integer NOT NULL
);


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

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


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

ALTER SEQUENCE public.migrations_id_seq OWNED BY public.migrations.id;


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

CREATE TABLE public.odds_items (
    id bigint NOT NULL,
    version_id bigint NOT NULL,
    play_code character varying(32) NOT NULL,
    prize_scope character varying(32) NOT NULL,
    odds_value bigint DEFAULT '0'::bigint NOT NULL,
    rebate_rate numeric(8,4) DEFAULT '0'::numeric NOT NULL,
    commission_rate numeric(8,4) DEFAULT '0'::numeric NOT NULL,
    currency_code character varying(16) NOT NULL,
    extra_config_json json,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    dimension smallint
);


--
-- Name: COLUMN odds_items.dimension; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN public.odds_items.dimension IS '2/3/4 维度，佣金按维度配置';


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

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


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

ALTER SEQUENCE public.odds_items_id_seq OWNED BY public.odds_items.id;


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

CREATE TABLE public.odds_versions (
    id bigint NOT NULL,
    version_no integer NOT NULL,
    status character varying(16) NOT NULL,
    effective_at timestamp(0) without time zone,
    updated_by bigint,
    reason character varying(255),
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


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

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


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

ALTER SEQUENCE public.odds_versions_id_seq OWNED BY public.odds_versions.id;


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

CREATE TABLE public.payment_records (
    id bigint NOT NULL,
    settlement_bill_id bigint NOT NULL,
    payer_type character varying(16) NOT NULL,
    payer_id bigint NOT NULL,
    payee_type character varying(16) NOT NULL,
    payee_id bigint NOT NULL,
    amount bigint NOT NULL,
    method character varying(32),
    status character varying(16) DEFAULT 'pending'::character varying NOT NULL,
    created_by bigint,
    confirmed_by bigint,
    confirmed_at timestamp(0) without time zone,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    proof text,
    remark character varying(255)
);


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

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


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

ALTER SEQUENCE public.payment_records_id_seq OWNED BY public.payment_records.id;


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

CREATE TABLE public.personal_access_tokens (
    id bigint NOT NULL,
    tokenable_type character varying(255) NOT NULL,
    tokenable_id bigint NOT NULL,
    name text NOT NULL,
    token character varying(64) NOT NULL,
    abilities text,
    last_used_at timestamp(0) without time zone,
    expires_at timestamp(0) without time zone,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


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

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


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

ALTER SEQUENCE public.personal_access_tokens_id_seq OWNED BY public.personal_access_tokens.id;


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

CREATE TABLE public.play_config_items (
    id bigint NOT NULL,
    version_id bigint NOT NULL,
    play_code character varying(32) NOT NULL,
    is_enabled boolean DEFAULT true NOT NULL,
    min_bet_amount bigint DEFAULT '0'::bigint NOT NULL,
    max_bet_amount bigint DEFAULT '0'::bigint NOT NULL,
    display_order integer DEFAULT 0 NOT NULL,
    rule_text_zh text,
    rule_text_en text,
    rule_text_ne text,
    extra_config_json json,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    category character varying(16),
    dimension smallint,
    bet_mode character varying(32),
    supports_multi_number boolean DEFAULT false NOT NULL,
    reserved_rule_json json,
    display_name character varying(64)
);


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

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


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

ALTER SEQUENCE public.play_config_items_id_seq OWNED BY public.play_config_items.id;


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

CREATE TABLE public.play_config_versions (
    id bigint NOT NULL,
    version_no integer NOT NULL,
    status character varying(16) NOT NULL,
    effective_at timestamp(0) without time zone,
    updated_by bigint,
    reason character varying(255),
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


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

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


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

ALTER SEQUENCE public.play_config_versions_id_seq OWNED BY public.play_config_versions.id;


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

CREATE TABLE public.play_types (
    id bigint NOT NULL,
    play_code character varying(32) NOT NULL,
    category character varying(16) NOT NULL,
    dimension smallint,
    bet_mode character varying(32),
    is_enabled boolean DEFAULT true NOT NULL,
    sort_order integer DEFAULT 0 NOT NULL,
    supports_multi_number boolean DEFAULT false NOT NULL,
    reserved_rule_json json,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    display_name character varying(64)
);


--
-- Name: COLUMN play_types.dimension; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN public.play_types.dimension IS '2/3/4';


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

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


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

ALTER SEQUENCE public.play_types_id_seq OWNED BY public.play_types.id;


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

CREATE TABLE public.player_credit_accounts (
    player_id bigint NOT NULL,
    credit_limit bigint DEFAULT '0'::bigint NOT NULL,
    used_credit bigint DEFAULT '0'::bigint NOT NULL,
    frozen_credit bigint DEFAULT '0'::bigint NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


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

CREATE TABLE public.player_rebate_profiles (
    id bigint NOT NULL,
    player_id bigint NOT NULL,
    game_type character varying(32) DEFAULT '*'::character varying NOT NULL,
    inherit_from_agent boolean DEFAULT true NOT NULL,
    rebate_rate numeric(8,4) DEFAULT '0'::numeric NOT NULL,
    extra_rebate_rate numeric(8,4) DEFAULT '0'::numeric NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


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

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


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

ALTER SEQUENCE public.player_rebate_profiles_id_seq OWNED BY public.player_rebate_profiles.id;


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

CREATE TABLE public.player_wallets (
    id bigint NOT NULL,
    player_id bigint NOT NULL,
    wallet_type character varying(32) DEFAULT 'lottery'::character varying NOT NULL,
    currency_code character varying(16) NOT NULL,
    balance bigint DEFAULT '0'::bigint NOT NULL,
    frozen_balance bigint DEFAULT '0'::bigint NOT NULL,
    status smallint DEFAULT '0'::smallint NOT NULL,
    version bigint DEFAULT '0'::bigint NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


--
-- Name: COLUMN player_wallets.status; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN public.player_wallets.status IS '0=active,1=frozen';


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

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


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

ALTER SEQUENCE public.player_wallets_id_seq OWNED BY public.player_wallets.id;


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

CREATE TABLE public.players (
    id bigint NOT NULL,
    site_code character varying(64) NOT NULL,
    site_player_id character varying(128) NOT NULL,
    username character varying(128),
    nickname character varying(128),
    default_currency character varying(16) DEFAULT 'NPR'::character varying NOT NULL,
    status smallint DEFAULT '0'::smallint NOT NULL,
    last_login_at timestamp(0) without time zone,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    agent_node_id bigint,
    auth_source character varying(16) DEFAULT 'main_site_sso'::character varying NOT NULL,
    funding_mode character varying(16) DEFAULT 'wallet'::character varying NOT NULL,
    password_hash character varying(255),
    login_failed_count smallint DEFAULT '0'::smallint NOT NULL,
    login_locked_until timestamp(0) without time zone,
    risk_tags json
);


--
-- Name: COLUMN players.status; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN public.players.status IS '0=active,1=frozen,2=blocked';


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

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


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

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


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

CREATE TABLE public.rebate_allocations (
    id bigint NOT NULL,
    rebate_record_id bigint NOT NULL,
    settlement_bill_id bigint,
    participant_type character varying(16) NOT NULL,
    participant_id bigint DEFAULT '0'::bigint NOT NULL,
    actual_share_rate numeric(5,2) DEFAULT '0'::numeric NOT NULL,
    allocated_amount bigint DEFAULT '0'::bigint NOT NULL,
    allocation_rule character varying(32) DEFAULT 'share'::character varying NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


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

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


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

ALTER SEQUENCE public.rebate_allocations_id_seq OWNED BY public.rebate_allocations.id;


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

CREATE TABLE public.rebate_records (
    id bigint NOT NULL,
    player_id bigint NOT NULL,
    settlement_period_id bigint,
    game_type character varying(32) DEFAULT '*'::character varying NOT NULL,
    valid_bet_amount bigint DEFAULT '0'::bigint NOT NULL,
    rebate_rate numeric(8,4) DEFAULT '0'::numeric NOT NULL,
    rebate_amount bigint DEFAULT '0'::bigint NOT NULL,
    rebate_type character varying(16) DEFAULT 'basic'::character varying NOT NULL,
    owner_agent_id bigint,
    status character varying(16) DEFAULT 'pending'::character varying NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    ticket_item_id bigint,
    reversal_of_id bigint
);


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

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


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

ALTER SEQUENCE public.rebate_records_id_seq OWNED BY public.rebate_records.id;


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

CREATE TABLE public.reconcile_items (
    id bigint NOT NULL,
    reconcile_job_id bigint NOT NULL,
    side_a_ref character varying(128),
    side_b_ref character varying(128),
    difference_amount bigint DEFAULT '0'::bigint NOT NULL,
    status character varying(32) NOT NULL,
    resolved_at timestamp(0) without time zone,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


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

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


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

ALTER SEQUENCE public.reconcile_items_id_seq OWNED BY public.reconcile_items.id;


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

CREATE TABLE public.reconcile_jobs (
    id bigint NOT NULL,
    job_no character varying(64) NOT NULL,
    reconcile_type character varying(32) NOT NULL,
    status character varying(32) NOT NULL,
    period_start timestamp(0) without time zone,
    period_end timestamp(0) without time zone,
    summary_json json,
    finished_at timestamp(0) without time zone,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    admin_user_id bigint
);


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

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


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

ALTER SEQUENCE public.reconcile_jobs_id_seq OWNED BY public.reconcile_jobs.id;


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

CREATE TABLE public.report_jobs (
    id bigint NOT NULL,
    job_no character varying(64) NOT NULL,
    admin_user_id bigint,
    report_type character varying(64) NOT NULL,
    export_format character varying(16) DEFAULT 'csv'::character varying NOT NULL,
    filter_json json,
    status character varying(32) NOT NULL,
    output_path character varying(512),
    error_message text,
    finished_at timestamp(0) without time zone,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


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

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


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

ALTER SEQUENCE public.report_jobs_id_seq OWNED BY public.report_jobs.id;


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

CREATE TABLE public.risk_cap_items (
    id bigint NOT NULL,
    version_id bigint NOT NULL,
    draw_id bigint,
    normalized_number character(4) NOT NULL,
    cap_amount bigint NOT NULL,
    cap_type character varying(16) NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


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

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


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

ALTER SEQUENCE public.risk_cap_items_id_seq OWNED BY public.risk_cap_items.id;


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

CREATE TABLE public.risk_cap_versions (
    id bigint NOT NULL,
    version_no integer NOT NULL,
    status character varying(16) NOT NULL,
    effective_at timestamp(0) without time zone,
    updated_by bigint,
    reason character varying(255),
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


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

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


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

ALTER SEQUENCE public.risk_cap_versions_id_seq OWNED BY public.risk_cap_versions.id;


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

CREATE TABLE public.risk_pool_lock_logs (
    id bigint NOT NULL,
    draw_id bigint NOT NULL,
    normalized_number character(4) NOT NULL,
    ticket_item_id bigint,
    action_type character varying(16) NOT NULL,
    amount bigint DEFAULT '0'::bigint NOT NULL,
    source_reason character varying(32),
    created_at timestamp(0) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL
);


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

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


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

ALTER SEQUENCE public.risk_pool_lock_logs_id_seq OWNED BY public.risk_pool_lock_logs.id;


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

CREATE TABLE public.risk_pools (
    id bigint NOT NULL,
    draw_id bigint NOT NULL,
    normalized_number character(4) NOT NULL,
    total_cap_amount bigint DEFAULT '0'::bigint NOT NULL,
    locked_amount bigint DEFAULT '0'::bigint NOT NULL,
    remaining_amount bigint DEFAULT '0'::bigint NOT NULL,
    sold_out_status smallint DEFAULT '0'::smallint NOT NULL,
    version bigint DEFAULT '0'::bigint NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


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

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


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

ALTER SEQUENCE public.risk_pools_id_seq OWNED BY public.risk_pools.id;


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

CREATE TABLE public.sessions (
    id character varying(255) NOT NULL,
    user_id bigint,
    ip_address character varying(45),
    user_agent text,
    payload text NOT NULL,
    last_activity integer NOT NULL
);


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

CREATE TABLE public.settlement_adjustments (
    id bigint NOT NULL,
    settlement_period_id bigint,
    original_bill_id bigint,
    adjustment_type character varying(32) NOT NULL,
    amount bigint NOT NULL,
    reason character varying(255),
    created_by bigint,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


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

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


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

ALTER SEQUENCE public.settlement_adjustments_id_seq OWNED BY public.settlement_adjustments.id;


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

CREATE TABLE public.settlement_batches (
    id bigint NOT NULL,
    draw_id bigint NOT NULL,
    result_batch_id bigint NOT NULL,
    settle_version integer DEFAULT 1 NOT NULL,
    status character varying(32) NOT NULL,
    total_ticket_count integer DEFAULT 0 NOT NULL,
    total_win_count integer DEFAULT 0 NOT NULL,
    total_payout_amount bigint DEFAULT '0'::bigint NOT NULL,
    total_jackpot_payout_amount bigint DEFAULT '0'::bigint NOT NULL,
    review_status character varying(32) DEFAULT 'pending'::character varying NOT NULL,
    reviewed_by bigint,
    reviewed_at timestamp(0) without time zone,
    review_remark character varying(255),
    paid_at timestamp(0) without time zone,
    started_at timestamp(0) without time zone,
    finished_at timestamp(0) without time zone,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


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

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


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

ALTER SEQUENCE public.settlement_batches_id_seq OWNED BY public.settlement_batches.id;


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

CREATE TABLE public.settlement_bills (
    id bigint NOT NULL,
    settlement_period_id bigint NOT NULL,
    bill_type character varying(16) NOT NULL,
    owner_type character varying(16) NOT NULL,
    owner_id bigint NOT NULL,
    counterparty_type character varying(16) NOT NULL,
    counterparty_id bigint NOT NULL,
    gross_win_loss bigint DEFAULT '0'::bigint NOT NULL,
    rebate_amount bigint DEFAULT '0'::bigint NOT NULL,
    adjustment_amount bigint DEFAULT '0'::bigint NOT NULL,
    net_amount bigint DEFAULT '0'::bigint NOT NULL,
    paid_amount bigint DEFAULT '0'::bigint NOT NULL,
    unpaid_amount bigint DEFAULT '0'::bigint NOT NULL,
    status character varying(16) DEFAULT 'pending'::character varying NOT NULL,
    confirmed_at timestamp(0) without time zone,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    locked_at timestamp(0) without time zone,
    reversed_bill_id bigint,
    meta_json json,
    platform_rounding_adjustment bigint DEFAULT '0'::bigint NOT NULL
);


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

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


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

ALTER SEQUENCE public.settlement_bills_id_seq OWNED BY public.settlement_bills.id;


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

CREATE TABLE public.settlement_periods (
    id bigint NOT NULL,
    admin_site_id bigint NOT NULL,
    period_start timestamp(0) without time zone NOT NULL,
    period_end timestamp(0) without time zone NOT NULL,
    status character varying(16) DEFAULT 'open'::character varying NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


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

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


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

ALTER SEQUENCE public.settlement_periods_id_seq OWNED BY public.settlement_periods.id;


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

CREATE TABLE public.share_ledger (
    id bigint NOT NULL,
    ticket_item_id bigint NOT NULL,
    player_id bigint NOT NULL,
    agent_node_id bigint,
    agent_path json,
    share_snapshot json,
    game_win_loss bigint DEFAULT '0'::bigint NOT NULL,
    basic_rebate bigint DEFAULT '0'::bigint NOT NULL,
    shared_net_win_loss bigint DEFAULT '0'::bigint NOT NULL,
    allocations_json json,
    settlement_period_id bigint,
    reversal_of_id bigint,
    settled_at timestamp(0) without time zone NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


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

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


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

ALTER SEQUENCE public.share_ledger_id_seq OWNED BY public.share_ledger.id;


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

CREATE TABLE public.ticket_combinations (
    id bigint NOT NULL,
    ticket_item_id bigint NOT NULL,
    combination_no integer DEFAULT 0 NOT NULL,
    number_4d character(4) NOT NULL,
    bet_amount bigint DEFAULT '0'::bigint NOT NULL,
    estimated_payout bigint DEFAULT '0'::bigint NOT NULL,
    created_at timestamp(0) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL
);


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

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


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

ALTER SEQUENCE public.ticket_combinations_id_seq OWNED BY public.ticket_combinations.id;


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

CREATE TABLE public.ticket_items (
    id bigint NOT NULL,
    ticket_no character varying(64) NOT NULL,
    order_id bigint NOT NULL,
    player_id bigint NOT NULL,
    draw_id bigint NOT NULL,
    original_number character varying(32),
    normalized_number character(4) NOT NULL,
    play_code character varying(32) NOT NULL,
    dimension smallint,
    digit_slot smallint,
    bet_mode character varying(32),
    unit_bet_amount bigint DEFAULT '0'::bigint NOT NULL,
    total_bet_amount bigint DEFAULT '0'::bigint NOT NULL,
    rebate_rate_snapshot numeric(8,4) DEFAULT '0'::numeric NOT NULL,
    commission_rate_snapshot numeric(8,4) DEFAULT '0'::numeric NOT NULL,
    actual_deduct_amount bigint DEFAULT '0'::bigint NOT NULL,
    odds_snapshot_json json,
    rule_snapshot_json json,
    combination_count integer DEFAULT 1 NOT NULL,
    estimated_max_payout bigint DEFAULT '0'::bigint NOT NULL,
    risk_locked_amount bigint DEFAULT '0'::bigint NOT NULL,
    status character varying(32) NOT NULL,
    fail_reason_code character varying(32),
    fail_reason_text character varying(255),
    win_amount bigint DEFAULT '0'::bigint NOT NULL,
    jackpot_win_amount bigint DEFAULT '0'::bigint NOT NULL,
    settled_at timestamp(0) without time zone,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    agent_node_id bigint,
    share_snapshot json,
    agent_rebate_rate_snapshot numeric(8,4),
    agent_settled_at timestamp(0) without time zone,
    agent_settlement_reversal_of_id bigint
);


--
-- Name: COLUMN ticket_items.dimension; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN public.ticket_items.dimension IS '2/3/4';


--
-- Name: COLUMN ticket_items.digit_slot; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN public.ticket_items.digit_slot IS '千百十个位，领域字典';


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

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


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

ALTER SEQUENCE public.ticket_items_id_seq OWNED BY public.ticket_items.id;


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

CREATE TABLE public.ticket_orders (
    id bigint NOT NULL,
    order_no character varying(64) NOT NULL,
    player_id bigint NOT NULL,
    draw_id bigint NOT NULL,
    currency_code character varying(16) NOT NULL,
    total_bet_amount bigint DEFAULT '0'::bigint NOT NULL,
    total_rebate_amount bigint DEFAULT '0'::bigint NOT NULL,
    total_actual_deduct bigint DEFAULT '0'::bigint NOT NULL,
    total_estimated_payout bigint DEFAULT '0'::bigint NOT NULL,
    status character varying(32) NOT NULL,
    submit_source character varying(16) DEFAULT 'h5'::character varying NOT NULL,
    client_trace_id character varying(64),
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    play_config_version_no integer DEFAULT 0 NOT NULL,
    odds_version_no integer DEFAULT 0 NOT NULL,
    risk_cap_version_no integer DEFAULT 0 NOT NULL
);


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

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


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

ALTER SEQUENCE public.ticket_orders_id_seq OWNED BY public.ticket_orders.id;


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

CREATE TABLE public.ticket_settlement_details (
    id bigint NOT NULL,
    settlement_batch_id bigint NOT NULL,
    ticket_item_id bigint NOT NULL,
    matched_prize_tier character varying(32),
    win_amount bigint DEFAULT '0'::bigint NOT NULL,
    jackpot_allocation_amount bigint DEFAULT '0'::bigint NOT NULL,
    match_detail_json json,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


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

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


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

ALTER SEQUENCE public.ticket_settlement_details_id_seq OWNED BY public.ticket_settlement_details.id;


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

CREATE TABLE public.transfer_orders (
    id bigint NOT NULL,
    transfer_no character varying(64) NOT NULL,
    player_id bigint NOT NULL,
    direction character varying(16) NOT NULL,
    currency_code character varying(16) NOT NULL,
    amount bigint NOT NULL,
    idempotent_key character varying(64) NOT NULL,
    status character varying(32) NOT NULL,
    external_request_payload json,
    external_response_payload json,
    external_ref_no character varying(64),
    fail_reason character varying(255),
    finished_at timestamp(0) without time zone,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


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

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


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

ALTER SEQUENCE public.transfer_orders_id_seq OWNED BY public.transfer_orders.id;


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

CREATE TABLE public.wallet_txns (
    id bigint NOT NULL,
    txn_no character varying(64) NOT NULL,
    player_id bigint NOT NULL,
    wallet_id bigint NOT NULL,
    biz_type character varying(32) NOT NULL,
    biz_no character varying(64),
    direction smallint NOT NULL,
    amount bigint NOT NULL,
    balance_before bigint NOT NULL,
    balance_after bigint NOT NULL,
    status character varying(32) NOT NULL,
    external_ref_no character varying(64),
    idempotent_key character varying(64),
    remark character varying(255),
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


--
-- Name: COLUMN wallet_txns.direction; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN public.wallet_txns.direction IS '1=in,2=out';


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

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


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

ALTER SEQUENCE public.wallet_txns_id_seq OWNED BY public.wallet_txns.id;


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


--
-- Name: admin_action_catalog admin_action_catalog_code_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.admin_action_catalog
    ADD CONSTRAINT admin_action_catalog_code_unique UNIQUE (code);


--
-- Name: admin_action_catalog admin_action_catalog_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.admin_action_catalog
    ADD CONSTRAINT admin_action_catalog_pkey PRIMARY KEY (id);


--
-- Name: admin_api_resource_bindings admin_api_resource_bindings_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.admin_api_resource_bindings
    ADD CONSTRAINT admin_api_resource_bindings_pkey PRIMARY KEY (id);


--
-- Name: admin_api_resources admin_api_resources_code_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.admin_api_resources
    ADD CONSTRAINT admin_api_resources_code_unique UNIQUE (code);


--
-- Name: admin_api_resources admin_api_resources_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.admin_api_resources
    ADD CONSTRAINT admin_api_resources_pkey PRIMARY KEY (id);


--
-- Name: admin_menu_actions admin_menu_actions_permission_code_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.admin_menu_actions
    ADD CONSTRAINT admin_menu_actions_permission_code_unique UNIQUE (permission_code);


--
-- Name: admin_menu_actions admin_menu_actions_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.admin_menu_actions
    ADD CONSTRAINT admin_menu_actions_pkey PRIMARY KEY (id);


--
-- Name: admin_menus admin_menus_code_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.admin_menus
    ADD CONSTRAINT admin_menus_code_unique UNIQUE (code);


--
-- Name: admin_menus admin_menus_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.admin_menus
    ADD CONSTRAINT admin_menus_pkey PRIMARY KEY (id);


--
-- Name: admin_role_menu_actions admin_role_menu_actions_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.admin_role_menu_actions
    ADD CONSTRAINT admin_role_menu_actions_pkey PRIMARY KEY (role_id, menu_action_id);


--
-- Name: admin_roles admin_roles_code_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.admin_roles
    ADD CONSTRAINT admin_roles_code_unique UNIQUE (code);


--
-- Name: admin_roles admin_roles_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.admin_roles
    ADD CONSTRAINT admin_roles_pkey PRIMARY KEY (id);


--
-- Name: admin_roles admin_roles_slug_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.admin_roles
    ADD CONSTRAINT admin_roles_slug_unique UNIQUE (slug);


--
-- Name: admin_sites admin_sites_code_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.admin_sites
    ADD CONSTRAINT admin_sites_code_unique UNIQUE (code);


--
-- Name: admin_sites admin_sites_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.admin_sites
    ADD CONSTRAINT admin_sites_pkey PRIMARY KEY (id);


--
-- Name: admin_user_agent_roles admin_user_agent_roles_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.admin_user_agent_roles
    ADD CONSTRAINT admin_user_agent_roles_pkey PRIMARY KEY (admin_user_id, agent_node_id, role_id);


--
-- Name: admin_user_agents admin_user_agents_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.admin_user_agents
    ADD CONSTRAINT admin_user_agents_pkey PRIMARY KEY (admin_user_id);


--
-- Name: admin_user_menu_actions admin_user_menu_actions_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.admin_user_menu_actions
    ADD CONSTRAINT admin_user_menu_actions_pkey PRIMARY KEY (admin_user_id, site_id, menu_action_id);


--
-- Name: admin_user_site_roles admin_user_site_roles_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.admin_user_site_roles
    ADD CONSTRAINT admin_user_site_roles_pkey PRIMARY KEY (admin_user_id, site_id, role_id);


--
-- Name: admin_users admin_users_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.admin_users
    ADD CONSTRAINT admin_users_pkey PRIMARY KEY (id);


--
-- Name: admin_users admin_users_username_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.admin_users
    ADD CONSTRAINT admin_users_username_unique UNIQUE (username);


--
-- Name: agent_delegation_grants agent_delegation_grants_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.agent_delegation_grants
    ADD CONSTRAINT agent_delegation_grants_pkey PRIMARY KEY (id);


--
-- Name: agent_nodes agent_nodes_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.agent_nodes
    ADD CONSTRAINT agent_nodes_pkey PRIMARY KEY (id);


--
-- Name: agent_profiles agent_profiles_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.agent_profiles
    ADD CONSTRAINT agent_profiles_pkey PRIMARY KEY (agent_node_id);


--
-- Name: audit_logs audit_logs_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.audit_logs
    ADD CONSTRAINT audit_logs_pkey PRIMARY KEY (id);


--
-- Name: cache_locks cache_locks_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cache_locks
    ADD CONSTRAINT cache_locks_pkey PRIMARY KEY (key);


--
-- Name: cache cache_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cache
    ADD CONSTRAINT cache_pkey PRIMARY KEY (key);


--
-- Name: credit_ledger credit_ledger_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.credit_ledger
    ADD CONSTRAINT credit_ledger_pkey PRIMARY KEY (id);


--
-- Name: currencies currencies_code_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.currencies
    ADD CONSTRAINT currencies_code_unique UNIQUE (code);


--
-- Name: currencies currencies_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.currencies
    ADD CONSTRAINT currencies_pkey PRIMARY KEY (id);


--
-- Name: draw_result_batches draw_result_batches_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.draw_result_batches
    ADD CONSTRAINT draw_result_batches_pkey PRIMARY KEY (id);


--
-- Name: draw_result_items draw_result_items_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.draw_result_items
    ADD CONSTRAINT draw_result_items_pkey PRIMARY KEY (id);


--
-- Name: draws draws_draw_no_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.draws
    ADD CONSTRAINT draws_draw_no_unique UNIQUE (draw_no);


--
-- Name: draws draws_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.draws
    ADD CONSTRAINT draws_pkey PRIMARY KEY (id);


--
-- Name: failed_jobs failed_jobs_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.failed_jobs
    ADD CONSTRAINT failed_jobs_pkey PRIMARY KEY (id);


--
-- Name: failed_jobs failed_jobs_uuid_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.failed_jobs
    ADD CONSTRAINT failed_jobs_uuid_unique UNIQUE (uuid);


--
-- Name: jackpot_contributions jackpot_contributions_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jackpot_contributions
    ADD CONSTRAINT jackpot_contributions_pkey PRIMARY KEY (id);


--
-- Name: jackpot_payout_logs jackpot_payout_logs_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jackpot_payout_logs
    ADD CONSTRAINT jackpot_payout_logs_pkey PRIMARY KEY (id);


--
-- Name: jackpot_pool_adjustments jackpot_pool_adjustments_adjustment_no_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jackpot_pool_adjustments
    ADD CONSTRAINT jackpot_pool_adjustments_adjustment_no_unique UNIQUE (adjustment_no);


--
-- Name: jackpot_pool_adjustments jackpot_pool_adjustments_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jackpot_pool_adjustments
    ADD CONSTRAINT jackpot_pool_adjustments_pkey PRIMARY KEY (id);


--
-- Name: jackpot_pools jackpot_pools_currency_code_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jackpot_pools
    ADD CONSTRAINT jackpot_pools_currency_code_unique UNIQUE (currency_code);


--
-- Name: jackpot_pools jackpot_pools_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jackpot_pools
    ADD CONSTRAINT jackpot_pools_pkey PRIMARY KEY (id);


--
-- Name: job_batches job_batches_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.job_batches
    ADD CONSTRAINT job_batches_pkey PRIMARY KEY (id);


--
-- Name: jobs jobs_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jobs
    ADD CONSTRAINT jobs_pkey PRIMARY KEY (id);


--
-- Name: lottery_settings lottery_settings_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.lottery_settings
    ADD CONSTRAINT lottery_settings_pkey PRIMARY KEY (id);


--
-- Name: lottery_settings lottery_settings_setting_key_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.lottery_settings
    ADD CONSTRAINT lottery_settings_setting_key_unique UNIQUE (setting_key);


--
-- Name: migrations migrations_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.migrations
    ADD CONSTRAINT migrations_pkey PRIMARY KEY (id);


--
-- Name: odds_items odds_items_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.odds_items
    ADD CONSTRAINT odds_items_pkey PRIMARY KEY (id);


--
-- Name: odds_versions odds_versions_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.odds_versions
    ADD CONSTRAINT odds_versions_pkey PRIMARY KEY (id);


--
-- Name: payment_records payment_records_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.payment_records
    ADD CONSTRAINT payment_records_pkey PRIMARY KEY (id);


--
-- Name: personal_access_tokens personal_access_tokens_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.personal_access_tokens
    ADD CONSTRAINT personal_access_tokens_pkey PRIMARY KEY (id);


--
-- Name: personal_access_tokens personal_access_tokens_token_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.personal_access_tokens
    ADD CONSTRAINT personal_access_tokens_token_unique UNIQUE (token);


--
-- Name: play_config_items play_config_items_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.play_config_items
    ADD CONSTRAINT play_config_items_pkey PRIMARY KEY (id);


--
-- Name: play_config_versions play_config_versions_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.play_config_versions
    ADD CONSTRAINT play_config_versions_pkey PRIMARY KEY (id);


--
-- Name: play_types play_types_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.play_types
    ADD CONSTRAINT play_types_pkey PRIMARY KEY (id);


--
-- Name: play_types play_types_play_code_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.play_types
    ADD CONSTRAINT play_types_play_code_unique UNIQUE (play_code);


--
-- Name: player_credit_accounts player_credit_accounts_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.player_credit_accounts
    ADD CONSTRAINT player_credit_accounts_pkey PRIMARY KEY (player_id);


--
-- Name: player_rebate_profiles player_rebate_profiles_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.player_rebate_profiles
    ADD CONSTRAINT player_rebate_profiles_pkey PRIMARY KEY (id);


--
-- Name: player_rebate_profiles player_rebate_profiles_player_id_game_type_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.player_rebate_profiles
    ADD CONSTRAINT player_rebate_profiles_player_id_game_type_unique UNIQUE (player_id, game_type);


--
-- Name: player_wallets player_wallets_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.player_wallets
    ADD CONSTRAINT player_wallets_pkey PRIMARY KEY (id);


--
-- Name: players players_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

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


--
-- Name: rebate_allocations rebate_allocations_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.rebate_allocations
    ADD CONSTRAINT rebate_allocations_pkey PRIMARY KEY (id);


--
-- Name: rebate_records rebate_records_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.rebate_records
    ADD CONSTRAINT rebate_records_pkey PRIMARY KEY (id);


--
-- Name: reconcile_items reconcile_items_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.reconcile_items
    ADD CONSTRAINT reconcile_items_pkey PRIMARY KEY (id);


--
-- Name: reconcile_jobs reconcile_jobs_job_no_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.reconcile_jobs
    ADD CONSTRAINT reconcile_jobs_job_no_unique UNIQUE (job_no);


--
-- Name: reconcile_jobs reconcile_jobs_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.reconcile_jobs
    ADD CONSTRAINT reconcile_jobs_pkey PRIMARY KEY (id);


--
-- Name: report_jobs report_jobs_job_no_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.report_jobs
    ADD CONSTRAINT report_jobs_job_no_unique UNIQUE (job_no);


--
-- Name: report_jobs report_jobs_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.report_jobs
    ADD CONSTRAINT report_jobs_pkey PRIMARY KEY (id);


--
-- Name: risk_cap_items risk_cap_items_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.risk_cap_items
    ADD CONSTRAINT risk_cap_items_pkey PRIMARY KEY (id);


--
-- Name: risk_cap_versions risk_cap_versions_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.risk_cap_versions
    ADD CONSTRAINT risk_cap_versions_pkey PRIMARY KEY (id);


--
-- Name: risk_pool_lock_logs risk_pool_lock_logs_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.risk_pool_lock_logs
    ADD CONSTRAINT risk_pool_lock_logs_pkey PRIMARY KEY (id);


--
-- Name: risk_pools risk_pools_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.risk_pools
    ADD CONSTRAINT risk_pools_pkey PRIMARY KEY (id);


--
-- Name: sessions sessions_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.sessions
    ADD CONSTRAINT sessions_pkey PRIMARY KEY (id);


--
-- Name: settlement_adjustments settlement_adjustments_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.settlement_adjustments
    ADD CONSTRAINT settlement_adjustments_pkey PRIMARY KEY (id);


--
-- Name: settlement_batches settlement_batches_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.settlement_batches
    ADD CONSTRAINT settlement_batches_pkey PRIMARY KEY (id);


--
-- Name: settlement_bills settlement_bills_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.settlement_bills
    ADD CONSTRAINT settlement_bills_pkey PRIMARY KEY (id);


--
-- Name: settlement_periods settlement_periods_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.settlement_periods
    ADD CONSTRAINT settlement_periods_pkey PRIMARY KEY (id);


--
-- Name: share_ledger share_ledger_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.share_ledger
    ADD CONSTRAINT share_ledger_pkey PRIMARY KEY (id);


--
-- Name: ticket_combinations ticket_combinations_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ticket_combinations
    ADD CONSTRAINT ticket_combinations_pkey PRIMARY KEY (id);


--
-- Name: ticket_items ticket_items_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ticket_items
    ADD CONSTRAINT ticket_items_pkey PRIMARY KEY (id);


--
-- Name: ticket_items ticket_items_ticket_no_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ticket_items
    ADD CONSTRAINT ticket_items_ticket_no_unique UNIQUE (ticket_no);


--
-- Name: ticket_orders ticket_orders_order_no_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ticket_orders
    ADD CONSTRAINT ticket_orders_order_no_unique UNIQUE (order_no);


--
-- Name: ticket_orders ticket_orders_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ticket_orders
    ADD CONSTRAINT ticket_orders_pkey PRIMARY KEY (id);


--
-- Name: ticket_settlement_details ticket_settlement_details_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ticket_settlement_details
    ADD CONSTRAINT ticket_settlement_details_pkey PRIMARY KEY (id);


--
-- Name: transfer_orders transfer_orders_idempotent_key_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.transfer_orders
    ADD CONSTRAINT transfer_orders_idempotent_key_unique UNIQUE (idempotent_key);


--
-- Name: transfer_orders transfer_orders_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.transfer_orders
    ADD CONSTRAINT transfer_orders_pkey PRIMARY KEY (id);


--
-- Name: transfer_orders transfer_orders_transfer_no_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.transfer_orders
    ADD CONSTRAINT transfer_orders_transfer_no_unique UNIQUE (transfer_no);


--
-- Name: admin_api_resource_bindings uk_admin_api_bindings_api_action; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.admin_api_resource_bindings
    ADD CONSTRAINT uk_admin_api_bindings_api_action UNIQUE (api_resource_id, menu_action_id);


--
-- Name: admin_menu_actions uk_admin_menu_actions_menu_action; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.admin_menu_actions
    ADD CONSTRAINT uk_admin_menu_actions_menu_action UNIQUE (menu_id, action_id);


--
-- Name: agent_delegation_grants uk_agent_delegation_child_action; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.agent_delegation_grants
    ADD CONSTRAINT uk_agent_delegation_child_action UNIQUE (child_agent_id, menu_action_id);


--
-- Name: agent_nodes uk_agent_nodes_site_code; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.agent_nodes
    ADD CONSTRAINT uk_agent_nodes_site_code UNIQUE (admin_site_id, code);


--
-- Name: draw_result_batches uk_draw_result_batches_draw_version; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.draw_result_batches
    ADD CONSTRAINT uk_draw_result_batches_draw_version UNIQUE (draw_id, result_version);


--
-- Name: jackpot_contributions uk_jackpot_contributions_ticket_item; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jackpot_contributions
    ADD CONSTRAINT uk_jackpot_contributions_ticket_item UNIQUE (ticket_item_id);


--
-- Name: odds_items uk_odds_items_version_play_prize_currency_dimension; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.odds_items
    ADD CONSTRAINT uk_odds_items_version_play_prize_currency_dimension UNIQUE (version_id, play_code, prize_scope, currency_code, dimension);


--
-- Name: play_config_items uk_play_config_items_version_play; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.play_config_items
    ADD CONSTRAINT uk_play_config_items_version_play UNIQUE (version_id, play_code);


--
-- Name: player_wallets uk_player_wallets_player_type_currency; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.player_wallets
    ADD CONSTRAINT uk_player_wallets_player_type_currency UNIQUE (player_id, wallet_type, currency_code);


--
-- Name: players uk_players_site_player; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.players
    ADD CONSTRAINT uk_players_site_player UNIQUE (site_code, site_player_id);


--
-- Name: risk_pools uk_risk_pools_draw_number; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.risk_pools
    ADD CONSTRAINT uk_risk_pools_draw_number UNIQUE (draw_id, normalized_number);


--
-- Name: ticket_settlement_details uk_ticket_settlement_batch_ticket; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ticket_settlement_details
    ADD CONSTRAINT uk_ticket_settlement_batch_ticket UNIQUE (settlement_batch_id, ticket_item_id);


--
-- Name: wallet_txns uk_wallet_txns_idempotent_biz; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.wallet_txns
    ADD CONSTRAINT uk_wallet_txns_idempotent_biz UNIQUE (idempotent_key, biz_type);


--
-- Name: ticket_orders uniq_ticket_orders_player_draw_trace; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ticket_orders
    ADD CONSTRAINT uniq_ticket_orders_player_draw_trace UNIQUE (player_id, draw_id, client_trace_id);


--
-- Name: wallet_txns wallet_txns_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.wallet_txns
    ADD CONSTRAINT wallet_txns_pkey PRIMARY KEY (id);


--
-- Name: wallet_txns wallet_txns_txn_no_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.wallet_txns
    ADD CONSTRAINT wallet_txns_txn_no_unique UNIQUE (txn_no);


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

CREATE INDEX cache_expiration_index ON public.cache USING btree (expiration);


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

CREATE INDEX cache_locks_expiration_index ON public.cache_locks USING btree (expiration);


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

CREATE INDEX credit_ledger_owner_type_owner_id_created_at_index ON public.credit_ledger USING btree (owner_type, owner_id, created_at);


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

CREATE INDEX idx_admin_api_resources_module_status ON public.admin_api_resources USING btree (module_code, status);


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

CREATE INDEX idx_admin_menu_actions_menu_status ON public.admin_menu_actions USING btree (menu_id, status);


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

CREATE INDEX idx_admin_menus_parent_sort ON public.admin_menus USING btree (parent_id, sort_order);


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

CREATE INDEX idx_agent_delegation_parent_child ON public.agent_delegation_grants USING btree (parent_agent_id, child_agent_id);


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

CREATE INDEX idx_agent_nodes_path ON public.agent_nodes USING btree (path);


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

CREATE INDEX idx_agent_nodes_site_parent ON public.agent_nodes USING btree (admin_site_id, parent_id);


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

CREATE INDEX idx_audit_logs_module_action ON public.audit_logs USING btree (module_code, action_code);


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

CREATE INDEX idx_audit_logs_operator_time ON public.audit_logs USING btree (operator_type, operator_id, created_at);


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

CREATE INDEX idx_draw_result_items_batch_prize ON public.draw_result_items USING btree (result_batch_id, prize_type, prize_index);


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

CREATE INDEX idx_draw_result_items_draw_number ON public.draw_result_items USING btree (draw_id, number_4d);


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

CREATE INDEX idx_draw_result_items_draw_prize ON public.draw_result_items USING btree (draw_id, prize_type, prize_index);


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

CREATE INDEX idx_draws_business_date_draw_time ON public.draws USING btree (business_date, draw_time);


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

CREATE INDEX idx_draws_status_draw_time ON public.draws USING btree (status, draw_time);


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

CREATE INDEX idx_jackpot_contrib_draw_player ON public.jackpot_contributions USING btree (draw_id, player_id);


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

CREATE INDEX idx_jackpot_pool_adjustments_pool_created ON public.jackpot_pool_adjustments USING btree (jackpot_pool_id, created_at);


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

CREATE INDEX idx_lottery_settings_group ON public.lottery_settings USING btree (group_name);


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

CREATE INDEX idx_odds_items_version_play ON public.odds_items USING btree (version_id, play_code);


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

CREATE INDEX idx_players_site_agent ON public.players USING btree (site_code, agent_node_id);


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

CREATE INDEX idx_players_site_auth_username ON public.players USING btree (site_code, auth_source, username);


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

CREATE INDEX idx_players_status ON public.players USING btree (status);


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

CREATE INDEX idx_risk_cap_items_lookup ON public.risk_cap_items USING btree (version_id, draw_id, normalized_number);


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

CREATE INDEX idx_risk_lock_logs_draw_number ON public.risk_pool_lock_logs USING btree (draw_id, normalized_number);


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

CREATE INDEX idx_risk_pools_draw_soldout ON public.risk_pools USING btree (draw_id, sold_out_status);


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

CREATE INDEX idx_settlement_batches_draw_version ON public.settlement_batches USING btree (draw_id, settle_version);


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

CREATE INDEX idx_settlement_batches_result_batch_id ON public.settlement_batches USING btree (result_batch_id);


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

CREATE INDEX idx_ticket_combinations_item ON public.ticket_combinations USING btree (ticket_item_id);


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

CREATE INDEX idx_ticket_combinations_number ON public.ticket_combinations USING btree (number_4d);


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

CREATE INDEX idx_ticket_items_draw_number ON public.ticket_items USING btree (draw_id, normalized_number);


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

CREATE INDEX idx_ticket_items_draw_status ON public.ticket_items USING btree (draw_id, status);


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

CREATE INDEX idx_ticket_items_order_id ON public.ticket_items USING btree (order_id);


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

CREATE INDEX idx_ticket_items_player_draw ON public.ticket_items USING btree (player_id, draw_id);


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

CREATE INDEX idx_ticket_items_player_id ON public.ticket_items USING btree (player_id, id);


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

CREATE INDEX idx_ticket_orders_draw_id ON public.ticket_orders USING btree (draw_id);


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

CREATE INDEX idx_ticket_orders_player_draw ON public.ticket_orders USING btree (player_id, draw_id);


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

CREATE INDEX idx_ticket_settlement_details_ticket_item ON public.ticket_settlement_details USING btree (ticket_item_id);


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

CREATE INDEX idx_wallet_txns_biz ON public.wallet_txns USING btree (biz_type, biz_no);


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

CREATE INDEX idx_wallet_txns_player_id ON public.wallet_txns USING btree (player_id, id);


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

CREATE INDEX idx_wallet_txns_player_time ON public.wallet_txns USING btree (player_id, created_at);


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

CREATE INDEX jobs_queue_index ON public.jobs USING btree (queue);


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

CREATE INDEX personal_access_tokens_expires_at_index ON public.personal_access_tokens USING btree (expires_at);


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

CREATE INDEX personal_access_tokens_tokenable_type_tokenable_id_index ON public.personal_access_tokens USING btree (tokenable_type, tokenable_id);


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

CREATE INDEX sessions_last_activity_index ON public.sessions USING btree (last_activity);


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

CREATE INDEX sessions_user_id_index ON public.sessions USING btree (user_id);


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

CREATE INDEX settlement_bills_settlement_period_id_bill_type_index ON public.settlement_bills USING btree (settlement_period_id, bill_type);


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

CREATE INDEX settlement_periods_admin_site_id_status_index ON public.settlement_periods USING btree (admin_site_id, status);


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

CREATE INDEX share_ledger_settled_at_player_id_index ON public.share_ledger USING btree (settled_at, player_id);


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

CREATE INDEX share_ledger_settlement_period_id_index ON public.share_ledger USING btree (settlement_period_id);


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

CREATE INDEX transfer_orders_player_id_created_at_index ON public.transfer_orders USING btree (player_id, created_at);


--
-- Name: admin_api_resource_bindings admin_api_resource_bindings_api_resource_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.admin_api_resource_bindings
    ADD CONSTRAINT admin_api_resource_bindings_api_resource_id_foreign FOREIGN KEY (api_resource_id) REFERENCES public.admin_api_resources(id) ON DELETE CASCADE;


--
-- Name: admin_api_resource_bindings admin_api_resource_bindings_menu_action_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.admin_api_resource_bindings
    ADD CONSTRAINT admin_api_resource_bindings_menu_action_id_foreign FOREIGN KEY (menu_action_id) REFERENCES public.admin_menu_actions(id) ON DELETE CASCADE;


--
-- Name: admin_menu_actions admin_menu_actions_action_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.admin_menu_actions
    ADD CONSTRAINT admin_menu_actions_action_id_foreign FOREIGN KEY (action_id) REFERENCES public.admin_action_catalog(id) ON DELETE CASCADE;


--
-- Name: admin_menu_actions admin_menu_actions_menu_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.admin_menu_actions
    ADD CONSTRAINT admin_menu_actions_menu_id_foreign FOREIGN KEY (menu_id) REFERENCES public.admin_menus(id) ON DELETE CASCADE;


--
-- Name: admin_menus admin_menus_parent_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.admin_menus
    ADD CONSTRAINT admin_menus_parent_id_foreign FOREIGN KEY (parent_id) REFERENCES public.admin_menus(id) ON DELETE SET NULL;


--
-- Name: admin_role_menu_actions admin_role_menu_actions_menu_action_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.admin_role_menu_actions
    ADD CONSTRAINT admin_role_menu_actions_menu_action_id_foreign FOREIGN KEY (menu_action_id) REFERENCES public.admin_menu_actions(id) ON DELETE CASCADE;


--
-- Name: admin_role_menu_actions admin_role_menu_actions_role_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.admin_role_menu_actions
    ADD CONSTRAINT admin_role_menu_actions_role_id_foreign FOREIGN KEY (role_id) REFERENCES public.admin_roles(id) ON DELETE CASCADE;


--
-- Name: admin_roles admin_roles_delegated_from_role_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.admin_roles
    ADD CONSTRAINT admin_roles_delegated_from_role_id_foreign FOREIGN KEY (delegated_from_role_id) REFERENCES public.admin_roles(id) ON DELETE SET NULL;


--
-- Name: admin_roles admin_roles_owner_agent_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.admin_roles
    ADD CONSTRAINT admin_roles_owner_agent_id_foreign FOREIGN KEY (owner_agent_id) REFERENCES public.agent_nodes(id) ON DELETE SET NULL;


--
-- Name: admin_user_agent_roles admin_user_agent_roles_admin_user_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.admin_user_agent_roles
    ADD CONSTRAINT admin_user_agent_roles_admin_user_id_foreign FOREIGN KEY (admin_user_id) REFERENCES public.admin_users(id) ON DELETE CASCADE;


--
-- Name: admin_user_agent_roles admin_user_agent_roles_agent_node_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.admin_user_agent_roles
    ADD CONSTRAINT admin_user_agent_roles_agent_node_id_foreign FOREIGN KEY (agent_node_id) REFERENCES public.agent_nodes(id) ON DELETE CASCADE;


--
-- Name: admin_user_agent_roles admin_user_agent_roles_role_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.admin_user_agent_roles
    ADD CONSTRAINT admin_user_agent_roles_role_id_foreign FOREIGN KEY (role_id) REFERENCES public.admin_roles(id) ON DELETE CASCADE;


--
-- Name: admin_user_agents admin_user_agents_admin_user_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.admin_user_agents
    ADD CONSTRAINT admin_user_agents_admin_user_id_foreign FOREIGN KEY (admin_user_id) REFERENCES public.admin_users(id) ON DELETE CASCADE;


--
-- Name: admin_user_agents admin_user_agents_agent_node_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.admin_user_agents
    ADD CONSTRAINT admin_user_agents_agent_node_id_foreign FOREIGN KEY (agent_node_id) REFERENCES public.agent_nodes(id) ON DELETE CASCADE;


--
-- Name: admin_user_menu_actions admin_user_menu_actions_admin_user_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.admin_user_menu_actions
    ADD CONSTRAINT admin_user_menu_actions_admin_user_id_foreign FOREIGN KEY (admin_user_id) REFERENCES public.admin_users(id) ON DELETE CASCADE;


--
-- Name: admin_user_menu_actions admin_user_menu_actions_menu_action_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.admin_user_menu_actions
    ADD CONSTRAINT admin_user_menu_actions_menu_action_id_foreign FOREIGN KEY (menu_action_id) REFERENCES public.admin_menu_actions(id) ON DELETE CASCADE;


--
-- Name: admin_user_menu_actions admin_user_menu_actions_site_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.admin_user_menu_actions
    ADD CONSTRAINT admin_user_menu_actions_site_id_foreign FOREIGN KEY (site_id) REFERENCES public.admin_sites(id) ON DELETE SET NULL;


--
-- Name: admin_user_site_roles admin_user_site_roles_admin_user_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.admin_user_site_roles
    ADD CONSTRAINT admin_user_site_roles_admin_user_id_foreign FOREIGN KEY (admin_user_id) REFERENCES public.admin_users(id) ON DELETE CASCADE;


--
-- Name: admin_user_site_roles admin_user_site_roles_role_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.admin_user_site_roles
    ADD CONSTRAINT admin_user_site_roles_role_id_foreign FOREIGN KEY (role_id) REFERENCES public.admin_roles(id) ON DELETE CASCADE;


--
-- Name: admin_user_site_roles admin_user_site_roles_site_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.admin_user_site_roles
    ADD CONSTRAINT admin_user_site_roles_site_id_foreign FOREIGN KEY (site_id) REFERENCES public.admin_sites(id) ON DELETE CASCADE;


--
-- Name: agent_delegation_grants agent_delegation_grants_child_agent_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.agent_delegation_grants
    ADD CONSTRAINT agent_delegation_grants_child_agent_id_foreign FOREIGN KEY (child_agent_id) REFERENCES public.agent_nodes(id) ON DELETE CASCADE;


--
-- Name: agent_delegation_grants agent_delegation_grants_granted_by_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.agent_delegation_grants
    ADD CONSTRAINT agent_delegation_grants_granted_by_foreign FOREIGN KEY (granted_by) REFERENCES public.admin_users(id) ON DELETE SET NULL;


--
-- Name: agent_delegation_grants agent_delegation_grants_menu_action_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.agent_delegation_grants
    ADD CONSTRAINT agent_delegation_grants_menu_action_id_foreign FOREIGN KEY (menu_action_id) REFERENCES public.admin_menu_actions(id) ON DELETE CASCADE;


--
-- Name: agent_delegation_grants agent_delegation_grants_parent_agent_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.agent_delegation_grants
    ADD CONSTRAINT agent_delegation_grants_parent_agent_id_foreign FOREIGN KEY (parent_agent_id) REFERENCES public.agent_nodes(id) ON DELETE CASCADE;


--
-- Name: agent_nodes agent_nodes_admin_site_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.agent_nodes
    ADD CONSTRAINT agent_nodes_admin_site_id_foreign FOREIGN KEY (admin_site_id) REFERENCES public.admin_sites(id) ON DELETE CASCADE;


--
-- Name: agent_nodes agent_nodes_created_by_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.agent_nodes
    ADD CONSTRAINT agent_nodes_created_by_foreign FOREIGN KEY (created_by) REFERENCES public.admin_users(id) ON DELETE SET NULL;


--
-- Name: agent_nodes agent_nodes_parent_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.agent_nodes
    ADD CONSTRAINT agent_nodes_parent_id_foreign FOREIGN KEY (parent_id) REFERENCES public.agent_nodes(id) ON DELETE SET NULL;


--
-- Name: agent_profiles agent_profiles_agent_node_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.agent_profiles
    ADD CONSTRAINT agent_profiles_agent_node_id_foreign FOREIGN KEY (agent_node_id) REFERENCES public.agent_nodes(id) ON DELETE CASCADE;


--
-- Name: draw_result_batches draw_result_batches_confirmed_by_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.draw_result_batches
    ADD CONSTRAINT draw_result_batches_confirmed_by_foreign FOREIGN KEY (confirmed_by) REFERENCES public.admin_users(id) ON DELETE SET NULL;


--
-- Name: draw_result_batches draw_result_batches_created_by_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.draw_result_batches
    ADD CONSTRAINT draw_result_batches_created_by_foreign FOREIGN KEY (created_by) REFERENCES public.admin_users(id) ON DELETE SET NULL;


--
-- Name: draw_result_batches draw_result_batches_draw_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.draw_result_batches
    ADD CONSTRAINT draw_result_batches_draw_id_foreign FOREIGN KEY (draw_id) REFERENCES public.draws(id) ON DELETE CASCADE;


--
-- Name: draw_result_items draw_result_items_draw_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.draw_result_items
    ADD CONSTRAINT draw_result_items_draw_id_foreign FOREIGN KEY (draw_id) REFERENCES public.draws(id) ON DELETE CASCADE;


--
-- Name: draw_result_items draw_result_items_result_batch_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.draw_result_items
    ADD CONSTRAINT draw_result_items_result_batch_id_foreign FOREIGN KEY (result_batch_id) REFERENCES public.draw_result_batches(id) ON DELETE CASCADE;


--
-- Name: jackpot_contributions jackpot_contributions_draw_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jackpot_contributions
    ADD CONSTRAINT jackpot_contributions_draw_id_foreign FOREIGN KEY (draw_id) REFERENCES public.draws(id) ON DELETE CASCADE;


--
-- Name: jackpot_contributions jackpot_contributions_jackpot_pool_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jackpot_contributions
    ADD CONSTRAINT jackpot_contributions_jackpot_pool_id_foreign FOREIGN KEY (jackpot_pool_id) REFERENCES public.jackpot_pools(id) ON DELETE CASCADE;


--
-- Name: jackpot_contributions jackpot_contributions_player_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jackpot_contributions
    ADD CONSTRAINT jackpot_contributions_player_id_foreign FOREIGN KEY (player_id) REFERENCES public.players(id) ON DELETE CASCADE;


--
-- Name: jackpot_contributions jackpot_contributions_ticket_item_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jackpot_contributions
    ADD CONSTRAINT jackpot_contributions_ticket_item_id_foreign FOREIGN KEY (ticket_item_id) REFERENCES public.ticket_items(id) ON DELETE SET NULL;


--
-- Name: jackpot_payout_logs jackpot_payout_logs_draw_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jackpot_payout_logs
    ADD CONSTRAINT jackpot_payout_logs_draw_id_foreign FOREIGN KEY (draw_id) REFERENCES public.draws(id) ON DELETE CASCADE;


--
-- Name: jackpot_payout_logs jackpot_payout_logs_jackpot_pool_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jackpot_payout_logs
    ADD CONSTRAINT jackpot_payout_logs_jackpot_pool_id_foreign FOREIGN KEY (jackpot_pool_id) REFERENCES public.jackpot_pools(id) ON DELETE CASCADE;


--
-- Name: jackpot_pool_adjustments jackpot_pool_adjustments_admin_user_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jackpot_pool_adjustments
    ADD CONSTRAINT jackpot_pool_adjustments_admin_user_id_foreign FOREIGN KEY (admin_user_id) REFERENCES public.admin_users(id) ON DELETE CASCADE;


--
-- Name: jackpot_pool_adjustments jackpot_pool_adjustments_jackpot_pool_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jackpot_pool_adjustments
    ADD CONSTRAINT jackpot_pool_adjustments_jackpot_pool_id_foreign FOREIGN KEY (jackpot_pool_id) REFERENCES public.jackpot_pools(id) ON DELETE CASCADE;


--
-- Name: jackpot_pools jackpot_pools_last_trigger_draw_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jackpot_pools
    ADD CONSTRAINT jackpot_pools_last_trigger_draw_id_foreign FOREIGN KEY (last_trigger_draw_id) REFERENCES public.draws(id) ON DELETE SET NULL;


--
-- Name: odds_items odds_items_version_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.odds_items
    ADD CONSTRAINT odds_items_version_id_foreign FOREIGN KEY (version_id) REFERENCES public.odds_versions(id) ON DELETE CASCADE;


--
-- Name: odds_versions odds_versions_updated_by_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.odds_versions
    ADD CONSTRAINT odds_versions_updated_by_foreign FOREIGN KEY (updated_by) REFERENCES public.admin_users(id) ON DELETE SET NULL;


--
-- Name: payment_records payment_records_confirmed_by_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.payment_records
    ADD CONSTRAINT payment_records_confirmed_by_foreign FOREIGN KEY (confirmed_by) REFERENCES public.admin_users(id) ON DELETE SET NULL;


--
-- Name: payment_records payment_records_created_by_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.payment_records
    ADD CONSTRAINT payment_records_created_by_foreign FOREIGN KEY (created_by) REFERENCES public.admin_users(id) ON DELETE SET NULL;


--
-- Name: payment_records payment_records_settlement_bill_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.payment_records
    ADD CONSTRAINT payment_records_settlement_bill_id_foreign FOREIGN KEY (settlement_bill_id) REFERENCES public.settlement_bills(id) ON DELETE CASCADE;


--
-- Name: play_config_items play_config_items_version_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.play_config_items
    ADD CONSTRAINT play_config_items_version_id_foreign FOREIGN KEY (version_id) REFERENCES public.play_config_versions(id) ON DELETE CASCADE;


--
-- Name: play_config_versions play_config_versions_updated_by_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.play_config_versions
    ADD CONSTRAINT play_config_versions_updated_by_foreign FOREIGN KEY (updated_by) REFERENCES public.admin_users(id) ON DELETE SET NULL;


--
-- Name: player_credit_accounts player_credit_accounts_player_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.player_credit_accounts
    ADD CONSTRAINT player_credit_accounts_player_id_foreign FOREIGN KEY (player_id) REFERENCES public.players(id) ON DELETE CASCADE;


--
-- Name: player_rebate_profiles player_rebate_profiles_player_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.player_rebate_profiles
    ADD CONSTRAINT player_rebate_profiles_player_id_foreign FOREIGN KEY (player_id) REFERENCES public.players(id) ON DELETE CASCADE;


--
-- Name: player_wallets player_wallets_player_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.player_wallets
    ADD CONSTRAINT player_wallets_player_id_foreign FOREIGN KEY (player_id) REFERENCES public.players(id) ON DELETE CASCADE;


--
-- Name: players players_agent_node_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.players
    ADD CONSTRAINT players_agent_node_id_foreign FOREIGN KEY (agent_node_id) REFERENCES public.agent_nodes(id) ON DELETE SET NULL;


--
-- Name: rebate_allocations rebate_allocations_rebate_record_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.rebate_allocations
    ADD CONSTRAINT rebate_allocations_rebate_record_id_foreign FOREIGN KEY (rebate_record_id) REFERENCES public.rebate_records(id) ON DELETE CASCADE;


--
-- Name: rebate_allocations rebate_allocations_settlement_bill_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.rebate_allocations
    ADD CONSTRAINT rebate_allocations_settlement_bill_id_foreign FOREIGN KEY (settlement_bill_id) REFERENCES public.settlement_bills(id) ON DELETE SET NULL;


--
-- Name: rebate_records rebate_records_owner_agent_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.rebate_records
    ADD CONSTRAINT rebate_records_owner_agent_id_foreign FOREIGN KEY (owner_agent_id) REFERENCES public.agent_nodes(id) ON DELETE SET NULL;


--
-- Name: rebate_records rebate_records_player_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.rebate_records
    ADD CONSTRAINT rebate_records_player_id_foreign FOREIGN KEY (player_id) REFERENCES public.players(id) ON DELETE CASCADE;


--
-- Name: rebate_records rebate_records_reversal_of_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.rebate_records
    ADD CONSTRAINT rebate_records_reversal_of_id_foreign FOREIGN KEY (reversal_of_id) REFERENCES public.rebate_records(id) ON DELETE SET NULL;


--
-- Name: rebate_records rebate_records_settlement_period_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.rebate_records
    ADD CONSTRAINT rebate_records_settlement_period_id_foreign FOREIGN KEY (settlement_period_id) REFERENCES public.settlement_periods(id) ON DELETE SET NULL;


--
-- Name: rebate_records rebate_records_ticket_item_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.rebate_records
    ADD CONSTRAINT rebate_records_ticket_item_id_foreign FOREIGN KEY (ticket_item_id) REFERENCES public.ticket_items(id) ON DELETE SET NULL;


--
-- Name: reconcile_items reconcile_items_reconcile_job_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.reconcile_items
    ADD CONSTRAINT reconcile_items_reconcile_job_id_foreign FOREIGN KEY (reconcile_job_id) REFERENCES public.reconcile_jobs(id) ON DELETE CASCADE;


--
-- Name: reconcile_jobs reconcile_jobs_admin_user_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.reconcile_jobs
    ADD CONSTRAINT reconcile_jobs_admin_user_id_foreign FOREIGN KEY (admin_user_id) REFERENCES public.admin_users(id) ON DELETE SET NULL;


--
-- Name: report_jobs report_jobs_admin_user_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.report_jobs
    ADD CONSTRAINT report_jobs_admin_user_id_foreign FOREIGN KEY (admin_user_id) REFERENCES public.admin_users(id) ON DELETE SET NULL;


--
-- Name: risk_cap_items risk_cap_items_draw_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.risk_cap_items
    ADD CONSTRAINT risk_cap_items_draw_id_foreign FOREIGN KEY (draw_id) REFERENCES public.draws(id) ON DELETE SET NULL;


--
-- Name: risk_cap_items risk_cap_items_version_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.risk_cap_items
    ADD CONSTRAINT risk_cap_items_version_id_foreign FOREIGN KEY (version_id) REFERENCES public.risk_cap_versions(id) ON DELETE CASCADE;


--
-- Name: risk_cap_versions risk_cap_versions_updated_by_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.risk_cap_versions
    ADD CONSTRAINT risk_cap_versions_updated_by_foreign FOREIGN KEY (updated_by) REFERENCES public.admin_users(id) ON DELETE SET NULL;


--
-- Name: risk_pool_lock_logs risk_pool_lock_logs_draw_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.risk_pool_lock_logs
    ADD CONSTRAINT risk_pool_lock_logs_draw_id_foreign FOREIGN KEY (draw_id) REFERENCES public.draws(id) ON DELETE CASCADE;


--
-- Name: risk_pool_lock_logs risk_pool_lock_logs_ticket_item_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.risk_pool_lock_logs
    ADD CONSTRAINT risk_pool_lock_logs_ticket_item_id_foreign FOREIGN KEY (ticket_item_id) REFERENCES public.ticket_items(id) ON DELETE SET NULL;


--
-- Name: risk_pools risk_pools_draw_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.risk_pools
    ADD CONSTRAINT risk_pools_draw_id_foreign FOREIGN KEY (draw_id) REFERENCES public.draws(id) ON DELETE CASCADE;


--
-- Name: settlement_adjustments settlement_adjustments_created_by_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.settlement_adjustments
    ADD CONSTRAINT settlement_adjustments_created_by_foreign FOREIGN KEY (created_by) REFERENCES public.admin_users(id) ON DELETE SET NULL;


--
-- Name: settlement_adjustments settlement_adjustments_original_bill_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.settlement_adjustments
    ADD CONSTRAINT settlement_adjustments_original_bill_id_foreign FOREIGN KEY (original_bill_id) REFERENCES public.settlement_bills(id) ON DELETE SET NULL;


--
-- Name: settlement_adjustments settlement_adjustments_settlement_period_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.settlement_adjustments
    ADD CONSTRAINT settlement_adjustments_settlement_period_id_foreign FOREIGN KEY (settlement_period_id) REFERENCES public.settlement_periods(id) ON DELETE SET NULL;


--
-- Name: settlement_batches settlement_batches_draw_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.settlement_batches
    ADD CONSTRAINT settlement_batches_draw_id_foreign FOREIGN KEY (draw_id) REFERENCES public.draws(id) ON DELETE CASCADE;


--
-- Name: settlement_batches settlement_batches_result_batch_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.settlement_batches
    ADD CONSTRAINT settlement_batches_result_batch_id_foreign FOREIGN KEY (result_batch_id) REFERENCES public.draw_result_batches(id) ON DELETE CASCADE;


--
-- Name: settlement_batches settlement_batches_reviewed_by_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.settlement_batches
    ADD CONSTRAINT settlement_batches_reviewed_by_foreign FOREIGN KEY (reviewed_by) REFERENCES public.admin_users(id) ON DELETE SET NULL;


--
-- Name: settlement_bills settlement_bills_reversed_bill_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.settlement_bills
    ADD CONSTRAINT settlement_bills_reversed_bill_id_foreign FOREIGN KEY (reversed_bill_id) REFERENCES public.settlement_bills(id) ON DELETE SET NULL;


--
-- Name: settlement_bills settlement_bills_settlement_period_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.settlement_bills
    ADD CONSTRAINT settlement_bills_settlement_period_id_foreign FOREIGN KEY (settlement_period_id) REFERENCES public.settlement_periods(id) ON DELETE CASCADE;


--
-- Name: settlement_periods settlement_periods_admin_site_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.settlement_periods
    ADD CONSTRAINT settlement_periods_admin_site_id_foreign FOREIGN KEY (admin_site_id) REFERENCES public.admin_sites(id) ON DELETE CASCADE;


--
-- Name: share_ledger share_ledger_agent_node_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.share_ledger
    ADD CONSTRAINT share_ledger_agent_node_id_foreign FOREIGN KEY (agent_node_id) REFERENCES public.agent_nodes(id) ON DELETE SET NULL;


--
-- Name: share_ledger share_ledger_player_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.share_ledger
    ADD CONSTRAINT share_ledger_player_id_foreign FOREIGN KEY (player_id) REFERENCES public.players(id) ON DELETE CASCADE;


--
-- Name: share_ledger share_ledger_reversal_of_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.share_ledger
    ADD CONSTRAINT share_ledger_reversal_of_id_foreign FOREIGN KEY (reversal_of_id) REFERENCES public.share_ledger(id) ON DELETE SET NULL;


--
-- Name: share_ledger share_ledger_settlement_period_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.share_ledger
    ADD CONSTRAINT share_ledger_settlement_period_id_foreign FOREIGN KEY (settlement_period_id) REFERENCES public.settlement_periods(id) ON DELETE SET NULL;


--
-- Name: share_ledger share_ledger_ticket_item_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.share_ledger
    ADD CONSTRAINT share_ledger_ticket_item_id_foreign FOREIGN KEY (ticket_item_id) REFERENCES public.ticket_items(id) ON DELETE CASCADE;


--
-- Name: ticket_combinations ticket_combinations_ticket_item_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ticket_combinations
    ADD CONSTRAINT ticket_combinations_ticket_item_id_foreign FOREIGN KEY (ticket_item_id) REFERENCES public.ticket_items(id) ON DELETE CASCADE;


--
-- Name: ticket_items ticket_items_agent_node_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ticket_items
    ADD CONSTRAINT ticket_items_agent_node_id_foreign FOREIGN KEY (agent_node_id) REFERENCES public.agent_nodes(id) ON DELETE SET NULL;


--
-- Name: ticket_items ticket_items_agent_settlement_reversal_of_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ticket_items
    ADD CONSTRAINT ticket_items_agent_settlement_reversal_of_id_foreign FOREIGN KEY (agent_settlement_reversal_of_id) REFERENCES public.ticket_items(id) ON DELETE SET NULL;


--
-- Name: ticket_items ticket_items_draw_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ticket_items
    ADD CONSTRAINT ticket_items_draw_id_foreign FOREIGN KEY (draw_id) REFERENCES public.draws(id) ON DELETE CASCADE;


--
-- Name: ticket_items ticket_items_order_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ticket_items
    ADD CONSTRAINT ticket_items_order_id_foreign FOREIGN KEY (order_id) REFERENCES public.ticket_orders(id) ON DELETE CASCADE;


--
-- Name: ticket_items ticket_items_player_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ticket_items
    ADD CONSTRAINT ticket_items_player_id_foreign FOREIGN KEY (player_id) REFERENCES public.players(id) ON DELETE CASCADE;


--
-- Name: ticket_orders ticket_orders_draw_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ticket_orders
    ADD CONSTRAINT ticket_orders_draw_id_foreign FOREIGN KEY (draw_id) REFERENCES public.draws(id) ON DELETE CASCADE;


--
-- Name: ticket_orders ticket_orders_player_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ticket_orders
    ADD CONSTRAINT ticket_orders_player_id_foreign FOREIGN KEY (player_id) REFERENCES public.players(id) ON DELETE CASCADE;


--
-- Name: ticket_settlement_details ticket_settlement_details_settlement_batch_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ticket_settlement_details
    ADD CONSTRAINT ticket_settlement_details_settlement_batch_id_foreign FOREIGN KEY (settlement_batch_id) REFERENCES public.settlement_batches(id) ON DELETE CASCADE;


--
-- Name: ticket_settlement_details ticket_settlement_details_ticket_item_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ticket_settlement_details
    ADD CONSTRAINT ticket_settlement_details_ticket_item_id_foreign FOREIGN KEY (ticket_item_id) REFERENCES public.ticket_items(id) ON DELETE CASCADE;


--
-- Name: transfer_orders transfer_orders_player_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.transfer_orders
    ADD CONSTRAINT transfer_orders_player_id_foreign FOREIGN KEY (player_id) REFERENCES public.players(id) ON DELETE CASCADE;


--
-- Name: wallet_txns wallet_txns_player_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.wallet_txns
    ADD CONSTRAINT wallet_txns_player_id_foreign FOREIGN KEY (player_id) REFERENCES public.players(id) ON DELETE CASCADE;


--
-- Name: wallet_txns wallet_txns_wallet_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.wallet_txns
    ADD CONSTRAINT wallet_txns_wallet_id_foreign FOREIGN KEY (wallet_id) REFERENCES public.player_wallets(id) ON DELETE CASCADE;


--
-- PostgreSQL database dump complete
--

\unrestrict rPXEgF1VaYgsz0ptn4X1KcYROWRPYlYb6daN4zAOY961hMNjxCs5gLhsUZO9N0E

--
-- PostgreSQL database dump
--

\restrict RiLJxG2okqJB0Ghnyl7nmKPp6kFTgq0lQmAb7r3CeeShjxRjgjZVfbJ1VM9V1oB

-- Dumped from database version 18.3(ServBay)
-- Dumped by pg_dump version 18.3(ServBay)

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;

--
-- Data for Name: migrations; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.migrations (id, migration, batch) FROM stdin;
1	0001_01_01_000000_create_users_table	1
2	0001_01_01_000001_create_cache_table	1
3	0001_01_01_000002_create_jobs_table	1
4	2026_05_08_100000_create_currencies_table	1
5	2026_05_08_100001_create_players_table	1
6	2026_05_08_100002_create_admin_users_table	1
7	2026_05_08_100003_create_admin_roles_and_permissions_tables	1
8	2026_05_08_100004_create_player_wallets_table	1
9	2026_05_08_100005_create_wallet_txns_table	1
10	2026_05_08_100006_create_transfer_orders_table	1
11	2026_05_08_100007_create_draws_table	1
12	2026_05_08_100008_create_draw_result_batches_table	1
13	2026_05_08_100009_create_draw_result_items_table	1
14	2026_05_08_120000_drop_laravel_default_users_and_password_reset_tables	1
15	2026_05_08_130000_create_play_types_table	1
16	2026_05_08_130001_create_play_config_versions_and_items_tables	1
17	2026_05_08_130002_create_odds_versions_and_items_tables	1
18	2026_05_08_130003_create_risk_cap_versions_and_items_tables	1
19	2026_05_08_130004_create_ticket_orders_table	1
20	2026_05_08_130005_create_ticket_items_table	1
21	2026_05_08_130006_create_ticket_combinations_table	1
22	2026_05_08_130007_create_risk_pools_and_lock_logs_tables	1
23	2026_05_08_130008_create_settlement_and_jackpot_tables	1
24	2026_05_08_130009_create_report_audit_reconcile_tables	1
25	2026_05_08_140000_create_lottery_settings_table	1
26	2026_05_09_023835_create_personal_access_tokens_table	1
27	2026_05_09_119999_rename_duplicate_migration_filenames_in_table	1
28	2026_05_09_120001_add_username_and_nullable_email_to_admin_users	1
29	2026_05_09_120002_migrate_draw_status_to_domain_dict	1
30	2026_05_11_120000_add_admin_user_id_to_reconcile_jobs_table	1
31	2026_05_11_173000_create_admin_user_permissions_table	1
32	2026_05_13_100000_rebuild_admin_authorization_system	1
33	2026_05_16_000100_add_snapshot_columns_to_play_config_items_table	1
34	2026_05_18_000001_add_combo_trigger_to_jackpot_pools_table	1
35	2026_05_18_090000_add_config_version_snapshots_to_ticket_orders	1
36	2026_05_18_120000_sync_complete_admin_api_resources	1
37	2026_05_19_112752_seed_default_jackpot_pools	1
38	2026_05_19_120000_create_admin_role_legacy_permissions_table	1
39	2026_05_19_121000_sync_admin_role_manage_permission	1
40	2026_05_19_122000_sync_player_permission_resource_bindings	1
41	2026_05_20_000001_add_admin_ticket_items_api_resource	1
42	2026_05_21_000002_add_admin_currency_api_resources	1
43	2026_05_21_093141_add_dimension_to_odds_items_table	1
44	2026_05_21_150000_add_admin_currency_destroy_api_resource	1
45	2026_05_21_160000_add_currency_manage_legacy_permission	1
46	2026_05_21_170000_move_currency_menu_to_top_level_route	1
47	2026_05_22_100000_add_admin_report_module	1
48	2026_05_22_110000_fix_admin_report_authorization	1
49	2026_05_22_120000_drop_redundant_admin_and_system_tables	1
50	2026_05_22_130000_consolidate_admin_rbac_slugs	1
51	2026_05_22_140000_add_frontend_play_rules_html_i18n_settings	1
52	2026_05_25_120001_consolidate_play_display_name_columns	1
53	2026_05_25_120002_expand_audit_logs_target_type	1
54	2026_05_25_120003_refine_admin_permission_granularity	1
55	2026_05_25_130000_remove_stale_admin_menu_actions	1
56	2026_05_25_140000_add_admin_dashboard_analytics_resource	1
57	2026_05_25_180000_add_settlement_batch_review_columns	1
58	2026_05_26_100000_expand_admin_permission_granularity	1
59	2026_05_27_100000_add_jackpot_manual_burst_permission	1
60	2026_05_28_100000_resync_admin_api_resources_after_dashboard_view	2
61	2026_05_29_100000_add_unique_ticket_item_id_to_jackpot_contributions	3
62	2026_05_30_100000_create_jackpot_pool_adjustments_table	4
63	2026_05_30_100001_add_jackpot_pool_adjustment_api_resources	5
64	2026_05_26_120000_add_unique_client_trace_to_ticket_orders	6
65	2026_05_27_140000_add_integration_fields_to_admin_sites	6
66	2026_05_27_140001_seed_integration_menu_actions	7
67	2026_05_31_100000_add_query_performance_indexes	8
68	2026_06_01_100000_add_admin_settings_batch_update_api_resource	8
69	2026_06_02_100000_create_agent_hierarchy_tables	8
70	2026_06_02_100001_seed_agent_node_permissions	8
71	2026_06_02_110000_agent_scoped_roles_and_player_agent	8
72	2026_06_02_110001_seed_agent_role_permissions	8
73	2026_06_02_120000_create_agent_delegation_grants	8
74	2026_06_02_130000_backfill_players_agent_node_id	9
75	2026_06_03_140000_ensure_agent_admin_user_destroy_api_resource	10
76	2026_06_03_120000_split_agent_permission_granularity	11
77	2026_06_03_150000_align_root_agent_codes	12
78	2026_06_03_160000_agent_credit_and_settlement_tables	12
79	2026_06_03_170000_seed_agent_settlement_api_resources	13
80	2026_06_03_180000_add_agent_profile_capability_flags	14
81	2026_06_03_190000_fix_agent_primary_admin_user_status	15
82	2026_06_04_100000_agent_game_settlement_ledger	16
83	2026_06_04_120000_resync_agent_owner_role_permissions	16
84	2026_06_04_130000_seed_platform_agent_role_and_resync_bindings	16
85	2026_06_04_140000_bind_agents_to_platform_agent_role	17
86	2026_06_04_120000_add_player_auth_and_funding_mode	18
87	2026_06_04_120000_agent_settlement_payment_proof	19
88	2026_06_04_140000_agent_settlement_reports_and_tags	20
89	2026_06_04_150000_ensure_platform_fixed_system_roles	20
90	2026_06_05_120000_seed_credit_ledger_admin_api_resource	21
\.


--
-- Name: migrations_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.migrations_id_seq', 90, true);


--
-- PostgreSQL database dump complete
--

\unrestrict RiLJxG2okqJB0Ghnyl7nmKPp6kFTgq0lQmAb7r3CeeShjxRjgjZVfbJ1VM9V1oB

