@opengis/fastify-table 1.1.12 → 1.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -26
- package/config.js +10 -10
- package/cron/controllers/cronApi.js +22 -22
- package/cron/controllers/utils/cronList.js +1 -1
- package/cron/funcs/addCron.js +131 -131
- package/cron/index.js +10 -10
- package/crud/controllers/utils/checkXSS.js +45 -45
- package/crud/controllers/utils/xssInjection.js +72 -72
- package/crud/funcs/getToken.js +27 -27
- package/crud/funcs/isFileExists.js +13 -13
- package/crud/funcs/setToken.js +53 -53
- package/notification/controllers/testEmail.js +49 -49
- package/notification/funcs/utils/sendEmail.js +39 -39
- package/notification/index.js +38 -38
- package/package.json +1 -1
- package/pg/funcs/getPG.js +30 -30
- package/redis/funcs/getRedis.js +23 -23
- package/server/migrations/crm.sql +150 -150
- package/server/migrations/log.sql +80 -80
- package/server.js +14 -14
- package/table/controllers/card.js +44 -44
- package/table/controllers/form.js +28 -28
- package/table/controllers/utils/getTemplatePath.js +1 -1
- package/test/api/crud.xss.test.js +72 -72
- package/test/api/notification.test.js +37 -37
- package/test/config.example +18 -18
- package/test/funcs/pg.test.js +34 -34
- package/test/funcs/redis.test.js +19 -19
- package/test/templates/cls/test.json +9 -9
- package/test/templates/form/cp_building.form.json +32 -32
- package/test/templates/select/account_id.json +3 -3
- package/test/templates/select/storage.data.json +2 -2
- package/test/templates/table/gis.dataset.table.json +20 -20
- package/util/controllers/logger.file.js +90 -90
- package/util/controllers/next.id.js +4 -4
- package/util/controllers/properties.get.js +19 -19
- package/util/controllers/utils/checkUserAccess.js +19 -19
- package/util/controllers/utils/getRootDir.js +20 -20
- package/util/index.js +23 -23
|
@@ -1,150 +1,150 @@
|
|
|
1
|
-
create schema if not exists crm;
|
|
2
|
-
|
|
3
|
-
-- crm.notifications
|
|
4
|
-
-- DROP TABLE IF EXISTS crm.notifications;
|
|
5
|
-
CREATE TABLE IF NOT EXISTS crm.notifications();
|
|
6
|
-
ALTER TABLE crm.notifications DROP CONSTRAINT IF EXISTS crm_notifications_pkey;
|
|
7
|
-
ALTER TABLE crm.notifications ADD COLUMN IF NOT EXISTS notification_id text NOT NULL DEFAULT next_id();
|
|
8
|
-
|
|
9
|
-
ALTER TABLE crm.notifications ADD COLUMN IF NOT EXISTS notification_user_id text;
|
|
10
|
-
ALTER TABLE crm.notifications ADD COLUMN IF NOT EXISTS notification_type text DEFAULT 'notify'::text;
|
|
11
|
-
ALTER TABLE crm.notifications ADD COLUMN IF NOT EXISTS notification_status text DEFAULT 'not sent'::text;
|
|
12
|
-
ALTER TABLE crm.notifications ADD COLUMN IF NOT EXISTS subject text;
|
|
13
|
-
ALTER TABLE crm.notifications ADD COLUMN IF NOT EXISTS body text;
|
|
14
|
-
ALTER TABLE crm.notifications ADD COLUMN IF NOT EXISTS link text;
|
|
15
|
-
|
|
16
|
-
ALTER TABLE crm.notifications ADD COLUMN IF NOT EXISTS uid text;
|
|
17
|
-
ALTER TABLE crm.notifications ADD COLUMN IF NOT EXISTS files json;
|
|
18
|
-
ALTER TABLE crm.notifications ADD COLUMN IF NOT EXISTS cdate timestamp without time zone DEFAULT (now())::timestamp without time zone;
|
|
19
|
-
ALTER TABLE crm.notifications ADD COLUMN IF NOT EXISTS editor_id text;
|
|
20
|
-
ALTER TABLE crm.notifications ADD COLUMN IF NOT EXISTS editor_date timestamp without time zone;
|
|
21
|
-
ALTER TABLE crm.notifications ADD CONSTRAINT crm_notifications_pkey PRIMARY KEY (notification_id);
|
|
22
|
-
|
|
23
|
-
-- crm.files
|
|
24
|
-
-- DROP TABLE IF EXISTS crm.files;
|
|
25
|
-
CREATE TABLE IF NOT EXISTS crm.files();
|
|
26
|
-
ALTER TABLE crm.files DROP CONSTRAINT IF EXISTS crm_files_pkey;
|
|
27
|
-
ALTER TABLE crm.files ADD COLUMN IF NOT EXISTS file_id text NOT NULL DEFAULT next_id();
|
|
28
|
-
|
|
29
|
-
ALTER TABLE crm.files ADD COLUMN IF NOT EXISTS uploaded_name text;
|
|
30
|
-
ALTER TABLE crm.files ADD COLUMN IF NOT EXISTS entity_id text; -- object_id
|
|
31
|
-
ALTER TABLE crm.files ADD COLUMN IF NOT EXISTS entity_type text; -- table_name
|
|
32
|
-
ALTER TABLE crm.files ADD COLUMN IF NOT EXISTS file_type text;
|
|
33
|
-
ALTER TABLE crm.files ADD COLUMN IF NOT EXISTS file_status numeric;
|
|
34
|
-
ALTER TABLE crm.files ADD COLUMN IF NOT EXISTS doc_type text;
|
|
35
|
-
ALTER TABLE crm.files ADD COLUMN IF NOT EXISTS subject text; -- title
|
|
36
|
-
ALTER TABLE crm.files ADD COLUMN IF NOT EXISTS size numeric;
|
|
37
|
-
ALTER TABLE crm.files ADD COLUMN IF NOT EXISTS ext text;
|
|
38
|
-
ALTER TABLE crm.files ADD COLUMN IF NOT EXISTS tags text[];
|
|
39
|
-
ALTER TABLE crm.files ADD COLUMN IF NOT EXISTS file_path text;
|
|
40
|
-
ALTER TABLE crm.files ADD COLUMN IF NOT EXISTS ismain boolean default false;
|
|
41
|
-
ALTER TABLE crm.files ADD COLUMN IF NOT EXISTS isverified boolean default false;
|
|
42
|
-
ALTER TABLE crm.files ADD COLUMN IF NOT EXISTS uid text;
|
|
43
|
-
ALTER TABLE crm.files ADD COLUMN IF NOT EXISTS files json;
|
|
44
|
-
ALTER TABLE crm.files ADD COLUMN IF NOT EXISTS cdate timestamp without time zone DEFAULT (now())::timestamp without time zone;
|
|
45
|
-
ALTER TABLE crm.files ADD COLUMN IF NOT EXISTS editor_id text;
|
|
46
|
-
ALTER TABLE crm.files ADD COLUMN IF NOT EXISTS editor_date timestamp without time zone;
|
|
47
|
-
ALTER TABLE crm.files ADD CONSTRAINT crm_files_pkey PRIMARY KEY (file_id);
|
|
48
|
-
|
|
49
|
-
-- crm.communications
|
|
50
|
-
-- DROP TABLE IF EXISTS crm.communications;
|
|
51
|
-
CREATE TABLE IF NOT EXISTS crm.communications();
|
|
52
|
-
ALTER TABLE crm.communications DROP CONSTRAINT IF EXISTS crm_communications_pkey;
|
|
53
|
-
ALTER TABLE crm.communications ADD COLUMN IF NOT EXISTS communication_id text NOT NULL DEFAULT next_id();
|
|
54
|
-
|
|
55
|
-
ALTER TABLE crm.communications ADD COLUMN IF NOT EXISTS entity_id text; -- object_id
|
|
56
|
-
ALTER TABLE crm.communications ADD COLUMN IF NOT EXISTS entity_type text; -- table_name
|
|
57
|
-
ALTER TABLE crm.communications ADD COLUMN IF NOT EXISTS sender text;
|
|
58
|
-
ALTER TABLE crm.communications ADD COLUMN IF NOT EXISTS channel text;
|
|
59
|
-
ALTER TABLE crm.communications ADD COLUMN IF NOT EXISTS participant text;
|
|
60
|
-
ALTER TABLE crm.communications ADD COLUMN IF NOT EXISTS communication_date date;
|
|
61
|
-
ALTER TABLE crm.communications ADD COLUMN IF NOT EXISTS expiration_date date;
|
|
62
|
-
ALTER TABLE crm.communications ADD COLUMN IF NOT EXISTS announcement text;
|
|
63
|
-
ALTER TABLE crm.communications ADD COLUMN IF NOT EXISTS subject text; -- title
|
|
64
|
-
ALTER TABLE crm.communications ADD COLUMN IF NOT EXISTS body text;
|
|
65
|
-
ALTER TABLE crm.communications ADD COLUMN IF NOT EXISTS mark numeric;
|
|
66
|
-
ALTER TABLE crm.communications ADD COLUMN IF NOT EXISTS parent_id text;
|
|
67
|
-
ALTER TABLE crm.communications ADD COLUMN IF NOT EXISTS target_id text[];
|
|
68
|
-
ALTER TABLE crm.communications ADD COLUMN IF NOT EXISTS enabled boolean;
|
|
69
|
-
ALTER TABLE crm.communications ADD COLUMN IF NOT EXISTS uid text;
|
|
70
|
-
ALTER TABLE crm.communications ADD COLUMN IF NOT EXISTS files json;
|
|
71
|
-
ALTER TABLE crm.communications ADD COLUMN IF NOT EXISTS cdate timestamp without time zone DEFAULT (now())::timestamp without time zone;
|
|
72
|
-
ALTER TABLE crm.communications ADD COLUMN IF NOT EXISTS editor_id text;
|
|
73
|
-
ALTER TABLE crm.communications ADD COLUMN IF NOT EXISTS editor_date timestamp without time zone;
|
|
74
|
-
ALTER TABLE crm.communications ADD CONSTRAINT crm_communications_pkey PRIMARY KEY (communication_id);
|
|
75
|
-
|
|
76
|
-
-- crm.checklists
|
|
77
|
-
-- DROP TABLE IF EXISTS crm.checklists;
|
|
78
|
-
CREATE TABLE IF NOT EXISTS crm.checklists();
|
|
79
|
-
ALTER TABLE crm.checklists DROP CONSTRAINT IF EXISTS crm_checklists_pkey;
|
|
80
|
-
ALTER TABLE crm.checklists ADD COLUMN IF NOT EXISTS checklist_id text NOT NULL DEFAULT next_id();
|
|
81
|
-
|
|
82
|
-
ALTER TABLE crm.checklists ADD COLUMN IF NOT EXISTS entity_id text; -- object_id
|
|
83
|
-
ALTER TABLE crm.checklists ADD COLUMN IF NOT EXISTS entity_type text; -- table_name
|
|
84
|
-
ALTER TABLE crm.checklists ADD COLUMN IF NOT EXISTS subject text; -- title
|
|
85
|
-
alter table crm.checklists add column IF NOT EXISTS is_done boolean default false;
|
|
86
|
-
alter table crm.checklists add column IF NOT EXISTS done_date date;
|
|
87
|
-
alter table crm.checklists add column IF NOT EXISTS category text;
|
|
88
|
-
alter table crm.checklists add column IF NOT EXISTS body text;
|
|
89
|
-
alter table crm.checklists add column IF NOT EXISTS parent_id text;
|
|
90
|
-
alter table crm.checklists add column IF NOT EXISTS flag boolean;
|
|
91
|
-
|
|
92
|
-
ALTER TABLE crm.checklists ADD COLUMN IF NOT EXISTS uid text;
|
|
93
|
-
ALTER TABLE crm.checklists ADD COLUMN IF NOT EXISTS files json;
|
|
94
|
-
ALTER TABLE crm.checklists ADD COLUMN IF NOT EXISTS cdate timestamp without time zone DEFAULT (now())::timestamp without time zone;
|
|
95
|
-
ALTER TABLE crm.checklists ADD COLUMN IF NOT EXISTS editor_id text;
|
|
96
|
-
ALTER TABLE crm.checklists ADD COLUMN IF NOT EXISTS editor_date timestamp without time zone;
|
|
97
|
-
ALTER TABLE crm.checklists ADD CONSTRAINT crm_checklists_pkey PRIMARY KEY (checklist_id);
|
|
98
|
-
|
|
99
|
-
-- crm.cls
|
|
100
|
-
-- DROP TABLE IF EXISTS crm.cls;
|
|
101
|
-
CREATE TABLE IF NOT EXISTS crm.cls();
|
|
102
|
-
ALTER TABLE crm.cls DROP CONSTRAINT IF EXISTS crm_cls_pkey;
|
|
103
|
-
ALTER TABLE crm.cls DROP CONSTRAINT IF EXISTS crm_cls_unique;
|
|
104
|
-
ALTER TABLE crm.cls ADD COLUMN IF NOT EXISTS cls_id text NOT NULL DEFAULT next_id();
|
|
105
|
-
|
|
106
|
-
ALTER TABLE crm.cls ADD COLUMN IF NOT EXISTS name text;
|
|
107
|
-
ALTER TABLE crm.cls ADD COLUMN IF NOT EXISTS data text;
|
|
108
|
-
ALTER TABLE crm.cls ADD COLUMN IF NOT EXISTS type text;
|
|
109
|
-
ALTER TABLE crm.cls ADD COLUMN IF NOT EXISTS parent text;
|
|
110
|
-
ALTER TABLE crm.cls ADD COLUMN IF NOT EXISTS code text;
|
|
111
|
-
ALTER TABLE crm.cls ADD COLUMN IF NOT EXISTS color text;
|
|
112
|
-
ALTER TABLE crm.cls ADD COLUMN IF NOT EXISTS icon text;
|
|
113
|
-
|
|
114
|
-
ALTER TABLE crm.cls ADD COLUMN IF NOT EXISTS uid text;
|
|
115
|
-
ALTER TABLE crm.cls ADD COLUMN IF NOT EXISTS files json;
|
|
116
|
-
ALTER TABLE crm.cls ADD COLUMN IF NOT EXISTS cdate timestamp without time zone DEFAULT (now())::timestamp without time zone;
|
|
117
|
-
ALTER TABLE crm.cls ADD COLUMN IF NOT EXISTS editor_id text;
|
|
118
|
-
ALTER TABLE crm.cls ADD COLUMN IF NOT EXISTS editor_date timestamp without time zone;
|
|
119
|
-
ALTER TABLE crm.cls ADD CONSTRAINT crm_cls_pkey PRIMARY KEY (cls_id);
|
|
120
|
-
ALTER TABLE crm.cls ADD CONSTRAINT crm_cls_unique UNIQUE (code, parent);
|
|
121
|
-
|
|
122
|
-
-- DROP TABLE crm.properties;
|
|
123
|
-
CREATE TABLE IF NOT EXISTS crm.properties();
|
|
124
|
-
ALTER TABLE crm.properties DROP CONSTRAINT IF EXISTS crm_properties_pkey;
|
|
125
|
-
ALTER TABLE crm.properties ADD COLUMN IF NOT EXISTS property_id text NOT NULL DEFAULT next_id();
|
|
126
|
-
|
|
127
|
-
ALTER TABLE crm.properties ADD COLUMN IF NOT EXISTS table_name text;
|
|
128
|
-
COMMENT ON COLUMN crm.properties.table_name IS 'Таблиця';
|
|
129
|
-
ALTER TABLE crm.properties ADD COLUMN IF NOT EXISTS object_id text;
|
|
130
|
-
COMMENT ON COLUMN crm.properties.object_id IS 'ID Об''єкту';
|
|
131
|
-
ALTER TABLE crm.properties ADD COLUMN IF NOT EXISTS property_key text;
|
|
132
|
-
COMMENT ON COLUMN crm.properties.object_id IS 'Назва атрибуту';
|
|
133
|
-
ALTER TABLE crm.properties ADD COLUMN IF NOT EXISTS property_text text;
|
|
134
|
-
COMMENT ON COLUMN crm.properties.property_text IS 'Текст';
|
|
135
|
-
ALTER TABLE crm.properties ADD COLUMN IF NOT EXISTS property_int integer;
|
|
136
|
-
COMMENT ON COLUMN crm.properties.property_int IS 'Integer';
|
|
137
|
-
ALTER TABLE crm.properties ADD COLUMN IF NOT EXISTS property_json json;
|
|
138
|
-
COMMENT ON COLUMN crm.properties.property_json IS 'JSON';
|
|
139
|
-
ALTER TABLE crm.properties ADD COLUMN IF NOT EXISTS property_date date;
|
|
140
|
-
COMMENT ON COLUMN crm.properties.property_json IS 'Дата';
|
|
141
|
-
ALTER TABLE crm.properties ADD COLUMN IF NOT EXISTS property_type text;
|
|
142
|
-
COMMENT ON COLUMN crm.properties.property_type IS 'Тип даних';
|
|
143
|
-
|
|
144
|
-
ALTER TABLE crm.properties ADD COLUMN IF NOT EXISTS uid text NOT NULL DEFAULT '1'::text;
|
|
145
|
-
ALTER TABLE crm.properties ADD COLUMN IF NOT EXISTS editor_id text;
|
|
146
|
-
ALTER TABLE crm.properties ADD COLUMN IF NOT EXISTS editor_date timestamp without time zone;
|
|
147
|
-
ALTER TABLE crm.properties ADD COLUMN IF NOT EXISTS cdate timestamp without time zone DEFAULT now();
|
|
148
|
-
ALTER TABLE crm.properties ADD COLUMN IF NOT EXISTS files json;
|
|
149
|
-
|
|
150
|
-
ALTER TABLE crm.properties ADD CONSTRAINT crm_properties_pkey PRIMARY KEY(property_id);
|
|
1
|
+
create schema if not exists crm;
|
|
2
|
+
|
|
3
|
+
-- crm.notifications
|
|
4
|
+
-- DROP TABLE IF EXISTS crm.notifications;
|
|
5
|
+
CREATE TABLE IF NOT EXISTS crm.notifications();
|
|
6
|
+
ALTER TABLE crm.notifications DROP CONSTRAINT IF EXISTS crm_notifications_pkey;
|
|
7
|
+
ALTER TABLE crm.notifications ADD COLUMN IF NOT EXISTS notification_id text NOT NULL DEFAULT next_id();
|
|
8
|
+
|
|
9
|
+
ALTER TABLE crm.notifications ADD COLUMN IF NOT EXISTS notification_user_id text;
|
|
10
|
+
ALTER TABLE crm.notifications ADD COLUMN IF NOT EXISTS notification_type text DEFAULT 'notify'::text;
|
|
11
|
+
ALTER TABLE crm.notifications ADD COLUMN IF NOT EXISTS notification_status text DEFAULT 'not sent'::text;
|
|
12
|
+
ALTER TABLE crm.notifications ADD COLUMN IF NOT EXISTS subject text;
|
|
13
|
+
ALTER TABLE crm.notifications ADD COLUMN IF NOT EXISTS body text;
|
|
14
|
+
ALTER TABLE crm.notifications ADD COLUMN IF NOT EXISTS link text;
|
|
15
|
+
|
|
16
|
+
ALTER TABLE crm.notifications ADD COLUMN IF NOT EXISTS uid text;
|
|
17
|
+
ALTER TABLE crm.notifications ADD COLUMN IF NOT EXISTS files json;
|
|
18
|
+
ALTER TABLE crm.notifications ADD COLUMN IF NOT EXISTS cdate timestamp without time zone DEFAULT (now())::timestamp without time zone;
|
|
19
|
+
ALTER TABLE crm.notifications ADD COLUMN IF NOT EXISTS editor_id text;
|
|
20
|
+
ALTER TABLE crm.notifications ADD COLUMN IF NOT EXISTS editor_date timestamp without time zone;
|
|
21
|
+
ALTER TABLE crm.notifications ADD CONSTRAINT crm_notifications_pkey PRIMARY KEY (notification_id);
|
|
22
|
+
|
|
23
|
+
-- crm.files
|
|
24
|
+
-- DROP TABLE IF EXISTS crm.files;
|
|
25
|
+
CREATE TABLE IF NOT EXISTS crm.files();
|
|
26
|
+
ALTER TABLE crm.files DROP CONSTRAINT IF EXISTS crm_files_pkey;
|
|
27
|
+
ALTER TABLE crm.files ADD COLUMN IF NOT EXISTS file_id text NOT NULL DEFAULT next_id();
|
|
28
|
+
|
|
29
|
+
ALTER TABLE crm.files ADD COLUMN IF NOT EXISTS uploaded_name text;
|
|
30
|
+
ALTER TABLE crm.files ADD COLUMN IF NOT EXISTS entity_id text; -- object_id
|
|
31
|
+
ALTER TABLE crm.files ADD COLUMN IF NOT EXISTS entity_type text; -- table_name
|
|
32
|
+
ALTER TABLE crm.files ADD COLUMN IF NOT EXISTS file_type text;
|
|
33
|
+
ALTER TABLE crm.files ADD COLUMN IF NOT EXISTS file_status numeric;
|
|
34
|
+
ALTER TABLE crm.files ADD COLUMN IF NOT EXISTS doc_type text;
|
|
35
|
+
ALTER TABLE crm.files ADD COLUMN IF NOT EXISTS subject text; -- title
|
|
36
|
+
ALTER TABLE crm.files ADD COLUMN IF NOT EXISTS size numeric;
|
|
37
|
+
ALTER TABLE crm.files ADD COLUMN IF NOT EXISTS ext text;
|
|
38
|
+
ALTER TABLE crm.files ADD COLUMN IF NOT EXISTS tags text[];
|
|
39
|
+
ALTER TABLE crm.files ADD COLUMN IF NOT EXISTS file_path text;
|
|
40
|
+
ALTER TABLE crm.files ADD COLUMN IF NOT EXISTS ismain boolean default false;
|
|
41
|
+
ALTER TABLE crm.files ADD COLUMN IF NOT EXISTS isverified boolean default false;
|
|
42
|
+
ALTER TABLE crm.files ADD COLUMN IF NOT EXISTS uid text;
|
|
43
|
+
ALTER TABLE crm.files ADD COLUMN IF NOT EXISTS files json;
|
|
44
|
+
ALTER TABLE crm.files ADD COLUMN IF NOT EXISTS cdate timestamp without time zone DEFAULT (now())::timestamp without time zone;
|
|
45
|
+
ALTER TABLE crm.files ADD COLUMN IF NOT EXISTS editor_id text;
|
|
46
|
+
ALTER TABLE crm.files ADD COLUMN IF NOT EXISTS editor_date timestamp without time zone;
|
|
47
|
+
ALTER TABLE crm.files ADD CONSTRAINT crm_files_pkey PRIMARY KEY (file_id);
|
|
48
|
+
|
|
49
|
+
-- crm.communications
|
|
50
|
+
-- DROP TABLE IF EXISTS crm.communications;
|
|
51
|
+
CREATE TABLE IF NOT EXISTS crm.communications();
|
|
52
|
+
ALTER TABLE crm.communications DROP CONSTRAINT IF EXISTS crm_communications_pkey;
|
|
53
|
+
ALTER TABLE crm.communications ADD COLUMN IF NOT EXISTS communication_id text NOT NULL DEFAULT next_id();
|
|
54
|
+
|
|
55
|
+
ALTER TABLE crm.communications ADD COLUMN IF NOT EXISTS entity_id text; -- object_id
|
|
56
|
+
ALTER TABLE crm.communications ADD COLUMN IF NOT EXISTS entity_type text; -- table_name
|
|
57
|
+
ALTER TABLE crm.communications ADD COLUMN IF NOT EXISTS sender text;
|
|
58
|
+
ALTER TABLE crm.communications ADD COLUMN IF NOT EXISTS channel text;
|
|
59
|
+
ALTER TABLE crm.communications ADD COLUMN IF NOT EXISTS participant text;
|
|
60
|
+
ALTER TABLE crm.communications ADD COLUMN IF NOT EXISTS communication_date date;
|
|
61
|
+
ALTER TABLE crm.communications ADD COLUMN IF NOT EXISTS expiration_date date;
|
|
62
|
+
ALTER TABLE crm.communications ADD COLUMN IF NOT EXISTS announcement text;
|
|
63
|
+
ALTER TABLE crm.communications ADD COLUMN IF NOT EXISTS subject text; -- title
|
|
64
|
+
ALTER TABLE crm.communications ADD COLUMN IF NOT EXISTS body text;
|
|
65
|
+
ALTER TABLE crm.communications ADD COLUMN IF NOT EXISTS mark numeric;
|
|
66
|
+
ALTER TABLE crm.communications ADD COLUMN IF NOT EXISTS parent_id text;
|
|
67
|
+
ALTER TABLE crm.communications ADD COLUMN IF NOT EXISTS target_id text[];
|
|
68
|
+
ALTER TABLE crm.communications ADD COLUMN IF NOT EXISTS enabled boolean;
|
|
69
|
+
ALTER TABLE crm.communications ADD COLUMN IF NOT EXISTS uid text;
|
|
70
|
+
ALTER TABLE crm.communications ADD COLUMN IF NOT EXISTS files json;
|
|
71
|
+
ALTER TABLE crm.communications ADD COLUMN IF NOT EXISTS cdate timestamp without time zone DEFAULT (now())::timestamp without time zone;
|
|
72
|
+
ALTER TABLE crm.communications ADD COLUMN IF NOT EXISTS editor_id text;
|
|
73
|
+
ALTER TABLE crm.communications ADD COLUMN IF NOT EXISTS editor_date timestamp without time zone;
|
|
74
|
+
ALTER TABLE crm.communications ADD CONSTRAINT crm_communications_pkey PRIMARY KEY (communication_id);
|
|
75
|
+
|
|
76
|
+
-- crm.checklists
|
|
77
|
+
-- DROP TABLE IF EXISTS crm.checklists;
|
|
78
|
+
CREATE TABLE IF NOT EXISTS crm.checklists();
|
|
79
|
+
ALTER TABLE crm.checklists DROP CONSTRAINT IF EXISTS crm_checklists_pkey;
|
|
80
|
+
ALTER TABLE crm.checklists ADD COLUMN IF NOT EXISTS checklist_id text NOT NULL DEFAULT next_id();
|
|
81
|
+
|
|
82
|
+
ALTER TABLE crm.checklists ADD COLUMN IF NOT EXISTS entity_id text; -- object_id
|
|
83
|
+
ALTER TABLE crm.checklists ADD COLUMN IF NOT EXISTS entity_type text; -- table_name
|
|
84
|
+
ALTER TABLE crm.checklists ADD COLUMN IF NOT EXISTS subject text; -- title
|
|
85
|
+
alter table crm.checklists add column IF NOT EXISTS is_done boolean default false;
|
|
86
|
+
alter table crm.checklists add column IF NOT EXISTS done_date date;
|
|
87
|
+
alter table crm.checklists add column IF NOT EXISTS category text;
|
|
88
|
+
alter table crm.checklists add column IF NOT EXISTS body text;
|
|
89
|
+
alter table crm.checklists add column IF NOT EXISTS parent_id text;
|
|
90
|
+
alter table crm.checklists add column IF NOT EXISTS flag boolean;
|
|
91
|
+
|
|
92
|
+
ALTER TABLE crm.checklists ADD COLUMN IF NOT EXISTS uid text;
|
|
93
|
+
ALTER TABLE crm.checklists ADD COLUMN IF NOT EXISTS files json;
|
|
94
|
+
ALTER TABLE crm.checklists ADD COLUMN IF NOT EXISTS cdate timestamp without time zone DEFAULT (now())::timestamp without time zone;
|
|
95
|
+
ALTER TABLE crm.checklists ADD COLUMN IF NOT EXISTS editor_id text;
|
|
96
|
+
ALTER TABLE crm.checklists ADD COLUMN IF NOT EXISTS editor_date timestamp without time zone;
|
|
97
|
+
ALTER TABLE crm.checklists ADD CONSTRAINT crm_checklists_pkey PRIMARY KEY (checklist_id);
|
|
98
|
+
|
|
99
|
+
-- crm.cls
|
|
100
|
+
-- DROP TABLE IF EXISTS crm.cls;
|
|
101
|
+
CREATE TABLE IF NOT EXISTS crm.cls();
|
|
102
|
+
ALTER TABLE crm.cls DROP CONSTRAINT IF EXISTS crm_cls_pkey;
|
|
103
|
+
ALTER TABLE crm.cls DROP CONSTRAINT IF EXISTS crm_cls_unique;
|
|
104
|
+
ALTER TABLE crm.cls ADD COLUMN IF NOT EXISTS cls_id text NOT NULL DEFAULT next_id();
|
|
105
|
+
|
|
106
|
+
ALTER TABLE crm.cls ADD COLUMN IF NOT EXISTS name text;
|
|
107
|
+
ALTER TABLE crm.cls ADD COLUMN IF NOT EXISTS data text;
|
|
108
|
+
ALTER TABLE crm.cls ADD COLUMN IF NOT EXISTS type text;
|
|
109
|
+
ALTER TABLE crm.cls ADD COLUMN IF NOT EXISTS parent text;
|
|
110
|
+
ALTER TABLE crm.cls ADD COLUMN IF NOT EXISTS code text;
|
|
111
|
+
ALTER TABLE crm.cls ADD COLUMN IF NOT EXISTS color text;
|
|
112
|
+
ALTER TABLE crm.cls ADD COLUMN IF NOT EXISTS icon text;
|
|
113
|
+
|
|
114
|
+
ALTER TABLE crm.cls ADD COLUMN IF NOT EXISTS uid text;
|
|
115
|
+
ALTER TABLE crm.cls ADD COLUMN IF NOT EXISTS files json;
|
|
116
|
+
ALTER TABLE crm.cls ADD COLUMN IF NOT EXISTS cdate timestamp without time zone DEFAULT (now())::timestamp without time zone;
|
|
117
|
+
ALTER TABLE crm.cls ADD COLUMN IF NOT EXISTS editor_id text;
|
|
118
|
+
ALTER TABLE crm.cls ADD COLUMN IF NOT EXISTS editor_date timestamp without time zone;
|
|
119
|
+
ALTER TABLE crm.cls ADD CONSTRAINT crm_cls_pkey PRIMARY KEY (cls_id);
|
|
120
|
+
ALTER TABLE crm.cls ADD CONSTRAINT crm_cls_unique UNIQUE (code, parent);
|
|
121
|
+
|
|
122
|
+
-- DROP TABLE crm.properties;
|
|
123
|
+
CREATE TABLE IF NOT EXISTS crm.properties();
|
|
124
|
+
ALTER TABLE crm.properties DROP CONSTRAINT IF EXISTS crm_properties_pkey;
|
|
125
|
+
ALTER TABLE crm.properties ADD COLUMN IF NOT EXISTS property_id text NOT NULL DEFAULT next_id();
|
|
126
|
+
|
|
127
|
+
ALTER TABLE crm.properties ADD COLUMN IF NOT EXISTS table_name text;
|
|
128
|
+
COMMENT ON COLUMN crm.properties.table_name IS 'Таблиця';
|
|
129
|
+
ALTER TABLE crm.properties ADD COLUMN IF NOT EXISTS object_id text;
|
|
130
|
+
COMMENT ON COLUMN crm.properties.object_id IS 'ID Об''єкту';
|
|
131
|
+
ALTER TABLE crm.properties ADD COLUMN IF NOT EXISTS property_key text;
|
|
132
|
+
COMMENT ON COLUMN crm.properties.object_id IS 'Назва атрибуту';
|
|
133
|
+
ALTER TABLE crm.properties ADD COLUMN IF NOT EXISTS property_text text;
|
|
134
|
+
COMMENT ON COLUMN crm.properties.property_text IS 'Текст';
|
|
135
|
+
ALTER TABLE crm.properties ADD COLUMN IF NOT EXISTS property_int integer;
|
|
136
|
+
COMMENT ON COLUMN crm.properties.property_int IS 'Integer';
|
|
137
|
+
ALTER TABLE crm.properties ADD COLUMN IF NOT EXISTS property_json json;
|
|
138
|
+
COMMENT ON COLUMN crm.properties.property_json IS 'JSON';
|
|
139
|
+
ALTER TABLE crm.properties ADD COLUMN IF NOT EXISTS property_date date;
|
|
140
|
+
COMMENT ON COLUMN crm.properties.property_json IS 'Дата';
|
|
141
|
+
ALTER TABLE crm.properties ADD COLUMN IF NOT EXISTS property_type text;
|
|
142
|
+
COMMENT ON COLUMN crm.properties.property_type IS 'Тип даних';
|
|
143
|
+
|
|
144
|
+
ALTER TABLE crm.properties ADD COLUMN IF NOT EXISTS uid text NOT NULL DEFAULT '1'::text;
|
|
145
|
+
ALTER TABLE crm.properties ADD COLUMN IF NOT EXISTS editor_id text;
|
|
146
|
+
ALTER TABLE crm.properties ADD COLUMN IF NOT EXISTS editor_date timestamp without time zone;
|
|
147
|
+
ALTER TABLE crm.properties ADD COLUMN IF NOT EXISTS cdate timestamp without time zone DEFAULT now();
|
|
148
|
+
ALTER TABLE crm.properties ADD COLUMN IF NOT EXISTS files json;
|
|
149
|
+
|
|
150
|
+
ALTER TABLE crm.properties ADD CONSTRAINT crm_properties_pkey PRIMARY KEY(property_id);
|
|
@@ -1,81 +1,81 @@
|
|
|
1
|
-
create schema if not exists log;
|
|
2
|
-
|
|
3
|
-
-- DROP TABLE IF EXISTS log.table_changes cascade;
|
|
4
|
-
CREATE TABLE IF NOT EXISTS log.table_changes();
|
|
5
|
-
ALTER TABLE log.table_changes ADD COLUMN IF NOT EXISTS change_id text NOT NULL DEFAULT next_id();
|
|
6
|
-
ALTER TABLE log.table_changes ADD COLUMN IF NOT EXISTS change_type text;
|
|
7
|
-
ALTER TABLE log.table_changes ADD COLUMN IF NOT EXISTS change_date date;
|
|
8
|
-
ALTER TABLE log.table_changes ADD COLUMN IF NOT EXISTS change_user_id text;
|
|
9
|
-
ALTER TABLE log.table_changes ADD COLUMN IF NOT EXISTS entity_type text; -- table_name
|
|
10
|
-
ALTER TABLE log.table_changes ADD COLUMN IF NOT EXISTS entity_id text; -- object_id
|
|
11
|
-
ALTER TABLE log.table_changes ADD COLUMN IF NOT EXISTS uid text;
|
|
12
|
-
ALTER TABLE log.table_changes ADD COLUMN IF NOT EXISTS cdate timestamp without time zone DEFAULT (now())::timestamp without time zone;
|
|
13
|
-
ALTER TABLE log.table_changes ADD COLUMN IF NOT EXISTS editor_id text;
|
|
14
|
-
ALTER TABLE log.table_changes ADD COLUMN IF NOT EXISTS editor_date timestamp without time zone;
|
|
15
|
-
|
|
16
|
-
-- DROP TABLE IF EXISTS log.table_changes_data;
|
|
17
|
-
CREATE TABLE IF NOT EXISTS log.table_changes_data();
|
|
18
|
-
ALTER TABLE log.table_changes_data ADD COLUMN IF NOT EXISTS change_data_id text NOT NULL DEFAULT next_id();
|
|
19
|
-
ALTER TABLE log.table_changes_data ADD COLUMN IF NOT EXISTS change_id text not null;
|
|
20
|
-
ALTER TABLE log.table_changes_data ADD COLUMN IF NOT EXISTS entity_key text; -- column_name
|
|
21
|
-
ALTER TABLE log.table_changes_data ADD COLUMN IF NOT EXISTS value_old text;
|
|
22
|
-
ALTER TABLE log.table_changes_data ADD COLUMN IF NOT EXISTS value_new text;
|
|
23
|
-
ALTER TABLE log.table_changes_data ADD COLUMN IF NOT EXISTS uid text;
|
|
24
|
-
ALTER TABLE log.table_changes_data ADD COLUMN IF NOT EXISTS cdate timestamp without time zone DEFAULT (now())::timestamp without time zone;
|
|
25
|
-
ALTER TABLE log.table_changes_data ADD COLUMN IF NOT EXISTS editor_id text;
|
|
26
|
-
ALTER TABLE log.table_changes_data ADD COLUMN IF NOT EXISTS editor_date timestamp without time zone;
|
|
27
|
-
|
|
28
|
-
-- DROP TABLE IF EXISTS log.user_auth;
|
|
29
|
-
CREATE TABLE IF NOT EXISTS log.user_auth();
|
|
30
|
-
ALTER TABLE log.user_auth ADD COLUMN IF NOT EXISTS user_auth_id text NOT NULL DEFAULT next_id();
|
|
31
|
-
ALTER TABLE log.user_auth ADD COLUMN IF NOT EXISTS user_id text;
|
|
32
|
-
ALTER TABLE log.user_auth ADD COLUMN IF NOT EXISTS auth_date timestamp without time zone;
|
|
33
|
-
ALTER TABLE log.user_auth ADD COLUMN IF NOT EXISTS auth_type text;
|
|
34
|
-
ALTER TABLE log.user_auth ADD COLUMN IF NOT EXISTS uid text;
|
|
35
|
-
ALTER TABLE log.user_auth ADD COLUMN IF NOT EXISTS cdate timestamp without time zone DEFAULT (now())::timestamp without time zone;
|
|
36
|
-
ALTER TABLE log.user_auth ADD COLUMN IF NOT EXISTS editor_id text;
|
|
37
|
-
ALTER TABLE log.user_auth ADD COLUMN IF NOT EXISTS editor_date timestamp without time zone;
|
|
38
|
-
|
|
39
|
-
COMMENT ON TABLE log.table_changes IS 'Логи подій змін в БД';
|
|
40
|
-
COMMENT ON COLUMN log.table_changes.change_type IS 'Тип події (insert / update / delete)';
|
|
41
|
-
COMMENT ON COLUMN log.table_changes.change_date IS 'Дата внесення змін до БД';
|
|
42
|
-
COMMENT ON COLUMN log.table_changes.entity_type IS 'Таблиця, до якої вносяться зміни';
|
|
43
|
-
COMMENT ON COLUMN log.table_changes.entity_id IS 'ID строки, до якої вносяться зміни';
|
|
44
|
-
COMMENT ON COLUMN log.table_changes.change_user_id IS 'Ініціатор внесення змін';
|
|
45
|
-
|
|
46
|
-
COMMENT ON TABLE log.table_changes_data IS 'Логи змін в таблицях БД';
|
|
47
|
-
COMMENT ON COLUMN log.table_changes_data.change_id IS 'ID події зміни в БД';
|
|
48
|
-
COMMENT ON COLUMN log.table_changes_data.entity_key IS 'Колонка таблиці, до якої вносяться зміни';
|
|
49
|
-
COMMENT ON COLUMN log.table_changes_data.value_old IS 'Старе значення';
|
|
50
|
-
COMMENT ON COLUMN log.table_changes_data.value_new IS 'Нове значення';
|
|
51
|
-
|
|
52
|
-
COMMENT ON TABLE log.user_auth IS 'Логи авторизації';
|
|
53
|
-
COMMENT ON COLUMN log.user_auth.user_id IS 'ID користувача';
|
|
54
|
-
COMMENT ON COLUMN log.user_auth.auth_date IS 'Дата авторизації';
|
|
55
|
-
COMMENT ON COLUMN log.user_auth.auth_type IS 'Тип авторизації';
|
|
56
|
-
|
|
57
|
-
ALTER TABLE log.table_changes DROP CONSTRAINT IF EXISTS log_table_changes_pkey cascade;
|
|
58
|
-
ALTER TABLE log.table_changes_data DROP CONSTRAINT IF EXISTS log_table_changes_data_pkey;
|
|
59
|
-
ALTER TABLE log.table_changes_data DROP CONSTRAINT IF EXISTS log_table_changes_data_change_id_fkey;
|
|
60
|
-
ALTER TABLE log.user_auth DROP CONSTRAINT IF EXISTS log_user_auth_pkey;
|
|
61
|
-
ALTER TABLE log.user_auth DROP CONSTRAINT IF EXISTS log_user_auth_user_id_fkey;
|
|
62
|
-
|
|
63
|
-
ALTER TABLE log.table_changes ADD CONSTRAINT log_table_changes_pkey PRIMARY KEY (change_id);
|
|
64
|
-
ALTER TABLE log.table_changes_data ADD CONSTRAINT log_table_changes_data_pkey PRIMARY KEY (change_data_id);
|
|
65
|
-
ALTER TABLE log.table_changes_data ADD CONSTRAINT log_table_changes_data_change_id_fkey FOREIGN KEY (change_id)
|
|
66
|
-
REFERENCES log.table_changes (change_id);
|
|
67
|
-
ALTER TABLE log.user_auth ADD CONSTRAINT log_user_auth_pkey PRIMARY KEY (user_auth_id);
|
|
68
|
-
-- ALTER TABLE log.user_auth ADD CONSTRAINT log_user_auth_user_id_fkey FOREIGN KEY (user_id) REFERENCES admin.users (uid) MATCH SIMPLE;
|
|
69
|
-
|
|
70
|
-
/* drop old columns */
|
|
71
|
-
alter table log.table_changes drop column if exists date_new;
|
|
72
|
-
alter table log.table_changes drop column if exists date_old;
|
|
73
|
-
alter table log.table_changes drop column if exists number_new;
|
|
74
|
-
alter table log.table_changes drop column if exists number_old;
|
|
75
|
-
alter table log.table_changes drop column if exists json_new;
|
|
76
|
-
alter table log.table_changes drop column if exists json_old;
|
|
77
|
-
alter table log.table_changes drop column if exists text_new;
|
|
78
|
-
alter table log.table_changes drop column if exists text_old;
|
|
79
|
-
alter table log.table_changes drop column if exists bool_new;
|
|
80
|
-
alter table log.table_changes drop column if exists bool_old;
|
|
1
|
+
create schema if not exists log;
|
|
2
|
+
|
|
3
|
+
-- DROP TABLE IF EXISTS log.table_changes cascade;
|
|
4
|
+
CREATE TABLE IF NOT EXISTS log.table_changes();
|
|
5
|
+
ALTER TABLE log.table_changes ADD COLUMN IF NOT EXISTS change_id text NOT NULL DEFAULT next_id();
|
|
6
|
+
ALTER TABLE log.table_changes ADD COLUMN IF NOT EXISTS change_type text;
|
|
7
|
+
ALTER TABLE log.table_changes ADD COLUMN IF NOT EXISTS change_date date;
|
|
8
|
+
ALTER TABLE log.table_changes ADD COLUMN IF NOT EXISTS change_user_id text;
|
|
9
|
+
ALTER TABLE log.table_changes ADD COLUMN IF NOT EXISTS entity_type text; -- table_name
|
|
10
|
+
ALTER TABLE log.table_changes ADD COLUMN IF NOT EXISTS entity_id text; -- object_id
|
|
11
|
+
ALTER TABLE log.table_changes ADD COLUMN IF NOT EXISTS uid text;
|
|
12
|
+
ALTER TABLE log.table_changes ADD COLUMN IF NOT EXISTS cdate timestamp without time zone DEFAULT (now())::timestamp without time zone;
|
|
13
|
+
ALTER TABLE log.table_changes ADD COLUMN IF NOT EXISTS editor_id text;
|
|
14
|
+
ALTER TABLE log.table_changes ADD COLUMN IF NOT EXISTS editor_date timestamp without time zone;
|
|
15
|
+
|
|
16
|
+
-- DROP TABLE IF EXISTS log.table_changes_data;
|
|
17
|
+
CREATE TABLE IF NOT EXISTS log.table_changes_data();
|
|
18
|
+
ALTER TABLE log.table_changes_data ADD COLUMN IF NOT EXISTS change_data_id text NOT NULL DEFAULT next_id();
|
|
19
|
+
ALTER TABLE log.table_changes_data ADD COLUMN IF NOT EXISTS change_id text not null;
|
|
20
|
+
ALTER TABLE log.table_changes_data ADD COLUMN IF NOT EXISTS entity_key text; -- column_name
|
|
21
|
+
ALTER TABLE log.table_changes_data ADD COLUMN IF NOT EXISTS value_old text;
|
|
22
|
+
ALTER TABLE log.table_changes_data ADD COLUMN IF NOT EXISTS value_new text;
|
|
23
|
+
ALTER TABLE log.table_changes_data ADD COLUMN IF NOT EXISTS uid text;
|
|
24
|
+
ALTER TABLE log.table_changes_data ADD COLUMN IF NOT EXISTS cdate timestamp without time zone DEFAULT (now())::timestamp without time zone;
|
|
25
|
+
ALTER TABLE log.table_changes_data ADD COLUMN IF NOT EXISTS editor_id text;
|
|
26
|
+
ALTER TABLE log.table_changes_data ADD COLUMN IF NOT EXISTS editor_date timestamp without time zone;
|
|
27
|
+
|
|
28
|
+
-- DROP TABLE IF EXISTS log.user_auth;
|
|
29
|
+
CREATE TABLE IF NOT EXISTS log.user_auth();
|
|
30
|
+
ALTER TABLE log.user_auth ADD COLUMN IF NOT EXISTS user_auth_id text NOT NULL DEFAULT next_id();
|
|
31
|
+
ALTER TABLE log.user_auth ADD COLUMN IF NOT EXISTS user_id text;
|
|
32
|
+
ALTER TABLE log.user_auth ADD COLUMN IF NOT EXISTS auth_date timestamp without time zone;
|
|
33
|
+
ALTER TABLE log.user_auth ADD COLUMN IF NOT EXISTS auth_type text;
|
|
34
|
+
ALTER TABLE log.user_auth ADD COLUMN IF NOT EXISTS uid text;
|
|
35
|
+
ALTER TABLE log.user_auth ADD COLUMN IF NOT EXISTS cdate timestamp without time zone DEFAULT (now())::timestamp without time zone;
|
|
36
|
+
ALTER TABLE log.user_auth ADD COLUMN IF NOT EXISTS editor_id text;
|
|
37
|
+
ALTER TABLE log.user_auth ADD COLUMN IF NOT EXISTS editor_date timestamp without time zone;
|
|
38
|
+
|
|
39
|
+
COMMENT ON TABLE log.table_changes IS 'Логи подій змін в БД';
|
|
40
|
+
COMMENT ON COLUMN log.table_changes.change_type IS 'Тип події (insert / update / delete)';
|
|
41
|
+
COMMENT ON COLUMN log.table_changes.change_date IS 'Дата внесення змін до БД';
|
|
42
|
+
COMMENT ON COLUMN log.table_changes.entity_type IS 'Таблиця, до якої вносяться зміни';
|
|
43
|
+
COMMENT ON COLUMN log.table_changes.entity_id IS 'ID строки, до якої вносяться зміни';
|
|
44
|
+
COMMENT ON COLUMN log.table_changes.change_user_id IS 'Ініціатор внесення змін';
|
|
45
|
+
|
|
46
|
+
COMMENT ON TABLE log.table_changes_data IS 'Логи змін в таблицях БД';
|
|
47
|
+
COMMENT ON COLUMN log.table_changes_data.change_id IS 'ID події зміни в БД';
|
|
48
|
+
COMMENT ON COLUMN log.table_changes_data.entity_key IS 'Колонка таблиці, до якої вносяться зміни';
|
|
49
|
+
COMMENT ON COLUMN log.table_changes_data.value_old IS 'Старе значення';
|
|
50
|
+
COMMENT ON COLUMN log.table_changes_data.value_new IS 'Нове значення';
|
|
51
|
+
|
|
52
|
+
COMMENT ON TABLE log.user_auth IS 'Логи авторизації';
|
|
53
|
+
COMMENT ON COLUMN log.user_auth.user_id IS 'ID користувача';
|
|
54
|
+
COMMENT ON COLUMN log.user_auth.auth_date IS 'Дата авторизації';
|
|
55
|
+
COMMENT ON COLUMN log.user_auth.auth_type IS 'Тип авторизації';
|
|
56
|
+
|
|
57
|
+
ALTER TABLE log.table_changes DROP CONSTRAINT IF EXISTS log_table_changes_pkey cascade;
|
|
58
|
+
ALTER TABLE log.table_changes_data DROP CONSTRAINT IF EXISTS log_table_changes_data_pkey;
|
|
59
|
+
ALTER TABLE log.table_changes_data DROP CONSTRAINT IF EXISTS log_table_changes_data_change_id_fkey;
|
|
60
|
+
ALTER TABLE log.user_auth DROP CONSTRAINT IF EXISTS log_user_auth_pkey;
|
|
61
|
+
ALTER TABLE log.user_auth DROP CONSTRAINT IF EXISTS log_user_auth_user_id_fkey;
|
|
62
|
+
|
|
63
|
+
ALTER TABLE log.table_changes ADD CONSTRAINT log_table_changes_pkey PRIMARY KEY (change_id);
|
|
64
|
+
ALTER TABLE log.table_changes_data ADD CONSTRAINT log_table_changes_data_pkey PRIMARY KEY (change_data_id);
|
|
65
|
+
ALTER TABLE log.table_changes_data ADD CONSTRAINT log_table_changes_data_change_id_fkey FOREIGN KEY (change_id)
|
|
66
|
+
REFERENCES log.table_changes (change_id);
|
|
67
|
+
ALTER TABLE log.user_auth ADD CONSTRAINT log_user_auth_pkey PRIMARY KEY (user_auth_id);
|
|
68
|
+
-- ALTER TABLE log.user_auth ADD CONSTRAINT log_user_auth_user_id_fkey FOREIGN KEY (user_id) REFERENCES admin.users (uid) MATCH SIMPLE;
|
|
69
|
+
|
|
70
|
+
/* drop old columns */
|
|
71
|
+
alter table log.table_changes drop column if exists date_new;
|
|
72
|
+
alter table log.table_changes drop column if exists date_old;
|
|
73
|
+
alter table log.table_changes drop column if exists number_new;
|
|
74
|
+
alter table log.table_changes drop column if exists number_old;
|
|
75
|
+
alter table log.table_changes drop column if exists json_new;
|
|
76
|
+
alter table log.table_changes drop column if exists json_old;
|
|
77
|
+
alter table log.table_changes drop column if exists text_new;
|
|
78
|
+
alter table log.table_changes drop column if exists text_old;
|
|
79
|
+
alter table log.table_changes drop column if exists bool_new;
|
|
80
|
+
alter table log.table_changes drop column if exists bool_old;
|
|
81
81
|
alter table log.table_changes drop column if exists table_change_id;
|
package/server.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
// This file contains code that we reuse
|
|
2
|
-
// between our tests.
|
|
3
|
-
import Fastify from 'fastify';
|
|
4
|
-
import config from './test/config.js';
|
|
5
|
-
import appService from './index.js';
|
|
6
|
-
|
|
7
|
-
const app = Fastify({ logger: false });
|
|
8
|
-
app.register(appService, config);
|
|
9
|
-
app.listen({ host: '0.0.0.0', port: process.env.PORT || 3000 }, (err) => {
|
|
10
|
-
if (err) {
|
|
11
|
-
app.log.error(err);
|
|
12
|
-
process.exit(1);
|
|
13
|
-
}
|
|
14
|
-
});
|
|
1
|
+
// This file contains code that we reuse
|
|
2
|
+
// between our tests.
|
|
3
|
+
import Fastify from 'fastify';
|
|
4
|
+
import config from './test/config.js';
|
|
5
|
+
import appService from './index.js';
|
|
6
|
+
|
|
7
|
+
const app = Fastify({ logger: false });
|
|
8
|
+
app.register(appService, config);
|
|
9
|
+
app.listen({ host: '0.0.0.0', port: process.env.PORT || 3000 }, (err) => {
|
|
10
|
+
if (err) {
|
|
11
|
+
app.log.error(err);
|
|
12
|
+
process.exit(1);
|
|
13
|
+
}
|
|
14
|
+
});
|
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
import getTemplate from './utils/getTemplate.js';
|
|
2
|
-
import getMeta from '../../pg/funcs/getMeta.js';
|
|
3
|
-
import metaFormat from '../funcs/metaFormat/index.js';
|
|
4
|
-
|
|
5
|
-
export default async function card(req) {
|
|
6
|
-
const time = Date.now();
|
|
7
|
-
const {
|
|
8
|
-
pg, params = {}, query = {}, opt = {},
|
|
9
|
-
} = req;
|
|
10
|
-
|
|
11
|
-
const loadTable = await getTemplate('table', params.table);
|
|
12
|
-
|
|
13
|
-
if (!loadTable) { return { message: 'template not found', status: 404 }; }
|
|
14
|
-
|
|
15
|
-
const {
|
|
16
|
-
table, columns, meta, sql, cardSql,
|
|
17
|
-
} = loadTable;
|
|
18
|
-
|
|
19
|
-
const { pk, columns: dbColumns = [] } = await getMeta(table);
|
|
20
|
-
|
|
21
|
-
if (!pk) return { message: `table not found: ${table}`, status: 404 };
|
|
22
|
-
|
|
23
|
-
const cols = columns.map((el) => el.name || el).join(',');
|
|
24
|
-
const columnList = dbColumns.map((el) => el.name || el).join(',');
|
|
25
|
-
const sqlTable = sql?.filter?.((el) => !el?.disabled && el?.sql?.replace).map((el, i) => ` left join lateral (${el.sql}) ${el.name || `t${i}`} on 1=1 `)?.join('') || '';
|
|
26
|
-
const cardSqlFiltered = opt.id || params.id ? cardSql?.filter?.((el) => !el?.disabled && el?.name && el?.sql?.replace) : [];
|
|
27
|
-
const cardSqlTable = cardSqlFiltered?.length ? cardSqlFiltered.map((el, i) => ` left join lateral (select json_agg(row_to_json(q)) as ${el.name} from (${el.sql})q) ct${i} on 1=1 `).join('') || '' : '';
|
|
28
|
-
|
|
29
|
-
const where = [`"${pk}" = $1`, loadTable.query].filter((el) => el);
|
|
30
|
-
const cardColumns = cardSqlFiltered?.length ? `,${cardSqlFiltered.map((el) => el.name)}` : '';
|
|
31
|
-
const q = `select ${pk ? `"${pk}" as id,` : ''} ${columnList.includes('geom') ? 'st_asgeojson(geom)::json as geom,' : ''} ${cols || '*'} ${cardColumns} from ${table} t ${sqlTable} ${cardSqlTable}
|
|
32
|
-
where ${where.join(' and ') || 'true'} limit 1`;
|
|
33
|
-
|
|
34
|
-
if (query.sql === '1') { return q; }
|
|
35
|
-
|
|
36
|
-
const { rows } = await pg.query(q, [opt.id || params.id]);
|
|
37
|
-
|
|
38
|
-
await metaFormat({ rows, table: params.table });
|
|
39
|
-
|
|
40
|
-
const data = meta.card?.length ? meta.card.reduce((acc, curr) => Object.assign(acc, { [columns.find((col) => col.name === curr)?.ua || '']: rows[0][curr] }), {}) : {};
|
|
41
|
-
return {
|
|
42
|
-
time: Date.now() - time, data,
|
|
43
|
-
};
|
|
44
|
-
}
|
|
1
|
+
import getTemplate from './utils/getTemplate.js';
|
|
2
|
+
import getMeta from '../../pg/funcs/getMeta.js';
|
|
3
|
+
import metaFormat from '../funcs/metaFormat/index.js';
|
|
4
|
+
|
|
5
|
+
export default async function card(req) {
|
|
6
|
+
const time = Date.now();
|
|
7
|
+
const {
|
|
8
|
+
pg, params = {}, query = {}, opt = {},
|
|
9
|
+
} = req;
|
|
10
|
+
|
|
11
|
+
const loadTable = await getTemplate('table', params.table);
|
|
12
|
+
|
|
13
|
+
if (!loadTable) { return { message: 'template not found', status: 404 }; }
|
|
14
|
+
|
|
15
|
+
const {
|
|
16
|
+
table, columns, meta, sql, cardSql,
|
|
17
|
+
} = loadTable;
|
|
18
|
+
|
|
19
|
+
const { pk, columns: dbColumns = [] } = await getMeta(table);
|
|
20
|
+
|
|
21
|
+
if (!pk) return { message: `table not found: ${table}`, status: 404 };
|
|
22
|
+
|
|
23
|
+
const cols = columns.map((el) => el.name || el).join(',');
|
|
24
|
+
const columnList = dbColumns.map((el) => el.name || el).join(',');
|
|
25
|
+
const sqlTable = sql?.filter?.((el) => !el?.disabled && el?.sql?.replace).map((el, i) => ` left join lateral (${el.sql}) ${el.name || `t${i}`} on 1=1 `)?.join('') || '';
|
|
26
|
+
const cardSqlFiltered = opt.id || params.id ? cardSql?.filter?.((el) => !el?.disabled && el?.name && el?.sql?.replace) : [];
|
|
27
|
+
const cardSqlTable = cardSqlFiltered?.length ? cardSqlFiltered.map((el, i) => ` left join lateral (select json_agg(row_to_json(q)) as ${el.name} from (${el.sql})q) ct${i} on 1=1 `).join('') || '' : '';
|
|
28
|
+
|
|
29
|
+
const where = [`"${pk}" = $1`, loadTable.query].filter((el) => el);
|
|
30
|
+
const cardColumns = cardSqlFiltered?.length ? `,${cardSqlFiltered.map((el) => el.name)}` : '';
|
|
31
|
+
const q = `select ${pk ? `"${pk}" as id,` : ''} ${columnList.includes('geom') ? 'st_asgeojson(geom)::json as geom,' : ''} ${cols || '*'} ${cardColumns} from ${table} t ${sqlTable} ${cardSqlTable}
|
|
32
|
+
where ${where.join(' and ') || 'true'} limit 1`;
|
|
33
|
+
|
|
34
|
+
if (query.sql === '1') { return q; }
|
|
35
|
+
|
|
36
|
+
const { rows } = await pg.query(q, [opt.id || params.id]);
|
|
37
|
+
|
|
38
|
+
await metaFormat({ rows, table: params.table });
|
|
39
|
+
|
|
40
|
+
const data = meta.card?.length ? meta.card.reduce((acc, curr) => Object.assign(acc, { [columns.find((col) => col.name === curr)?.ua || '']: rows[0][curr] }), {}) : {};
|
|
41
|
+
return {
|
|
42
|
+
time: Date.now() - time, data,
|
|
43
|
+
};
|
|
44
|
+
}
|