-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.sql
38 lines (35 loc) · 1.26 KB
/
init.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
37
38
CREATE TABLE IF NOT EXISTS spenders (
"spender_id" serial4 UNIQUE PRIMARY KEY NOT NULL,
"name" varchar(255) NOT NULL,
"email" text,
"created_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
"used_flg" bool DEFAULT true
);
CREATE TABLE IF NOT EXISTS transactions (
"transaction_id" serial4 UNIQUE PRIMARY KEY NOT NULL,
"date" TIMESTAMP NOT NULL,
"amount" float,
"category" int,
"transaction_type" int,
"note" text,
"image_url" text,
"spender_id" int,
"created_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
"used_flg" bool DEFAULT true
);
CREATE TABLE IF NOT EXISTS categories (
"category_id" serial4 UNIQUE PRIMARY KEY NOT NULL,
"category" text,
"created_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
"used_flg" bool DEFAULT true
);
CREATE TABLE IF NOT EXISTS transaction_types (
"transaction_type_id" serial4 UNIQUE PRIMARY KEY NOT NULL,
"type" text,
"created_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
"used_flg" bool DEFAULT true
);