· 5 years ago · Mar 16, 2020, 07:28 PM
1--constraints and indexes
2
3--sys_server--
4alter table sys_server
5 add constraint sys_server_pkey primary key (id);
6
7create unique index IDX_SYS_SERVER_UNIQ_NAME on SYS_SERVER (NAME);
8
9--sys_config--
10alter table sys_config
11 add constraint sys_config_pkey primary key (id);
12
13create unique index IDX_SYS_CONFIG_UNIQ_NAME on SYS_CONFIG (NAME);
14
15--sys_file--
16alter table sys_file
17 add constraint sys_file_pkey primary key (id);
18
19--sys_lock_config--
20alter table sys_lock_config
21 add constraint sys_lock_config_pkey primary key (id);
22
23--sys_entity_statistics--
24alter table sys_entity_statistics
25 add constraint sys_entity_statistics_pkey primary key (id);
26
27create unique index IDX_SYS_ENTITY_STATISTICS_UNIQ_NAME on SYS_ENTITY_STATISTICS (NAME);
28
29--sys_scheduled_task--
30alter table sys_scheduled_task
31 add constraint sys_scheduled_task_pkey primary key (id);
32
33alter table sys_scheduled_execution
34 add constraint sys_scheduled_execution_pkey primary key (id);
35
36alter table sys_scheduled_execution
37 add constraint SYS_SCHEDULED_EXECUTION_TASK foreign key (TASK_ID) references SYS_SCHEDULED_TASK (ID);
38
39create index IDX_SYS_SCHEDULED_EXECUTION_TASK_START_TIME on SYS_SCHEDULED_EXECUTION (TASK_ID, START_TIME);
40create index IDX_SYS_SCHEDULED_EXECUTION_TASK_FINISH_TIME on SYS_SCHEDULED_EXECUTION (TASK_ID, FINISH_TIME);
41
42--sec_role--
43alter table sec_role
44 add constraint sec_role_pkey primary key (id);
45
46--sec_group--
47alter table sec_group
48 add constraint sec_group_pkey primary key (id);
49
50alter table sec_group
51 add constraint SEC_GROUP_PARENT foreign key (PARENT_ID) references SEC_GROUP (ID);
52
53--sec_group_hierarchy--
54alter table sec_group_hierarchy
55 add constraint sec_group_hierarchy_pkey primary key (id);
56
57alter table sec_group_hierarchy
58 add constraint SEC_GROUP_HIERARCHY_GROUP foreign key (GROUP_ID) references SEC_GROUP (ID);
59
60alter table sec_group_hierarchy
61 add constraint SEC_GROUP_HIERARCHY_PARENT foreign key (PARENT_ID) references SEC_GROUP (ID);
62
63
64--sec_user--
65alter table sec_user
66 add constraint sec_user_pkey primary key (id);
67
68alter table sec_user
69 add constraint SEC_USER_GROUP foreign key (GROUP_ID) references SEC_GROUP (ID);
70
71
72--sec_user_role--
73alter table sec_user_role
74 add constraint sec_user_role_pkey primary key (id);
75
76alter table sec_user_role
77 add constraint SEC_USER_ROLE_PROFILE foreign key (USER_ID) references SEC_USER (ID);
78
79alter table sec_user_role
80 add constraint SEC_USER_ROLE_ROLE foreign key (ROLE_ID) references SEC_ROLE (ID);
81
82create unique index IDX_SEC_USER_ROLE_UNIQ_ROLE on SEC_USER_ROLE (USER_ID, ROLE_ID) where DELETE_TS is null;
83
84--sec_permission--
85alter table sec_permission
86 add constraint sec_permission_pkey primary key (id);
87
88alter table sec_permission
89 add constraint SEC_PERMISSION_ROLE foreign key (ROLE_ID) references SEC_ROLE (ID);
90
91create unique index IDX_SEC_PERMISSION_UNIQUE on SEC_PERMISSION (ROLE_ID, PERMISSION_TYPE, TARGET) where DELETE_TS is null;
92
93--sec_constraint--
94alter table sec_constraint
95 add constraint sec_constraint_pkey primary key (id);
96
97alter table sec_constraint
98 add constraint SEC_CONSTRAINT_GROUP foreign key (GROUP_ID) references SEC_GROUP (ID);
99
100create index IDX_SEC_CONSTRAINT_GROUP on SEC_CONSTRAINT (GROUP_ID);
101
102--sec_localized_constraint_msg--
103alter table sec_localized_constraint_msg
104 add constraint sec_localized_constraint_msg_pkey primary key (id);
105
106create unique index IDX_SEC_LOC_CNSTRNT_MSG_UNIQUE
107 on SEC_LOCALIZED_CONSTRAINT_MSG (ENTITY_NAME, OPERATION_TYPE)
108 where DELETE_TS is null;
109
110
111--sec_session_attr--
112alter table sec_session_attr
113 add constraint sec_session_attr_pkey primary key (id);
114
115alter table sec_session_attr
116 add constraint SEC_SESSION_ATTR_GROUP foreign key (GROUP_ID) references SEC_GROUP (ID);
117
118create index IDX_SEC_SESSION_ATTR_GROUP on SEC_SESSION_ATTR (GROUP_ID);
119
120
121--sec_user_setting--
122alter table sec_user_setting
123 add constraint sec_user_setting_pkey primary key (id);
124
125alter table sec_user_setting
126 add constraint SEC_USER_SETTING_USER foreign key (USER_ID) references SEC_USER (ID);
127
128alter table sec_user_setting
129 add constraint SEC_USER_SETTING_UNIQ unique (USER_ID, NAME, CLIENT_TYPE);
130
131
132--sec_user_substitution--
133alter table sec_user_substitution
134 add constraint sec_user_substitution_pkey primary key (id);
135
136alter table sec_user_substitution
137 add constraint FK_SEC_USER_SUBSTITUTION_USER foreign key (USER_ID) references SEC_USER (ID);
138
139alter table sec_user_substitution
140 add constraint FK_SEC_USER_SUBSTITUTION_SUBSTITUTED_USER foreign key (SUBSTITUTED_USER_ID) references SEC_USER (ID);
141
142create index IDX_SEC_USER_SUBSTITUTION_USER on SEC_USER_SUBSTITUTION (USER_ID);
143
144
145--sec_logged_entity--
146alter table sec_logged_entity
147 add constraint sec_logged_entity_pkey primary key (id);
148
149alter table sec_logged_entity
150 add constraint SEC_LOGGED_ENTITY_UNIQ_NAME unique (NAME);
151
152
153--sec_logged_attr--
154alter table sec_logged_attr
155 add constraint sec_logged_attr_pkey primary key (id);
156
157alter table sec_logged_attr
158 add constraint FK_SEC_LOGGED_ATTR_ENTITY foreign key (ENTITY_ID) references SEC_LOGGED_ENTITY (ID);
159
160alter table sec_logged_attr
161 add constraint SEC_LOGGED_ATTR_UNIQ_NAME unique (ENTITY_ID, NAME);
162
163create index IDX_SEC_LOGGED_ATTR_ENTITY on SEC_LOGGED_ATTR (ENTITY_ID);
164
165
166--sec_entity_log--
167alter table sec_entity_log
168 add constraint sec_entity_log_pkey primary key (id);
169
170alter table sec_entity_log
171 add constraint FK_SEC_ENTITY_LOG_USER foreign key (USER_ID) references SEC_USER (ID);
172
173create index IDX_SEC_ENTITY_LOG_ENTITY_ID on SEC_ENTITY_LOG (ENTITY_ID);
174create index IDX_SEC_ENTITY_LOG_SENTITY_ID on SEC_ENTITY_LOG (STRING_ENTITY_ID);
175create index IDX_SEC_ENTITY_LOG_IENTITY_ID on SEC_ENTITY_LOG (INT_ENTITY_ID);
176create index IDX_SEC_ENTITY_LOG_LENTITY_ID on SEC_ENTITY_LOG (LONG_ENTITY_ID);
177
178
179--sec_filter--
180alter table sec_filter
181 add constraint sec_filter_pkey primary key (id);
182
183alter table sec_filter
184 add constraint FK_SEC_FILTER_USER foreign key (USER_ID) references SEC_USER (ID);
185
186create index IDX_SEC_FILTER_COMPONENT_USER on SEC_FILTER (COMPONENT, USER_ID);
187
188--sys_folder--
189alter table sys_folder
190 add constraint sys_folder_pkey primary key (id);
191
192alter table sys_folder
193 add constraint FK_SYS_FOLDER_PARENT foreign key (PARENT_ID) references SYS_FOLDER (ID);
194
195--sys_app_folder--
196alter table sys_app_folder
197 add constraint sys_app_folder_pkey primary key (folder_id);
198
199alter table sys_app_folder
200 add constraint FK_SYS_APP_FOLDER_FOLDER foreign key (FOLDER_ID) references SYS_FOLDER (ID);
201
202--sec_presentation--
203alter table sec_presentation
204 add constraint sec_presentation_pkey primary key (id);
205
206alter table sec_presentation
207 add constraint SEC_PRESENTATION_USER foreign key (USER_ID) references SEC_USER (ID);
208
209create index IDX_SEC_PRESENTATION_COMPONENT_USER on SEC_PRESENTATION (COMPONENT, USER_ID);
210
211
212--sec_search_folder--
213alter table sec_search_folder
214 add constraint sec_search_folder_pkey primary key (folder_id);
215
216alter table sec_search_folder
217 add constraint FK_SEC_SEARCH_FOLDER_FOLDER foreign key (FOLDER_ID) references SYS_FOLDER (ID);
218
219alter table sec_search_folder
220 add constraint FK_SEC_SEARCH_FOLDER_USER foreign key (USER_ID) references SEC_USER (ID);
221
222alter table sec_search_folder
223 add constraint FK_SEC_SEARCH_FOLDER_PRESENTATION foreign key (PRESENTATION_ID)
224 references SEC_PRESENTATION (ID)
225 on delete set null;
226
227create index IDX_SEC_SEARCH_FOLDER_USER on SEC_SEARCH_FOLDER (USER_ID);
228
229
230--sys_fts_queue--
231alter table sys_fts_queue
232 add constraint sys_fts_queue_pkey primary key (id);
233
234create index IDX_SYS_FTS_QUEUE_IDXHOST_CRTS on SYS_FTS_QUEUE (INDEXING_HOST, CREATE_TS);
235
236--sec_screen_history--
237alter table sec_screen_history
238 add constraint sec_screen_history_pkey primary key (id);
239
240alter table sec_screen_history
241 add constraint FK_SEC_HISTORY_USER foreign key (USER_ID) references SEC_USER (ID);
242
243alter table sec_screen_history
244 add constraint FK_SEC_HISTORY_SUBSTITUTED_USER foreign key (SUBSTITUTED_USER_ID) references SEC_USER (ID);
245
246create index IDX_SEC_SCREEN_HISTORY_USER on SEC_SCREEN_HISTORY (USER_ID);
247create index IDX_SEC_SCREEN_HIST_SUB_USER on SEC_SCREEN_HISTORY (SUBSTITUTED_USER_ID);
248
249
250--sys_sending_message--
251alter table sys_sending_message
252 add constraint sys_sending_message_pkey primary key (id);
253
254alter table sys_sending_message
255 add constraint FK_SYS_SENDING_MESSAGE_CONTENT_FILE foreign key (CONTENT_TEXT_FILE_ID) references SYS_FILE (ID);
256
257create index IDX_SYS_SENDING_MESSAGE_STATUS on SYS_SENDING_MESSAGE (STATUS);
258create index IDX_SYS_SENDING_MESSAGE_DATE_SENT on SYS_SENDING_MESSAGE (DATE_SENT);
259create index IDX_SYS_SENDING_MESSAGE_UPDATE_TS on SYS_SENDING_MESSAGE (UPDATE_TS);
260
261--sys_sending_attachment--
262alter table sys_sending_attachment
263 add constraint sys_sending_attachment_pkey primary key (id);
264
265alter table sys_sending_attachment
266 add constraint FK_SYS_SENDING_ATTACHMENT_SENDING_MESSAGE foreign key (MESSAGE_ID) references SYS_SENDING_MESSAGE (ID);
267
268alter table sys_sending_attachment
269 add constraint FK_SYS_SENDING_ATTACHMENT_CONTENT_FILE foreign key (CONTENT_FILE_ID) references SYS_FILE (ID);
270
271create index SYS_SENDING_ATTACHMENT_MESSAGE_IDX on SYS_SENDING_ATTACHMENT (MESSAGE_ID);
272
273
274--sys_entity_snapshot--
275alter table sys_entity_snapshot
276 add constraint sys_entity_snapshot_pkey primary key (id);
277
278alter table sys_entity_snapshot
279 add constraint FK_SYS_ENTITY_SNAPSHOT_AUTHOR_ID foreign key (AUTHOR_ID) references SEC_USER (ID);
280
281create index IDX_SYS_ENTITY_SNAPSHOT_ENTITY_ID on SYS_ENTITY_SNAPSHOT (ENTITY_ID);
282create index IDX_SYS_ENTITY_SNAPSHOT_SENTITY_ID on SYS_ENTITY_SNAPSHOT (STRING_ENTITY_ID);
283create index IDX_SYS_ENTITY_SNAPSHOT_IENTITY_ID on SYS_ENTITY_SNAPSHOT (INT_ENTITY_ID);
284create index IDX_SYS_ENTITY_SNAPSHOT_LENTITY_ID on SYS_ENTITY_SNAPSHOT (LONG_ENTITY_ID);
285
286
287--sys_category--
288alter table sys_category
289 add constraint sys_category_pkey primary key (id);
290
291create unique index IDX_SYS_CATEGORY_UNIQ_NAME_ENTITY_TYPE on SYS_CATEGORY (NAME, ENTITY_TYPE) where DELETE_TS is null;
292
293
294--sys_category_attr--
295alter table sys_category_attr
296 add constraint sys_category_attr_pkey primary key (id);
297
298alter table sys_category_attr
299 add constraint SYS_CATEGORY_ATTR_CATEGORY_ID foreign key (CATEGORY_ID) references SYS_CATEGORY (ID);
300
301create index IDX_SYS_CATEGORY_ATTR_CATEGORY on SYS_CATEGORY_ATTR (CATEGORY_ID);
302create unique index IDX_CAT_ATTR_ENT_TYPE_AND_CODE on SYS_CATEGORY_ATTR (CATEGORY_ENTITY_TYPE, CODE) where DELETE_TS is null;
303
304
305--sys_attr_value--
306alter table sys_attr_value
307 add constraint sys_attr_value_pkey primary key (id);
308
309alter table sys_attr_value
310 add constraint SYS_ATTR_VALUE_CATEGORY_ATTR_ID foreign key (CATEGORY_ATTR_ID) references SYS_CATEGORY_ATTR (ID);
311
312alter table sys_attr_value
313 add constraint SYS_ATTR_VALUE_ATTR_VALUE_PARENT_ID foreign key (PARENT_ID) references SYS_ATTR_VALUE (ID);
314
315create index IDX_SYS_ATTR_VALUE_ENTITY on SYS_ATTR_VALUE (ENTITY_ID);
316create index IDX_SYS_ATTR_VALUE_SENTITY on SYS_ATTR_VALUE (STRING_ENTITY_ID);
317create index IDX_SYS_ATTR_VALUE_IENTITY on SYS_ATTR_VALUE (INT_ENTITY_ID);
318create index IDX_SYS_ATTR_VALUE_LENTITY on SYS_ATTR_VALUE (LONG_ENTITY_ID);
319
320
321--sys_jmx_instance--
322alter table sys_jmx_instance
323 add constraint sys_jmx_instance_pkey primary key (id);
324
325--sys_query_result--
326alter table sys_query_result
327 add constraint sys_query_result_pkey primary key (id);
328
329create index IDX_SYS_QUERY_RESULT_ENTITY_SESSION_KEY on SYS_QUERY_RESULT (ENTITY_ID, SESSION_ID, QUERY_KEY);
330create index IDX_SYS_QUERY_RESULT_SENTITY_SESSION_KEY on SYS_QUERY_RESULT (STRING_ENTITY_ID, SESSION_ID, QUERY_KEY);
331create index IDX_SYS_QUERY_RESULT_IENTITY_SESSION_KEY on SYS_QUERY_RESULT (INT_ENTITY_ID, SESSION_ID, QUERY_KEY);
332create index IDX_SYS_QUERY_RESULT_LENTITY_SESSION_KEY on SYS_QUERY_RESULT (LONG_ENTITY_ID, SESSION_ID, QUERY_KEY);
333create index IDX_SYS_QUERY_RESULT_SESSION_KEY on SYS_QUERY_RESULT (SESSION_ID, QUERY_KEY);
334
335
336--sec_remember_me--
337alter table sec_remember_me
338 add constraint sec_remember_me_pkey primary key (id);
339
340alter table sec_remember_me
341 add constraint FK_SEC_REMEMBER_ME_USER foreign key (USER_ID) references SEC_USER (ID);
342
343create index IDX_SEC_REMEMBER_ME_USER on SEC_REMEMBER_ME (USER_ID);
344create index IDX_SEC_REMEMBER_ME_TOKEN on SEC_REMEMBER_ME (TOKEN);
345
346--sec_session_log--
347alter table sec_session_log
348 add constraint sec_session_log_pkey primary key (id);
349
350alter table SEC_SESSION_LOG
351 add constraint FK_SEC_SESSION_LOG_USER foreign key (USER_ID) references SEC_USER (ID);
352create index IDX_SEC_SESSION_LOG_USER on SEC_SESSION_LOG (USER_ID);
353alter table SEC_SESSION_LOG
354 add constraint FK_SEC_SESSION_LOG_SUBUSER foreign key (SUBSTITUTED_USER_ID) references SEC_USER (ID);
355create index IDX_SEC_SESSION_LOG_SUBUSER on SEC_SESSION_LOG (SUBSTITUTED_USER_ID);
356create index IDX_SEC_SESSION_LOG_SESSION on SEC_SESSION_LOG (SESSION_ID);
357create index IDX_SESSION_LOG_STARTED_TS on SEC_SESSION_LOG (STARTED_TS DESC);
358
359--inserts--
360
361insert into SEC_FILTER (ID, CREATE_TS, CREATED_BY, VERSION, COMPONENT, NAME, XML, USER_ID, GLOBAL_DEFAULT)
362values ('b61d18cb-e79a-46f3-b16d-eaf4aebb10dd', now(), 'admin', 0, '[sec$User.browse].genericFilter', 'Search by role',
363 '<?xml version="1.0" encoding="UTF-8"?><filter><and><c name="UrMxpkfMGn" class="com.haulmont.cuba.security.entity.Role" type="CUSTOM" locCaption="Role" entityAlias="u" join="join u.userRoles ur">ur.role.id = :component$genericFilter.UrMxpkfMGn32565<param name="component$genericFilter.UrMxpkfMGn32565">NULL</param></c></and></filter>',
364 '60885987-1b61-4247-94c7-dff348347f93', false);
365
366/*updates 18*/
367
368-- Increase scale for double value
369alter table SYS_CATEGORY_ATTR alter column DEFAULT_DOUBLE type numeric(36,6);
370alter table SYS_ATTR_VALUE alter column DOUBLE_VALUE type numeric(36,6);
371
372-- add not null constraints for SYS_CONFIG
373drop index if exists IDX_SYS_CONFIG_UNIQ_NAME;
374alter table SYS_CONFIG alter column NAME set not null;
375alter table SYS_CONFIG alter column VALUE_ set not null;
376create unique index IDX_SYS_CONFIG_UNIQ_NAME on SYS_CONFIG (NAME);
377
378--Add ability to specify CC and BCC email addresses to EmailInfo
379alter table SYS_SENDING_MESSAGE add ADDRESS_CC text;
380alter table SYS_SENDING_MESSAGE add ADDRESS_BCC text;
381
382--Add more strong password hashing algorithm
383alter table SEC_USER add PASSWORD_ENCRYPTION varchar(50);
384
385--ScreenHistorySupport assumes all entities have id of type UUID
386alter table SEC_SCREEN_HISTORY add STRING_ENTITY_ID varchar(255);
387alter table SEC_SCREEN_HISTORY add INT_ENTITY_ID integer;
388alter table SEC_SCREEN_HISTORY add LONG_ENTITY_ID bigint;
389create index IDX_SEC_SCREEN_HISTORY_ENTITY_ID on SEC_SCREEN_HISTORY (ENTITY_ID);
390create index IDX_SEC_SCREEN_HISTORY_SENTITY_ID on SEC_SCREEN_HISTORY (STRING_ENTITY_ID);
391create index IDX_SEC_SCREEN_HISTORY_IENTITY_ID on SEC_SCREEN_HISTORY (INT_ENTITY_ID);
392create index IDX_SEC_SCREEN_HISTORY_LENTITY_ID on SEC_SCREEN_HISTORY (LONG_ENTITY_ID);
393
394
395/*updates 19*/
396
397--Store modified instance's name in entity log
398alter table SEC_ENTITY_LOG add ENTITY_INSTANCE_NAME varchar(1000);
399
400--SQLSyntaxErrorException is occurred when opening Scheduled Task screen
401-- Rename PERIOD columns
402alter table SYS_SCHEDULED_TASK add PERIOD_ integer;
403update SYS_SCHEDULED_TASK set PERIOD_ = PERIOD;
404
405--DateWithoutTime datatype for dynamic attributes was added
406alter table SYS_CATEGORY_ATTR add DEFAULT_DATE_WO_TIME date;
407alter table SYS_ATTR_VALUE add DATE_WO_TIME_VALUE date;
408
409--add Description Field For Dynamic Attributes
410alter table SYS_CATEGORY_ATTR add DESCRIPTION varchar(1000);
411alter table SYS_CATEGORY_ATTR add LOCALE_DESCRIPTIONS varchar(4000);
412
413--added ability to create roles in the source code
414alter table SEC_USER_ROLE add ROLE_NAME varchar(50);
415
416--Dynamic attributes improvements
417alter table SYS_CATEGORY_ATTR add DEFAULT_DECIMAL numeric(36,10);
418alter table SYS_ATTR_VALUE add DECIMAL_VALUE numeric(36,10);
419alter table SYS_CATEGORY_ATTR add ATTRIBUTE_CONFIGURATION_JSON text;
420
421--Design time security groups and constraints
422alter table SEC_USER add GROUP_NAMES varchar(255);
423alter table SEC_USER alter column GROUP_ID drop not null;
424
425--Simplify creating multi-tenant applications
426alter table SYS_FILE add SYS_TENANT_ID varchar(255);
427alter table SYS_SCHEDULED_TASK add SYS_TENANT_ID varchar(255);
428alter table SYS_SCHEDULED_EXECUTION add SYS_TENANT_ID varchar(255);
429alter table SEC_ROLE add SYS_TENANT_ID varchar(255);
430alter table SEC_GROUP add SYS_TENANT_ID varchar(255);
431alter table SEC_GROUP_HIERARCHY add SYS_TENANT_ID varchar(255);
432alter table SEC_USER add SYS_TENANT_ID varchar(255);
433alter table SEC_CONSTRAINT add SYS_TENANT_ID varchar(255);
434alter table SEC_SESSION_ATTR add SYS_TENANT_ID varchar(255);
435alter table SEC_USER_SUBSTITUTION add SYS_TENANT_ID varchar(255);
436alter table SEC_ENTITY_LOG add SYS_TENANT_ID varchar(255);
437alter table SEC_FILTER add SYS_TENANT_ID varchar(255);
438alter table SYS_FOLDER add SYS_TENANT_ID varchar(255);
439alter table SEC_PRESENTATION add SYS_TENANT_ID varchar(255);
440alter table SEC_SCREEN_HISTORY add SYS_TENANT_ID varchar(255);
441alter table SYS_SENDING_MESSAGE add SYS_TENANT_ID varchar(255);
442alter table SYS_SENDING_ATTACHMENT add SYS_TENANT_ID varchar(255);
443alter table SYS_ENTITY_SNAPSHOT add SYS_TENANT_ID varchar(255);
444alter table SEC_SESSION_LOG add SYS_TENANT_ID varchar(255);
445drop index if exists IDX_SEC_USER_UNIQ_LOGIN;
446create unique index IDX_SEC_USER_UNIQ_LOGIN on SEC_USER (LOGIN_LC) where DELETE_TS is null and SYS_TENANT_ID is null;
447create unique index IDX_SEC_USER_UNIQ_LOGIN_SYS_TENANT_ID_NN on SEC_USER (LOGIN_LC, SYS_TENANT_ID)
448 where DELETE_TS is null and SYS_TENANT_ID is not null;
449drop index if exists IDX_SEC_ROLE_UNIQ_NAME;
450create unique index IDX_SEC_ROLE_UNIQ_NAME on SEC_ROLE (NAME) where DELETE_TS is null and SYS_TENANT_ID is null;
451create unique index IDX_SEC_ROLE_UNIQ_NAME_SYS_TENANT_ID_NN on SEC_ROLE (NAME, SYS_TENANT_ID)
452 where DELETE_TS is null and SYS_TENANT_ID is not null;
453drop index if exists IDX_SEC_GROUP_UNIQ_NAME;
454create unique index IDX_SEC_GROUP_UNIQ_NAME on SEC_GROUP (NAME) where DELETE_TS is null and SYS_TENANT_ID is null;
455create unique index IDX_SEC_GROUP_UNIQ_NAME_SYS_TENANT_ID_NN on SEC_GROUP (NAME, SYS_TENANT_ID)
456 where DELETE_TS is null and SYS_TENANT_ID is not null;
457
458--Default role permissions
459alter table SEC_ROLE add SECURITY_SCOPE varchar(255);
460update SEC_ROLE set SECURITY_SCOPE = 'GENERIC_UI';