drop table if exists tb_room;
create table tb_room
(
    batch_no VARCHAR(50) PRIMARY KEY,                -- 批次
    item_num int not null check (item_num between 1 and 6), -- 游戏项目(1到6)
    player_count int not null default 0,             -- 房间人数
    create_date timestamptz                          -- 创建时间
);

drop table if exists tb_game;
create table tb_game
(
    wechat_id text,                 -- 微信id
    nickname varchar(50),   	    -- 昵称
    avatar text,      	            -- 头像
    game_rank int,                       -- 排名
    item_num int  not null check (item_num between 1 and 6),     -- 游戏项目(1到6)
    score int not null default 0 check (score >= 0),             -- 得分
    create_date timestamptz,         -- 创建时间
    batch_no VARCHAR(50)				--批次
);
SELECT * FROM tb_game


DROP TABLE IF EXISTS tb_log;
CREATE TABLE tb_log
(
	id BIGSERIAL  PRIMARY KEY,
	msg TEXT,
	params jsonb,
	create_date timestamptz
);

SELECT * FROM tb_log


drop table if exists tb_manager;
create table tb_manager
(
   id SERIAL  PRIMARY KEY,
	username VARCHAR(20),
	"password" VARCHAR(20),
	token VARCHAR(36)
)

INSERT INTO tb_manager(username,"password",token) VALUES('admin','123456','88236aeb-8d3f-6d56-fdf5-3adca3961dfb');

SELECT * FROM tb_manager;

