dkforest

A forum and chat platform (onion)
git clone https://git.dasho.dev/n0tr1v/dkforest.git
Log | Files | Refs | LICENSE

147.sql (2168B)


      1 -- +migrate Up
      2 CREATE TABLE IF NOT EXISTS poker_tables (
      3     id INTEGER NOT NULL PRIMARY KEY,
      4     slug VARCHAR(255) UNIQUE NOT NULL,
      5     name VARCHAR(50) NOT NULL,
      6     min_buy_in INTEGER NOT NULL,
      7     max_buy_in INTEGER NOT NULL,
      8     min_bet INTEGER NOT NULL,
      9     is_test TINYINT(1) NOT NULL DEFAULT 1);
     10 CREATE INDEX poker_tables_slug_idx ON poker_tables (slug);
     11 CREATE INDEX poker_tables_is_test_idx ON poker_tables (is_test);
     12 
     13 INSERT INTO poker_tables (slug, name, min_buy_in, max_buy_in, min_bet, is_test) VALUES ('test', 'test', 1000, 2000, 20, 1);
     14 INSERT INTO poker_tables (slug, name, min_buy_in, max_buy_in, min_bet, is_test) VALUES ('test1', 'test1', 1000, 2000, 20, 1);
     15 INSERT INTO poker_tables (slug, name, min_buy_in, max_buy_in, min_bet, is_test) VALUES ('test2', 'test2', 1000, 2000, 20, 1);
     16 INSERT INTO poker_tables (slug, name, min_buy_in, max_buy_in, min_bet, is_test) VALUES ('test3', 'test3', 1000, 2000, 20, 1);
     17 INSERT INTO poker_tables (slug, name, min_buy_in, max_buy_in, min_bet, is_test) VALUES ('test4', 'test4', 1000, 2000, 20, 1);
     18 INSERT INTO poker_tables (slug, name, min_buy_in, max_buy_in, min_bet, is_test) VALUES ('test5', 'test5', 1000, 2000, 20, 1);
     19 
     20 CREATE TABLE IF NOT EXISTS poker_table_accounts (
     21     id INTEGER NOT NULL PRIMARY KEY,
     22     user_id INTEGER NOT NULL,
     23     poker_table_id INTEGER NOT NULL,
     24     amount INTEGER NOT NULL,
     25     amount_bet INTEGER NOT NULL,
     26     UNIQUE (user_id, poker_table_id),
     27     CONSTRAINT poker_table_accounts_user_id_fk
     28         FOREIGN KEY (user_id)
     29             REFERENCES users (id)
     30             ON DELETE NO ACTION
     31             ON UPDATE CASCADE,
     32     CONSTRAINT poker_table_accounts_poker_table_id_fk
     33         FOREIGN KEY (poker_table_id)
     34             REFERENCES poker_tables (id)
     35             ON DELETE NO ACTION
     36             ON UPDATE CASCADE);
     37 CREATE INDEX poker_table_accounts_poker_table_id_idx ON poker_table_accounts (poker_table_id);
     38 CREATE INDEX poker_table_accounts_user_id_idx ON poker_table_accounts (user_id);
     39 CREATE INDEX poker_table_accounts_amount_idx ON poker_table_accounts (amount);
     40 CREATE INDEX poker_table_accounts_amount_bet_idx ON poker_table_accounts (amount_bet);
     41 
     42 -- +migrate Down