forked from KingmanDouglass/IFT_Group
-
Notifications
You must be signed in to change notification settings - Fork 1
/
database.sql
executable file
·159 lines (142 loc) · 4.27 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
-- create a database table titled immigrant_families
-- 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 TABLE "user" (
"id" SERIAL PRIMARY KEY,
"username" VARCHAR (80) UNIQUE NOT NULL,
"password" VARCHAR (1000) NOT NULL,
"phone" VARCHAR (80),
"email" VARCHAR (100),
"encrypted" VARCHAR(100),
"address" VARCHAR (200),
"skills" VARCHAR (500),
"second_language" VARCHAR (100),
"admin" VARCHAR (80),
"first_name" VARCHAR (100),
"last_name" VARCHAR (100)
);
CREATE TABLE "cases" (
"id" SERIAL PRIMARY KEY,
"case_last_name" VARCHAR(200),
"case_number" VARCHAR(100),
"status" VARCHAR(100)
);
CREATE TABLE "users_cases" (
"id" SERIAL PRIMARY KEY,
"user_id" INT REFERENCES "user",
"case_id" INT REFERENCES "cases"
);
CREATE TABLE "aid" (
"id" SERIAL PRIMARY KEY,
"case_id" INT REFERENCES "cases",
"grocery_program" BOOLEAN,
"grocery_program_volunteer" VARCHAR(200),
"go_fund_me" VARCHAR(200),
"social_worker" VARCHAR(200),
"social_worker_phone" VARCHAR(50)
);
CREATE TABLE "events" (
"id" SERIAL PRIMARY KEY,
"case_id" INT REFERENCES "cases",
"date" DATE,
"description" VARCHAR(2000)
);
CREATE TABLE "housing" (
"id" SERIAL PRIMARY KEY,
"case_id" INT REFERENCES "cases",
"address" VARCHAR (200),
"rent" VARCHAR (100),
"paid_by" VARCHAR (100),
"utilities" VARCHAR (100),
"living_with_fam" VARCHAR(100)
);
CREATE TABLE "legal_status" (
"id" SERIAL PRIMARY KEY,
"case_id" INT REFERENCES "cases",
"last_court_date" DATE,
"last_court_date_outcome" VARCHAR(2000),
"next_court_date" DATE,
"next_court_date_outcome" VARCHAR(2000),
"asylum_application" BOOLEAN,
"work_authorization" BOOLEAN
);
CREATE TABLE "legal" (
"id" SERIAL PRIMARY KEY,
"case_id" INT REFERENCES "cases",
"ice_facility" VARCHAR(200),
"bond_amount" INT,
"bond_paid_date" DATE,
"bond_paid_by" VARCHAR(200),
"foster_facility" VARCHAR(200),
"foster_facility_address" VARCHAR(700),
"attorney" VARCHAR(200),
"attorney_phone" VARCHAR(200),
"attorney_fee" VARCHAR(200),
"legal_status_id" INT REFERENCES "legal_status",
"legal_notes" VARCHAR(2000)
);
CREATE TABLE "medical" (
"id" SERIAL PRIMARY KEY,
"case_id" INT REFERENCES "cases",
"doctor_name" VARCHAR(200),
"doctor_phone" VARCHAR(100),
"medical_conditions" VARCHAR(2000),
"counselor" VARCHAR(2000),
"counselor_phone" VARCHAR(100),
"pediatrician" VARCHAR(2000),
"pediatrician_phone" VARCHAR(100),
"optometrist" VARCHAR(2000),
"optometrist_phone" VARCHAR(100),
"dentist" VARCHAR(2000),
"dentist_phone" VARCHAR(100),
"vaccinations" VARCHAR(2000),
"insurance_card_info" VARCHAR(2000),
"fee_coverage" BOOLEAN,
"medical_notes" VARCHAR(2000)
);
CREATE TABLE "notes" (
"id" SERIAL PRIMARY KEY,
"case_id" INT REFERENCES "cases",
"family_notes" VARCHAR(2000),
"date" VARCHAR(50)
);
CREATE TABLE "primary_children" (
"id" SERIAL PRIMARY KEY,
"case_id" INT REFERENCES "cases",
"child_name" VARCHAR(200),
"child_dob" VARCHAR(200),
"child_info" VARCHAR(2000)
);
CREATE TABLE "primary_individual" (
"id" SERIAL PRIMARY KEY,
"case_id" INT REFERENCES "cases",
"last_name" VARCHAR (100),
"first_name" VARCHAR (100),
"dob" DATE,
"spouse_first_name" VARCHAR(100),
"spouse_dob" VARCHAR(50),
"phone" VARCHAR (80),
"email" VARCHAR (100),
"address" VARCHAR (1000),
"utlities" VARCHAR (100),
"rent" INT,
"rent_paid_by" VARCHAR(100),
"housing_notes" VARCHAR(2000),
"living_with_family" BOOLEAN,
"referred_by" VARCHAR (500),
"reference_date" DATE,
"passport" BOOLEAN,
"us_id" BOOLEAN,
"encrypted" VARCHAR (200)
);
CREATE TABLE "school" (
"id" SERIAL PRIMARY KEY,
"case_id" INT REFERENCES "cases",
"name" VARCHAR (200),
"phone" VARCHAR (20),
"email" VARCHAR (100)
);
INSERT INTO "user" ("username", "first_name", "last_name", "password", "phone", "email", "encrypted", "address", "skills", "second_language", "admin" )
VALUES ('Test User', 'Initial', 'User', '$2b$10$JPYYlg9aWjGVVjcDFfrIVeRlK2ZLyVth56E7b/q2PPmlzDbWpWQ1m', '', '', '', '', '', '', 'yes');