This repository was archived by the owner on Apr 18, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathzapit-ddl.sql
More file actions
69 lines (63 loc) · 2.16 KB
/
zapit-ddl.sql
File metadata and controls
69 lines (63 loc) · 2.16 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
create database zapit;
use zapit;
create table location_data
(
id integer auto_increment,
latitude decimal(13, 10) not null,
longitude decimal(13, 10) not null,
primary key (id)
);
create table users
(
id integer auto_increment,
email varchar(128) not null unique,
display_name varchar(32) not null unique,
password varchar(72) not null,
first_name varchar(32),
last_name varchar(32),
roles varchar(255) not null default 'ROLE_USER',
is_deleted boolean not null default false,
created_on timestamp not null default current_timestamp,
updated_on timestamp on update current_timestamp,
primary key (id)
);
create table merchants
(
id integer auto_increment,
name varchar(64) not null unique,
website varchar(64) not null,
address varchar(128) not null,
post_code varchar(32) not null,
is_deleted boolean not null default false,
created_by integer not null unique,
created_on timestamp not null default current_timestamp,
updated_on timestamp on update current_timestamp,
primary key (id),
foreign key (created_by) references users (id)
);
create table cards
(
id varchar(36),
user integer not null,
balance decimal(13, 4) not null,
is_deleted boolean not null default false,
issued_by integer not null,
created_on timestamp not null default current_timestamp,
updated_on timestamp on update current_timestamp,
primary key (id),
foreign key (user) references users (id),
foreign key (issued_by) references merchants (id)
);
create table transactions
(
id integer auto_increment,
card varchar(36) not null,
amount decimal(13, 4) not null,
status boolean not null default false,
location_data integer,
created_on timestamp not null default current_timestamp,
updated_on timestamp on update current_timestamp,
primary key (id),
foreign key (card) references cards (id),
foreign key (location_data) references location_data (id)
);