-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathschema.sql
36 lines (29 loc) · 1.09 KB
/
schema.sql
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
drop schema if exists test cascade;
create schema test;
create table test.users (id bigint primary key, name varchar(128));
insert into test.users(id,name)
select g, 'user ' || g::varchar
from generate_series(1,1000000) g;
create table test.accounts (
id bigserial primary key,
user_id bigint references test.users(id),
currency varchar(4),
amount numeric
);
insert into test.accounts (user_id, currency, amount)
select user_id,
x.currency,
random() * case
when x.currency = 'BTC' then 1
when x.currency = 'ETH' then 10
when x.currency = 'PTU' then 50000
when x.currency = 'IDRT' then 300000000
end as amount
from generate_series(1,1000000) user_id
cross join (select unnest as currency from unnest('{BTC,ETH,PTU,IDRT}'::varchar[])) x;
create table test.idr_rate (currency varchar(4), rate numeric);
insert into test.idr_rate(currency, rate) values
('IDRT', 1),
('BTC', 317000000),
('ETH', 23000000),
('PTU', 6000);