Skip to content

Commit

Permalink
IN: Update old access tables with new tab IDs
Browse files Browse the repository at this point in the history
This have to be done in order to make new access structure migration
working.
  • Loading branch information
soullivaneuh committed Dec 13, 2017
1 parent d945628 commit 705b294
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion install-dev/upgrade/sql/1.7.0.0.sql
Expand Up @@ -119,7 +119,9 @@ CREATE TABLE `PREFIX_authorization_role` (
UNIQUE KEY (`slug`)
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;

RENAME TABLE `PREFIX_access` TO `PREFIX_access_old`;
/* Create a copy without indexes to make ID updates without conflict. */
CREATE TABLE `PREFIX_access_old` AS SELECT * FROM `PREFIX_access`;
DROP TABLE `PREFIX_access`;
RENAME TABLE `PREFIX_module_access` TO `PREFIX_module_access_old`;

CREATE TABLE `PREFIX_tab_transit` (
Expand Down Expand Up @@ -218,6 +220,12 @@ UPDATE `PREFIX_employee` e SET `default_tab` = (
) FROM `PREFIX_tab_transit` WHERE `id_old_tab` = e.`default_tab`
);

/* Update access tab IDs */
UPDATE `PREFIX_access_old` ao SET `id_tab` = (
/* Update tab ID if possible, leave as is if the tab does not exist anymore */
SELECT IFNULL(`id_new_tab`, ao.`id_tab`) FROM `PREFIX_tab_transit` WHERE `id_old_tab` = ao.`id_tab`
);

/* Properly migrate the rights associated with each tabs */
/* PHP:ps_1700_right_management(); */;

Expand Down

0 comments on commit 705b294

Please sign in to comment.