-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.sql
More file actions
81 lines (65 loc) · 2.09 KB
/
Copy pathinit.sql
File metadata and controls
81 lines (65 loc) · 2.09 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
DROP TABLE IF EXISTS transactions;
DROP TABLE IF EXISTS customers;
DROP TABLE IF EXISTS features;
DROP TABLE IF EXISTS experiments;
DROP TABLE IF EXISTS rules;
DROP TABLE IF EXISTS postprocessed_transactions;
CREATE TABLE IF NOT EXISTS transactions (
transaction_id BIGINT,
from_customer_id BIGINT,
to_customer_id BIGINT,
created_at BIGINT,
amount FLOAT,
latitude FLOAT,
longitude FLOAT,
record_created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE INDEX transaction_from_customer_id_index ON transactions(from_customer_id);
CREATE INDEX transaction_to_customer_id_index ON transactions(to_customer_id);
CREATE TABLE IF NOT EXISTS customers (
customer_id BIGINT PRIMARY KEY,
created_at BIGINT,
name VARCHAR,
ssn VARCHAR,
date_of_birth VARCHAR,
email VARCHAR,
latitude VARCHAR,
longitude VARCHAR,
record_created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE UNIQUE INDEX customers_customer_id ON customers(customer_id);
COPY customers(customer_id, created_at, name, ssn, date_of_birth, email, latitude, longitude)
FROM '/docker-entrypoint-initdb.d/customers.csv'
DELIMITER ','
CSV HEADER;
CREATE TABLE IF NOT EXISTS features (
customer_id BIGINT PRIMARY KEY,
features VARCHAR,
record_created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE UNIQUE INDEX features_customer_id ON features(customer_id);
CREATE TABLE IF NOT EXISTS experiments (
experiment_id SERIAL PRIMARY KEY,
experiment BYTEA,
active BOOLEAN,
record_created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE IF NOT EXISTS rules (
rule_id SERIAL PRIMARY KEY,
rule BYTEA,
active BOOLEAN,
record_created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE IF NOT EXISTS postprocessed_transactions (
start_window TIMESTAMP,
end_window TIMESTAMP,
transaction_type VARCHAR,
amount_bucket VARCHAR,
rules VARCHAR,
experiments VARCHAR,
attempted_transactions INT,
approved_transactions INT,
attempted_amount FLOAT,
approved_amount FLOAT,
record_created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);