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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
|
--
-- PostgreSQL database dump
--
-- Dumped from database version 17.2
-- Dumped by pg_dump version 17.2
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET transaction_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;
--
-- Name: pgcrypto; Type: EXTENSION; Schema: -; Owner: -
--
CREATE EXTENSION IF NOT EXISTS pgcrypto WITH SCHEMA public;
--
-- Name: EXTENSION pgcrypto; Type: COMMENT; Schema: -; Owner:
--
COMMENT ON EXTENSION pgcrypto IS 'cryptographic functions';
--
-- Name: assignment_state; Type: TYPE; Schema: public; Owner: postgres
--
CREATE TYPE public.assignment_state AS ENUM (
'AWAITING_GARDENER_NOTIFICATION',
'AWAITING_FINISH',
'AWAITING_WATERMARKING',
'AWAITING_OWNER_NOTIFICATION',
'DONE'
);
ALTER TYPE public.assignment_state OWNER TO postgres;
--
-- Name: TYPE assignment_state; Type: COMMENT; Schema: public; Owner: postgres
--
COMMENT ON TYPE public.assignment_state IS 'The states for an assignment.';
--
-- Name: role; Type: TYPE; Schema: public; Owner: postgres
--
CREATE TYPE public.role AS ENUM (
'gardener',
'owner'
);
ALTER TYPE public.role OWNER TO postgres;
--
-- Name: TYPE role; Type: COMMENT; Schema: public; Owner: postgres
--
COMMENT ON TYPE public.role IS 'The role of a user within the system.';
SET default_tablespace = '';
SET default_table_access_method = heap;
--
-- Name: assignments; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.assignments (
id integer NOT NULL,
gardener_id integer NOT NULL,
cemetary_plot_id integer NOT NULL,
date date,
state public.assignment_state DEFAULT 'AWAITING_GARDENER_NOTIFICATION'::public.assignment_state NOT NULL,
note text
);
ALTER TABLE public.assignments OWNER TO postgres;
--
-- Name: COLUMN assignments.note; Type: COMMENT; Schema: public; Owner: postgres
--
COMMENT ON COLUMN public.assignments.note IS 'When an assignment is finished, the gardener can supply a note.';
--
-- Name: assignments_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
ALTER TABLE public.assignments ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY (
SEQUENCE NAME public.assignments_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
--
-- Name: cemetary_plots; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.cemetary_plots (
id integer NOT NULL,
address text NOT NULL,
owner_id integer NOT NULL,
assignment_interval interval day DEFAULT '14 days'::interval NOT NULL
);
ALTER TABLE public.cemetary_plots OWNER TO postgres;
--
-- Name: COLUMN cemetary_plots.assignment_interval; Type: COMMENT; Schema: public; Owner: postgres
--
COMMENT ON COLUMN public.cemetary_plots.assignment_interval IS 'The interval between when cleaning assignments. If there was a job at time N, the next one would be at N + assignment_interval.';
--
-- Name: cementary_plots_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
ALTER TABLE public.cemetary_plots ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY (
SEQUENCE NAME public.cementary_plots_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
--
-- Name: images; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.images (
id integer NOT NULL,
s3_path text NOT NULL,
original_filename text NOT NULL,
assignment_id integer
);
ALTER TABLE public.images OWNER TO postgres;
--
-- Name: TABLE images; Type: COMMENT; Schema: public; Owner: postgres
--
COMMENT ON TABLE public.images IS 'This table stores the images uploaded when finishing an assignment.';
--
-- Name: COLUMN images.assignment_id; Type: COMMENT; Schema: public; Owner: postgres
--
COMMENT ON COLUMN public.images.assignment_id IS 'Reference to the owning assignment';
--
-- Name: images_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
ALTER TABLE public.images ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY (
SEQUENCE NAME public.images_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
--
-- Name: sessions; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.sessions (
token text NOT NULL,
user_id integer NOT NULL,
expires_at timestamp with time zone NOT NULL
);
ALTER TABLE public.sessions OWNER TO postgres;
--
-- Name: users; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.users (
id integer NOT NULL,
role public.role NOT NULL,
first_name text NOT NULL,
last_name text NOT NULL,
password_hash text NOT NULL,
email text
);
ALTER TABLE public.users OWNER TO postgres;
--
-- Name: COLUMN users.password_hash; Type: COMMENT; Schema: public; Owner: postgres
--
COMMENT ON COLUMN public.users.password_hash IS 'Hash of password + salt.';
--
-- Name: users_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
ALTER TABLE public.users ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY (
SEQUENCE NAME public.users_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
--
-- Data for Name: assignments; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.assignments (id, gardener_id, cemetary_plot_id, date, state, note) FROM stdin;
2 1 2 2025-03-05 AWAITING_GARDENER_NOTIFICATION \N
1 1 1 2025-02-28 AWAITING_WATERMARKING \N
\.
--
-- Data for Name: cemetary_plots; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.cemetary_plots (id, address, owner_id, assignment_interval) FROM stdin;
1 24B, Kirkevej 64, Egå 8328 4 21 days
2 26C, Kirkevej 64, Egå 8328 5 14 days
\.
--
-- Data for Name: images; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.images (id, s3_path, original_filename, assignment_id) FROM stdin;
3 fe5e7c27-99c4-4d4b-ba77-fcad5c6607e3 eva.jpeg 1
\.
--
-- Data for Name: sessions; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.sessions (token, user_id, expires_at) FROM stdin;
je2bic5i5jou7woob4ehreoqojuir4co 1 2025-03-19 18:04:35.904+01
27ghlb4vzh543kxpnkniip2oai6q4dvx 1 2025-03-19 18:04:47.722+01
bjt7wgbfrlzrg7fhphsxezpc7fornezv 1 2025-03-19 20:42:57.838+01
bgrgdtxmiq44ig6dh32pop4wkterqj6r 1 2025-03-20 18:03:54.199+01
q6ifvlkjdoncw5usnb37da3sf4y3fxyq 1 2025-03-20 20:01:53.318+01
\.
--
-- Data for Name: users; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.users (id, role, first_name, last_name, password_hash, email) FROM stdin;
1 gardener Emil Blomst $2a$06$vw1iVTLDQzeUwmhyW17ZzeJL.gyC4xWWzAwvJO8dsZi7Jdg2w5zbu emil@eksempel.dk
2 gardener Sarah Hækkesen $2a$06$RyzzMad/jmKZwg9hRDymCO/KvxiSUFcdYQZdxB9trHHOU3tKhtFIK sarah.hækkesen@kirkefætrene.dk
3 gardener Sten Graversen $2a$06$/InJ2HFv1/z0YVXMwoHWZuV7aTlWl3GH9csKEvN5gb4nEPSECEdFq wad@gaidefar.com
4 owner Lotte Ejersen $2a$06$C1JTdp2y9lIO57S7kGsBruE2oLj87AYpNNrZqx/5Zgap5lqcDj.my l.ejersen@eksempel.dk
5 owner Mads Hylgaard Jensen $2a$06$FuFHsoFo1cPJ9ms9TceVG..2BAHAyJpE2NyBUTH9JnG6v8GWuOh4u mads@wraaath.xyz
6 owner Lukas Ibasen $2a$06$p2nOFXtLC0YE/7TTxqzUOeEfpPKVjVZr2sge1KBFT/7lrx2rpsvO2 contact@ibsenware.xyz
\.
--
-- Name: assignments_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.assignments_id_seq', 2, true);
--
-- Name: cementary_plots_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.cementary_plots_id_seq', 2, true);
--
-- Name: images_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.images_id_seq', 3, true);
--
-- Name: users_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.users_id_seq', 6, true);
--
-- Name: assignments assignments_id_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.assignments
ADD CONSTRAINT assignments_id_pkey PRIMARY KEY (id);
--
-- Name: cemetary_plots cemetary_plots_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.cemetary_plots
ADD CONSTRAINT cemetary_plots_pkey PRIMARY KEY (id);
--
-- Name: users email_uniqueness; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.users
ADD CONSTRAINT email_uniqueness UNIQUE (email);
--
-- Name: CONSTRAINT email_uniqueness ON users; Type: COMMENT; Schema: public; Owner: postgres
--
COMMENT ON CONSTRAINT email_uniqueness ON public.users IS 'Multiple users cannot have the same email.';
--
-- Name: images images_s3_path_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.images
ADD CONSTRAINT images_s3_path_key UNIQUE (s3_path);
--
-- Name: sessions sessions_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.sessions
ADD CONSTRAINT sessions_pkey PRIMARY KEY (token);
--
-- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.users
ADD CONSTRAINT users_pkey PRIMARY KEY (id);
--
-- Name: assignments assignments_cemetary_plot_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.assignments
ADD CONSTRAINT assignments_cemetary_plot_id_fkey FOREIGN KEY (cemetary_plot_id) REFERENCES public.cemetary_plots(id);
--
-- Name: assignments assignments_gardener_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.assignments
ADD CONSTRAINT assignments_gardener_id_fkey FOREIGN KEY (gardener_id) REFERENCES public.users(id);
--
-- Name: cemetary_plots cemetary_plots_owner_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.cemetary_plots
ADD CONSTRAINT cemetary_plots_owner_id_fkey FOREIGN KEY (owner_id) REFERENCES public.users(id);
--
-- Name: images images_assignment_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.images
ADD CONSTRAINT images_assignment_id_fkey FOREIGN KEY (assignment_id) REFERENCES public.assignments(id) ON UPDATE CASCADE ON DELETE CASCADE;
--
-- Name: sessions sessions_userid_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.sessions
ADD CONSTRAINT sessions_userid_fkey FOREIGN KEY (user_id) REFERENCES public.users(id);
--
-- PostgreSQL database dump complete
--
|