-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheatogather.sql
48 lines (40 loc) · 1.21 KB
/
eatogather.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
SELECT pg_terminate_backend(pg_stat_activity.pid)
FROM pg_stat_activity
WHERE pg_stat_activity.datname = 'eatogather'
AND pid <> pg_backend_pid();
DROP DATABASE IF EXISTS eatogather;
CREATE DATABASE eatogather;
\c eatogather;
CREATE TABLE hmfs (
ID bigserial PRIMARY KEY,
password text NOT NULL,
email text UNIQUE,
firstName text NOT NULL,
lastName text NOT NULL,
gender bit(1) NOT NULL,
phone text UNIQUE,
bio text,
location text,
image text
);
INSERT INTO hmfs ( password, email, gender, firstName, lastName, phone, bio, location, image )
VALUES ('Azeem', '[email protected]', B'1', 'Azeem', 'Akhter', '1234123', NULL, NULL, NULL);
CREATE TABLE feasts (
ID bigserial PRIMARY KEY,
uid bigserial REFERENCES hmfs(ID) ON DELETE CASCADE,
description text NOT NULL,
title text NOT NULL,
location text NOT NULL,
tags text,
created_at timestamptz NOT NULL DEFAULT now(),
datetime timestamptz NOT NULL,
noofguest int4 NOT NULL
);
CREATE TABLE hostfeast (
uid bigserial REFERENCES hmfs(ID) on DELETE CASCADE,
fid bigserial REFERENCES feasts(ID) on DELETE CASCADE,
created_at timestamptz NOT NULL DEFAULT now(),
note text,
approved bit(1) NOT NULL,
PRIMARY KEY (uid, fid)
);