-
Notifications
You must be signed in to change notification settings - Fork 165
Expand file tree
/
Copy pathinit.sql
More file actions
47 lines (40 loc) · 1.92 KB
/
init.sql
File metadata and controls
47 lines (40 loc) · 1.92 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
CREATE DATABASE IF NOT EXISTS vouchers;
USE vouchers;
CREATE TABLE customers (
customer_id BINARY(16),
customer_name VARCHAR(30),
customer_type VARCHAR(30),
created_at datetime(6) not null ,
updated_at datetime(6) DEFAULT null,
CONSTRAINT customer_pk PRIMARY KEY(customer_id)
);
CREATE TABLE vouchers (
voucher_id BINARY(16),
discount_value BIGINT,
voucher_type VARCHAR(30),
customer_id BINARY(16),
created_at datetime(6) not null ,
updated_at datetime(6) DEFAULT null,
CONSTRAINT voucher_pk PRIMARY KEY(voucher_id),
CONSTRAINT voucher_fk FOREIGN KEY (customer_id) REFERENCES customers (customer_id)
);
CREATE DATABASE IF NOT EXISTS vouchers_test;
USE vouchers_test;
CREATE TABLE customers (
customer_id BINARY(16),
customer_name VARCHAR(30),
customer_type VARCHAR(30),
created_at datetime(6) not null ,
updated_at datetime(6) DEFAULT null,
CONSTRAINT customer_pk PRIMARY KEY(customer_id)
);
CREATE TABLE vouchers (
voucher_id BINARY(16),
discount_value BIGINT,
voucher_type VARCHAR(30),
customer_id BINARY(16),
created_at datetime(6) not null ,
updated_at datetime(6) DEFAULT null,
CONSTRAINT voucher_pk PRIMARY KEY(voucher_id),
CONSTRAINT voucher_fk FOREIGN KEY (customer_id) REFERENCES customers (customer_id)
);