#
# MySQL upgrade script for upgrade database from version 2.0.25 to 2.0.26
#

 

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


CREATE TABLE `address`
(
	`id` INTEGER  NOT NULL AUTO_INCREMENT,
	`hierarchy_id` INTEGER  NOT NULL,
	`important_address` INTEGER default 0 NOT NULL,
	`for_delivery` INTEGER default 1 NOT NULL,
	`for_billing` INTEGER default 1 NOT NULL,
	`name` VARCHAR(256)  NOT NULL,
	`address` VARCHAR(512)  NOT NULL,
	`zipcode` VARCHAR(5)  NOT NULL,
	`city` VARCHAR(256)  NOT NULL,
	`country` VARCHAR(256)  NOT NULL,
	`created_at` DATETIME,
	`updated_at` DATETIME,
	PRIMARY KEY (`id`),
	INDEX `address_FI_1` (`hierarchy_id`),
	CONSTRAINT `address_FK_1`
		FOREIGN KEY (`hierarchy_id`)
		REFERENCES `hierarchy` (`id`)
)Type=InnoDB;

#-----------------------------------------------------------------------------
#-- Adding new credentials
#-----------------------------------------------------------------------------
INSERT INTO sf_guard_permission (name, description) VALUES ('manageAddresses', 'allow to manage addresses');

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 = 'manageAddresses'
          AND
            sf_guard_group.name = 'admin';

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 = 'manageAddresses'
          AND
            sf_guard_group.name = 'Global Administrator';

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 = 'manageAddresses'
          AND
            sf_guard_group.name = 'Local Administrator';


