CREATE TABLE users (
    id BIGSERIAL PRIMARY KEY,
    first_name VARCHAR(255) NOT NULL,
    last_name VARCHAR(255) NOT NULL,
    email VARCHAR(255) UNIQUE NOT NULL,
    phone_number VARCHAR(20) UNIQUE NOT NULL,
    password TEXT NOT NULL,
    role VARCHAR(50) NOT NULL,
    verified BOOLEAN DEFAULT FALSE,
    created_at TIMESTAMP,
    updated_at TIMESTAMP 
);


CREATE TABLE IF NOT EXISTS bets (
	id BIGSERIAL PRIMARY KEY,
	amount BIGINT NOT NULL,
	total_odds REAL NOT NULL,
    status INT NOT NULL,
    full_name VARCHAR(255) NOT NULL,
    phone_number VARCHAR(255) NOT NULL,
    branch_id BIGINT,
    user_id BIGINT,
    cashed_out BOOLEAN DEFAULT FALSE,
	created_at TIMESTAMP,
    updated_at TIMESTAMP,
    CHECK (user_id IS NOT NULL OR branch_id IS NOT NULL)
);

CREATE TABLE IF NOT EXISTS tickets (
	id BIGSERIAL PRIMARY KEY,
	amount BIGINT NULL,
	total_odds REAL NOT NULL,
	created_at TIMESTAMP,
    updated_at TIMESTAMP  
);


-- CREATE TABLE IF NOT EXISTS bet_outcomes (
-- 	id BIGSERIAL PRIMARY KEY,
--     bet_id BIGINT NOT NULL,
-- 	outcome_id BIGINT NOT NULL,
-- );

-- CREATE TABLE IF NOT EXISTS ticket_outcomes (
-- 	id BIGSERIAL PRIMARY KEY,
--     ticket_id BIGINT NOT NULL,
-- 	outcome_id BIGINT NOT NULL,
-- );