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