-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdatabase.sql
130 lines (110 loc) · 4.75 KB
/
database.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
-- -- USER is a reserved keyword with Postgres
-- -- You must use double quotes in every query that user is in:
-- -- ex. SELECT * FROM "user";
-- -- Otherwise you will have errors!
-- Create a database with the name "intersection" then create the following tables
-- You should be able to run the whole table when making changes. If DROP TABLE commands yell
-- At you about tables not existing, simply highlight everything below
DROP TABLE "media";
DROP TABLE "team_user";
DROP TABLE "item";
DROP TABLE "messages";
DROP TABLE "client";
DROP TABLE "team";
DROP TABLE "user";
CREATE TABLE "user" (
"id" SERIAL PRIMARY KEY,
"username" VARCHAR (80) UNIQUE NOT NULL,
"password" VARCHAR (1000) NOT NULL,
"first_name" VARCHAR(255),
"last_name" VARCHAR(255),
"email" VARCHAR(255),
"phone" VARCHAR(15),
"street_address" VARCHAR(255),
"city" VARCHAR(255),
"state" VARCHAR(255),
"zip" INT,
"access_level" INT,
"date_registered" TIMESTAMP with time zone,
"active_team" INT
);
CREATE TABLE "team" (
"id" SERIAL PRIMARY KEY,
"captain_name" VARCHAR(255),
"is_archived" BOOLEAN,
"date" TIMESTAMP with time zone
);
CREATE TABLE "client" (
"id" SERIAL PRIMARY KEY,
"name" VARCHAR(255),
"bio" TEXT,
"media_release" TEXT,
"location" VARCHAR(255),
"date" TIMESTAMP with time zone,
"team_id" INT REFERENCES "team",
"comment" VARCHAR(2000)
);
CREATE TABLE "team_user" (
"id" SERIAL PRIMARY KEY,
"team_id" INT REFERENCES "team",
"user_id" INT REFERENCES "user"
);
CREATE TABLE "item" (
"id" SERIAL PRIMARY KEY,
"name" VARCHAR(255),
"client_id" INT REFERENCES "client",
"team_id" INT REFERENCES "team",
"purchased" BOOLEAN
);
CREATE TABLE "media" (
"id" SERIAL PRIMARY KEY,
"client_id" INT,
"link" VARCHAR(255),
"type" VARCHAR(255),
"metadata" VARCHAR(255),
"date" TIMESTAMP with time zone,
"user_id" INT REFERENCES "user"
);
CREATE TABLE "messages" (
"id" SERIAL PRIMARY KEY,
"client_id" INT REFERENCES "client",
"user_id" INT REFERENCES "user",
"team_id" INT REFERENCES "team",
"message" TEXT,
"date" TIMESTAMP with time zone
);
-- Dummy Data
INSERT INTO "user" ("username", "password", "first_name", "last_name", "email", "phone", "street_address", "city", "state", "zip", "access_level", "date_registered", "active_team")
VALUES ('Gabe', '$2a$10$FMWf/Zx934b0QbqoiCSuoO0PJ5M273f/10pffwxo8GpvQN6Usx0gm', 'Gabriel', 'Hawk', 'ghawk@gmail.com', '474-751-1642', '5642 Main St', 'Redwood', 'MN', '55415', 1, NOW(), 1),
('Meghan', '$2a$10$cghoHshxw31jgKsRAYt02OUmthPdlMdaFIRosVaCXaZGLYWcc.v.C', 'Meghan', 'Gunderson', 'mgunderson@gmail.com', '474-973-4260', '3246 Broadway Ave', 'Minneapolis', 'MN', '55415', 1, NOW(), 2),
('Jessica', '$2a$10$.xLq2xwq9MS9EYRFI/h0vOkyFL277eTASomppCYonYXVcASBMZqPC', 'Jessica', 'Heggem', 'jheggem@gmail.com', '785-424-9078', '7890 63rd St N', 'Bloomington', 'MN', '55457', 2, NOW(), 1),
('Tou', '$2a$10$x4GLDwPSqx3dLw8qHzlHzeFX4nxTN4GN7i5z5phjpPe3jdPe4iB.G', 'Tou', 'Xiong', 'txiiong@gmail.com', '890-257-5631', '560 Lake St', 'Edina', 'MN', '55424', 2, NOW(), 2),
('Amber', '$2a$10$sfTE8trmDX6RH3Whr3KTdeyWqx4JT2cS5RFyGc0tW9JhYkG5e.NwG', 'Amber', 'Volkmann', 'avolkmann@gmail.com', '423-746-8952', '2683 Cherrywood Ln', 'Austin', 'TX', '55672', 1, NOW(), 1),
('Andrea', '$2a$10$SZzb5ITs2wV4tE1Ei1vK5ectds/YdzFNK9PIddBaocazPkaakJnuu', 'Andrea', 'Bert', 'abert@gmail.com', '907-363-1568', '6340 Stonebroke Rd', 'Appleton', 'WI', '55678', 3, NOW(), 0),
('Billy', '$2a$10$SZzb5ITs2wV4tE1Ei1vK5ectds/YdzFNK9PIddBaocazPkaakJnuu', 'Billy', 'Johnson', 'bjohnson@gmail.com', '774-236-5076', '230 Oakwood Blvd', 'Roseville', 'MN', '55498', 1, NOW(), 0);
INSERT INTO "team" ("captain_name", "is_archived", "date")
VALUES ('Jessica Heggem', FALSE, NOW()),
('Tou Xiong', FALSE, NOW());
INSERT INTO "team_user" ("team_id", "user_id")
VALUES (1, 3),
(2, 4),
(1, 5),
(2, 2),
(1, 1);
INSERT INTO "client" ("name", "bio", "media_release", "location", "date", "team_id", "comment")
VALUES ('Caleb', 'Has been homeless for 2 years', NULL, 'St. Paul', NOW(), 1, NULL),
('Georgie', 'Single Mother. Lost job last year. Evicted 6 months ago.', NULL, 'Minneapolis', NOW(), 1, 'What color for the jacket?');
INSERT INTO "media" ("client_id", "link", "type", "metadata", "date", "user_id")
VALUES (2, 'image.png', 'img', NULL, NOW(), 3),
(2, 'download.jpeg', 'img', NULL, NOW(), 3),
(2, 'Untitled.png', 'img', NULL, NOW(), 3);
INSERT INTO "item" ("name", "client_id", "team_id", "purchased")
VALUES
('Kid size winter coat', '2', '1', 'false'),
('School backpack', '2', '1', 'true'),
('Tent', '2', '1', 'true'),
('2 sleeping bags', '2', '1', 'true');
INSERT INTO "messages" ("client_id", "user_id", "team_id", "message", "date")
VALUES (1, 1, 1, 'First chat message, should be Gabe', NOW()),
(1, 3, 1, 'Second chat message, should be Jessica', NOW()),
(1, 5, 1, 'Second chat message, should be Amber', NOW());