USE mtplayyyy;

-- TRX Wingo Game table (used by cron jobs)
CREATE TABLE IF NOT EXISTS trx_wingo_game (
    id int(11) NOT NULL AUTO_INCREMENT,
    period varchar(30) NOT NULL DEFAULT '0',
    result varchar(10) NOT NULL DEFAULT '0',
    game varchar(20) NOT NULL DEFAULT 'trx_wingo',
    status int(11) NOT NULL DEFAULT 0,
    release_status int(11) NOT NULL DEFAULT 0,
    time varchar(50) NOT NULL DEFAULT '0',
    PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- TRX Wingo Bets table
CREATE TABLE IF NOT EXISTS trx_wingo_bets (
    id int(11) NOT NULL AUTO_INCREMENT,
    id_product varchar(50) NOT NULL DEFAULT '0',
    phone varchar(20) NOT NULL DEFAULT '0',
    game varchar(20) NOT NULL DEFAULT 'trx_wingo',
    period varchar(30) NOT NULL DEFAULT '0',
    bet varchar(20) NOT NULL DEFAULT '0',
    money float NOT NULL DEFAULT 0,
    fee float NOT NULL DEFAULT 0,
    get float NOT NULL DEFAULT 0,
    status int(11) NOT NULL DEFAULT 0,
    today datetime NOT NULL DEFAULT current_timestamp(),
    time varchar(50) NOT NULL DEFAULT '0',
    PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- Seed initial trx_wingo_game rows for each game type
INSERT INTO trx_wingo_game (period, result, game, status, release_status, time)
VALUES ('2022070110000', '0', 'trx_wingo', 1, 1, UNIX_TIMESTAMP()*1000);
INSERT INTO trx_wingo_game (period, result, game, status, release_status, time)
VALUES ('2022070110001', '0', 'trx_wingo', 0, 0, UNIX_TIMESTAMP()*1000);

INSERT INTO trx_wingo_game (period, result, game, status, release_status, time)
VALUES ('2022070110000', '0', 'trx_wingo3', 1, 1, UNIX_TIMESTAMP()*1000);
INSERT INTO trx_wingo_game (period, result, game, status, release_status, time)
VALUES ('2022070110001', '0', 'trx_wingo3', 0, 0, UNIX_TIMESTAMP()*1000);

INSERT INTO trx_wingo_game (period, result, game, status, release_status, time)
VALUES ('2022070110000', '0', 'trx_wingo5', 1, 1, UNIX_TIMESTAMP()*1000);
INSERT INTO trx_wingo_game (period, result, game, status, release_status, time)
VALUES ('2022070110001', '0', 'trx_wingo5', 0, 0, UNIX_TIMESTAMP()*1000);

INSERT INTO trx_wingo_game (period, result, game, status, release_status, time)
VALUES ('2022070110000', '0', 'trx_wingo10', 1, 1, UNIX_TIMESTAMP()*1000);
INSERT INTO trx_wingo_game (period, result, game, status, release_status, time)
VALUES ('2022070110001', '0', 'trx_wingo10', 0, 0, UNIX_TIMESTAMP()*1000);

SELECT 'Missing tables created!' AS status;
