Eli Mesika has posted comments on this change. Change subject: aaa: Change API to 3.3 behavior ......................................................................
Patch Set 10: (10 comments) http://gerrit.ovirt.org/#/c/25997/10/packaging/dbscripts/upgrade/03_05_0150_change_group_ids.sql File packaging/dbscripts/upgrade/03_05_0150_change_group_ids.sql: Line 11: substring(encode(external_id,'hex') FROM 17 FOR 4) || '-' || Line 12: substring(encode(external_id,'hex') FROM 21 FOR 12) AS uuid); Line 13: Line 14: --2. Changing relevant group_id appearances in other tables Line 15: ALTER TABLE tags_user_group_map DROP constraint "tags_user_map_user_group"; Instead of drop/create , you can do here ALTER TABLE tags_user_group_map DISABLE TRIGGER all; and to return it back ALTER TABLE tags_user_group_map ENABLE TRIGGER all; Line 16: Line 17: UPDATE tags_user_group_map m set group_id = ( Line 18: SELECT temp_id FROM ad_groups WHERE id = m.group_id Line 19: ); Line 28: tmp_users_groups Please add : ON COMMIT DROP to ensure that table is dropped at the end of the transaction Line 29: SELECT fnsplitteruuid(group_ids) as group_id, user_id from users; Line 30: UPDATE tmp_users_groups t SET group_id = ( Line 31: SELECT temp_id FROM ad_groups WHERE id = t.group_id Line 32: ); Line 33: CREATE temp TABLE tmp_users_group_ids AS Please add : ON COMMIT DROP to ensure that table is dropped at the end of the transaction Line 34: SELECT user_id, array_to_string(array_agg(group_id), ',') group_ids FROM tmp_users_groups GROUP BY user_id; Line 35: UPDATE users u SET group_ids = ( Line 36: SELECT group_ids FROM tmp_users_group_ids WHERE user_id = u.user_id Line 37: ); Line 37: ); > can we avoid the 2nd temp table and do something like Please ignore the above comment Line 36: SELECT group_ids FROM tmp_users_group_ids WHERE user_id = u.user_id Line 37: ); Line 38: UPDATE ad_groups SET id = temp_id; Line 39: --4. Cleanup Line 40: DROP TABLE tmp_users_group_ids; Not needed , handled by transaction Line 41: DROP TABLE tmp_users_groups; Line 42: ALTER TABLE tags_user_group_map ADD CONSTRAINT tags_user_map_user_group FOREIGN KEY (group_id) REFERENCES ad_groups(id); Line 37: ); Line 38: UPDATE ad_groups SET id = temp_id; Line 39: --4. Cleanup Line 40: DROP TABLE tmp_users_group_ids; Line 41: DROP TABLE tmp_users_groups; Not needed , handled by transaction Line 42: ALTER TABLE tags_user_group_map ADD CONSTRAINT tags_user_map_user_group FOREIGN KEY (group_id) REFERENCES ad_groups(id); Line 42: tags_user_group_map see 1st comment in this file http://gerrit.ovirt.org/#/c/25997/10/packaging/dbscripts/upgrade/03_05_0160_update_user_ids.sql File packaging/dbscripts/upgrade/03_05_0160_update_user_ids.sql: Line 11: substring(encode(external_id,'hex') FROM 17 FOR 4) || '-' || Line 12: substring(encode(external_id,'hex') FROM 21 FOR 12) AS uuid); Line 13: Line 14: --2. Changing relevant group_id appearances in other tables Line 15: ALTER TABLE tags_user_map DROP constraint "tags_user_map_user"; Instead of drop/create , you can do here ALTER TABLE tags_user_map DISABLE TRIGGER all; and to return it back ALTER TABLE tags_user_map ENABLE TRIGGER all; Line 16: UPDATE tags_user_map m set user_id = ( Line 17: SELECT temp_id FROM users WHERE user_id = m.user_id); Line 18: Line 19: UPDATE permissions p SET ad_element_id = ( Line 17: SELECT temp_id FROM users WHERE user_id = m.user_id); Line 18: Line 19: UPDATE permissions p SET ad_element_id = ( Line 20: SELECT temp_id FROM users u1 WHERE u1.user_id = p.ad_element_id Line 21: ) WHERE EXISTS ( Why do you need this WHERE, if it will not be found than UPDATE will do nothing , isn't it ??? Line 22: SELECT user_id from users where user_id = p.ad_element_id Line 23: ); Line 24: Line 25: UPDATE users SET user_id = temp_id; Line 23: ); Line 24: Line 25: UPDATE users SET user_id = temp_id; Line 26: --3. Cleanup Line 27: ALTER TABLE tags_user_map ADD CONSTRAINT tags_user_map_user FOREIGN KEY (user_id) REFERENCES users(user_id); see 1st comment in this file -- To view, visit http://gerrit.ovirt.org/25997 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Iff51fb9df33b4b679eba5b1c3ef2bea6ea7b3e07 Gerrit-PatchSet: 10 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Yair Zaslavsky <[email protected]> Gerrit-Reviewer: Alon Bar-Lev <[email protected]> Gerrit-Reviewer: Barak Azulay <[email protected]> Gerrit-Reviewer: Eli Mesika <[email protected]> Gerrit-Reviewer: Juan Hernandez <[email protected]> Gerrit-Reviewer: Yair Zaslavsky <[email protected]> Gerrit-Reviewer: [email protected] Gerrit-Reviewer: oVirt Jenkins CI Server Gerrit-HasComments: Yes _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
