forked from CodesmithLLC-Danger-Noodle/PocketS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtransactions_postgres_create.sql
49 lines (42 loc) · 1.69 KB
/
transactions_postgres_create.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
39
40
41
42
43
44
45
46
47
48
49
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;
CREATE TABLE public.transactions (
"_id" serial NOT NULL,
"name" varchar NOT NULL,
"amount" DECIMAL(19, 2) NOT NULL,
"date" varchar,
"category_id" bigint,
CONSTRAINT "transactions_pk" PRIMARY KEY ("_id")
) WITH (
OIDS=FALSE
);
CREATE TABLE public.categories (
"_id" serial NOT NULL,
"category" varchar NOT NULL,
CONSTRAINT "categories_pk" PRIMARY KEY ("_id")
) WITH (
OIDS=FALSE
);
ALTER TABLE public.transactions ADD CONSTRAINT "transactions_fk0" FOREIGN KEY ("category_id") REFERENCES public.categories("_id")
INSERT INTO public.categories VALUES (1, 'test');
INSERT INTO public.categories VALUES (2, 'Housing/Rent');
INSERT INTO public.categories VALUES (3, 'Utilities');
INSERT INTO public.categories VALUES (4, 'Gas');
INSERT INTO public.categories VALUES (5, 'Groceries');
INSERT INTO public.categories VALUES (6, 'Dining Out');
INSERT INTO public.categories VALUES (7, 'Drinks');
INSERT INTO public.categories VALUES (8, 'Entertainment');
INSERT INTO public.categories VALUES (9, 'Savings');
INSERT INTO public.categories VALUES (10, 'Other');
-- INSERT INTO public.transactions VALUES (999, 'idk', 123.45, '10/18/2021', 6);
-- To Delete all transactions, uncomment delete and run command:
-- DELETE FROM public.transactions
-- psql -d postgres://faojdvgu:[email protected]/faojdvgu -f transactions_postgres_create.sql