-- Create payouts table
CREATE TABLE IF NOT EXISTS payouts (
    id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
    user_id INT NOT NULL,
    username VARCHAR(255) NOT NULL,
    type VARCHAR(20) NOT NULL COMMENT 'STARS, GIFT',
    gift_name VARCHAR(50) NULL COMMENT 'Gift name for GIFT type (HEART, BEAR, etc)',
    total BIGINT UNSIGNED NOT NULL COMMENT 'Tickets amount in bigint format',
    stars_amount INT NOT NULL COMMENT 'Stars amount',
    status VARCHAR(20) NOT NULL DEFAULT 'PROCESSING' COMMENT 'PROCESSING, COMPLETED, CANCELLED',
    created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    resolved_at TIMESTAMP NULL,
    INDEX idx_user_id (user_id),
    INDEX idx_status (status),
    INDEX idx_created_at (created_at),
    FOREIGN KEY (user_id) REFERENCES db_users_a(id) ON DELETE RESTRICT
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

