#
# MySQL upgrade script for upgrade database from version 2.0.33 to 2.0.34
#


#-----------------------------------------------------------------------------
#-- address
#-----------------------------------------------------------------------------

ALTER TABLE `address`
      ADD `code` VARCHAR(255) AFTER `hierarchy_id`,
      ADD UNIQUE KEY `unique_code` (`code`);

#-----------------------------------------------------------------------------
#-- sf_guard_group
#-----------------------------------------------------------------------------

INSERT INTO sf_guard_group(name, description)
    VALUES ('Images manager', 'People allowed to manage image libraries contents');

INSERT INTO sf_guard_permission (name, description) VALUES ('viewTemplates', 'Access to template management with read-only permissions.');

INSERT INTO sf_guard_group_permission (group_id, permission_id)
        SELECT sf_guard_group.id, sf_guard_permission.id
        FROM sf_guard_group, sf_guard_permission
        WHERE
            sf_guard_permission.name = 'accessAdministration'
          AND
            sf_guard_group.name = 'Images manager';

INSERT INTO sf_guard_group_permission (group_id, permission_id)
        SELECT sf_guard_group.id, sf_guard_permission.id
        FROM sf_guard_group, sf_guard_permission
        WHERE
            sf_guard_permission.name = 'viewTemplates'
          AND
            sf_guard_group.name = 'Images manager';

INSERT INTO sf_guard_group_permission (group_id, permission_id)
        SELECT sf_guard_group.id, sf_guard_permission.id
        FROM sf_guard_group, sf_guard_permission
        WHERE
            sf_guard_permission.name = 'adminImageLibrarys'
          AND
            sf_guard_group.name = 'Images manager';





