-- Deploy gaia:create_table_shoping_cart to mysql

BEGIN;

CREATE TABLE `api_shopcart` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `person_id` char(32) NOT NULL,
    `service_id` int(11) NOT NULL,
    `service_item_key` varchar(64) DEFAULT NULL,
    `added_at` datetime NOT NULL,
    PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

ALTER TABLE `api_shopcart` ADD CONSTRAINT `api_shopcart_person_id_ref_api_person` FOREIGN KEY (`person_id`) REFERENCES `api_person` (`id`) ON DELETE CASCADE;
ALTER TABLE `api_shopcart` ADD CONSTRAINT `api_shopcart_service_id_ref_api_service` FOREIGN KEY (`service_id`) REFERENCES `api_service` (`id`) ON DELETE CASCADE;

COMMIT;
