|
| 1 | +create table account |
| 2 | +( |
| 3 | + account_id int auto_increment |
| 4 | + primary key, |
| 5 | + cash double not null, |
| 6 | + user_id int not null |
| 7 | +); |
| 8 | + |
| 9 | +create table asset |
| 10 | +( |
| 11 | + ticker varchar(10) not null |
| 12 | + primary key, |
| 13 | + name varchar(100) null |
| 14 | +); |
| 15 | + |
| 16 | +create table buy_orders |
| 17 | +( |
| 18 | + buy_order_id bigint auto_increment |
| 19 | + primary key, |
| 20 | + created_at datetime(6) not null, |
| 21 | + is_bot bit not null, |
| 22 | + is_marketorder bit not null, |
| 23 | + order_size double null, |
| 24 | + price double null, |
| 25 | + remaining_size double null, |
| 26 | + state enum ('CANCELED', 'DONE', 'WAIT') not null, |
| 27 | + ticker varchar(10) not null, |
| 28 | + user_id int not null, |
| 29 | + locked_deposit double not null, |
| 30 | + remaining_deposit double not null |
| 31 | +); |
| 32 | + |
| 33 | +create table oauth |
| 34 | +( |
| 35 | + oauth_id int auto_increment |
| 36 | + primary key, |
| 37 | + access_token text null, |
| 38 | + email varchar(255) null, |
| 39 | + expires_at datetime(6) null, |
| 40 | + nickname varchar(255) null, |
| 41 | + provider varchar(20) not null, |
| 42 | + provider_user_id varchar(255) not null, |
| 43 | + refresh_token text null, |
| 44 | + scope varchar(255) null, |
| 45 | + user_id int not null |
| 46 | +); |
| 47 | + |
| 48 | +create table sell_orders |
| 49 | +( |
| 50 | + sell_order_id bigint auto_increment |
| 51 | + primary key, |
| 52 | + created_at datetime(6) not null, |
| 53 | + is_bot bit not null, |
| 54 | + is_marketorder bit not null, |
| 55 | + order_size double null, |
| 56 | + price double null, |
| 57 | + remaining_size double null, |
| 58 | + state enum ('CANCELED', 'DONE', 'WAIT') not null, |
| 59 | + ticker varchar(10) not null, |
| 60 | + user_id int not null |
| 61 | +); |
| 62 | + |
| 63 | +create table trade |
| 64 | +( |
| 65 | + trade_id int auto_increment |
| 66 | + primary key, |
| 67 | + buy_user_id int not null, |
| 68 | + price double not null, |
| 69 | + sell_user_id int not null, |
| 70 | + size double not null, |
| 71 | + ticker varchar(255) not null, |
| 72 | + trade_time datetime(6) not null |
| 73 | +); |
| 74 | + |
| 75 | +create table users |
| 76 | +( |
| 77 | + user_id int auto_increment |
| 78 | + primary key, |
| 79 | + created_at datetime(6) not null |
| 80 | +); |
| 81 | + |
| 82 | +create table wallet |
| 83 | +( |
| 84 | + wallet_id bigint auto_increment |
| 85 | + primary key, |
| 86 | + account_id int not null, |
| 87 | + buy_price double null, |
| 88 | + roi double null, |
| 89 | + size double not null, |
| 90 | + ticker varchar(10) not null |
| 91 | +); |
| 92 | + |
| 93 | + |
| 94 | + |
| 95 | +INSERT INTO `if`.users (user_id, created_at) VALUES (1, '2025-05-16 09:30:00.000000'); |
| 96 | +INSERT INTO `if`.users (user_id, created_at) VALUES (2, '2025-05-16 09:30:00.000000'); |
| 97 | + |
| 98 | +INSERT INTO `if`.account (account_id, cash, user_id) VALUES (1, 0, 1); |
| 99 | +INSERT INTO `if`.account (account_id, cash, user_id) VALUES (2, 500000000, 2); |
| 100 | + |
| 101 | +INSERT INTO `if`.asset (ticker, name) VALUES ('BTC', '비트코인'); |
| 102 | +INSERT INTO `if`.asset (ticker, name) VALUES ('TRUMP', '오피셜트럼프'); |
| 103 | + |
| 104 | +INSERT INTO `if`.wallet (wallet_id, account_id, buy_price, roi, size, ticker) VALUES (1, 1, 0, 0, 500000000, 'BTC'); |
| 105 | +INSERT INTO `if`.wallet (wallet_id, account_id, buy_price, roi, size, ticker) VALUES (2, 1, 0, 0, 500000000, 'TRUMP'); |
| 106 | + |
0 commit comments