-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
database-20240119.sql
64 lines (60 loc) · 1.33 KB
/
database-20240119.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
-- UPDATE SCRIPT FOR EXISTING INSTANCES --
BEGIN;
ALTER TABLE tbl_ticket ADD COLUMN watcherid _text;
CREATE TABLE "public"."tbl_ticket_backup" (
"id" text NOT NULL,
"ticketid" text,
"userid" text,
"markdown" text,
"ip" text,
"ua" text,
"dtcreated" timestamp DEFAULT timezone('utc'::text, now()),
CONSTRAINT "tbl_ticket_backup_ticketid_fkey" FOREIGN KEY ("ticketid") REFERENCES "public"."tbl_ticket"("id") ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT "tbl_ticket_backup_userid_fkey" FOREIGN KEY ("userid") REFERENCES "public"."tbl_user"("id") ON DELETE SET NULL ON UPDATE CASCADE,
PRIMARY KEY ("id")
);
DROP VIEW view_ticket;
CREATE VIEW view_ticket AS
SELECT
a.id,
a.folderid,
a.ownerid,
a.statusid,
a.parentid,
a.userid,
a.watcherid,
a.name,
a.worked,
a.estimate,
a.comments,
a.ispriority,
b.name AS folder,
b.color AS folder_color,
b.icon AS folder_icon,
a.attachments,
a.tags,
a.date,
a.dtstatus,
a.dtupdated,
a.deadline,
a.isbillable,
d.name AS status,
d.sortindex,
d.icon AS status_icon,
d.color AS status_color,
a.search,
b.isprivate,
a.html,
a.dtparent,
a.dtcreated,
a.reference,
a.source,
a.markdown,
a.ispublic,
a.note
FROM tbl_ticket a
LEFT JOIN tbl_folder b ON b.id = a.folderid
LEFT JOIN cl_status d ON d.id = a.statusid
WHERE
a.isremoved = false;
COMMIT;