Eli Mesika has posted comments on this change.

Change subject: core, restapi: Add DbGroup
......................................................................


Patch Set 19:

(4 comments)

....................................................
File packaging/dbscripts/upgrade/03_04_0160_add_external_id_to_groups.sql
Line 1: -- Add a column to the groups table to store the identifier assigned by 
the
Line 2: -- external directory. This new comlumn is initialized with a copy of 
the
comlumn=>column
Line 3: -- identifier of the group, as before this change we used the external
Line 4: -- identifier also as internal identifier.
Line 5: 
Line 6: create or replace function __temp_add_external_id_to_groups() returns 
void


Line 5: 
Line 6: create or replace function __temp_add_external_id_to_groups() returns 
void
Line 7: as $function$
Line 8: begin
Line 9:   if (not exists (select 1 from information_schema.columns where 
table_name ilike 'ad_groups' and column_name ilike 'external_id')) then
Since this script will run once and is controlled by the update mechanism , 
scripts should not be re-entrant , there is no need to have that inside the SP 
and check for existence , you can simply leave just the "alter table " and 
update statements
Line 10:     alter table ad_groups add column external_id bytea not null 
default '';
Line 11:     update ad_groups set external_id = decode(replace(id::text, '-', 
''), 'hex');
Line 12:     perform fn_db_create_constraint('ad_groups', 
'groups_domain_external_id_unique', 'unique (domain, external_id)');
Line 13:   end if;


....................................................
File 
packaging/dbscripts/upgrade/03_04_0170_rename_user_and_group_status_to_active.sql
Line 5: create or replace function 
__temp_rename_user_and_group_status_to_active() returns void
Line 6: as $function$
Line 7: begin
Line 8:   -- Update the users table:
Line 9:   if (not exists (select 1 from information_schema.columns where 
table_name ilike 'users' and column_name ilike 'active')) then
Same here , no need for the if and SP
Line 10:     alter table users add column active boolean not null default false;
Line 11:     update users set active = status::boolean;
Line 12:     alter table users drop column status;
Line 13:   end if;


Line 12:     alter table users drop column status;
Line 13:   end if;
Line 14: 
Line 15:   -- Update the groups table:
Line 16:   if (not exists (select 1 from information_schema.columns where 
table_name ilike 'ad_groups' and column_name ilike 'active')) then
Same here , no need for the if
Line 17:     alter table ad_groups add column active boolean not null default 
false;
Line 18:     update ad_groups set active = status::boolean;
Line 19:     alter table ad_groups drop column status;
Line 20:   end if;


-- 
To view, visit http://gerrit.ovirt.org/17544
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Idb1a7146c29eb74f97e10043d65b5a67f1430021
Gerrit-PatchSet: 19
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Juan Hernandez <juan.hernan...@redhat.com>
Gerrit-Reviewer: Eli Mesika <emes...@redhat.com>
Gerrit-Reviewer: Juan Hernandez <juan.hernan...@redhat.com>
Gerrit-Reviewer: Liran Zelkha <lzel...@redhat.com>
Gerrit-Reviewer: Martin Peřina <mper...@redhat.com>
Gerrit-Reviewer: Michael Pasternak <mpast...@redhat.com>
Gerrit-Reviewer: Oved Ourfali <oourf...@redhat.com>
Gerrit-Reviewer: Ravi Nori <rn...@redhat.com>
Gerrit-Reviewer: Yair Zaslavsky <yzasl...@redhat.com>
Gerrit-Reviewer: mooli tayer <mta...@redhat.com>
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: Yes
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to