-- Deploy gaia:api_2015_11_13_create_table_api_specialseckillservice to mysql

BEGIN;

CREATE TABLE `api_specialseckillservice` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `service_id` integer NOT NULL,
    `special_id` integer NOT NULL,
    `seckill_price` integer NOT NULL,
    `pre_payment_price` integer NOT NULL,
    `stock` integer,
    `commission` integer NOT NULL,
    `buy_up_to` integer NOT NULL,
    `start_time` datetime(6) NOT NULL,
    `end_time` datetime(6),
    `tip` varchar(128) NOT NULL,
    UNIQUE (`service_id`, `special_id`)
)
;
ALTER TABLE `api_specialseckillservice` ADD CONSTRAINT `special_id_refs_id_f81cbca7` FOREIGN KEY (`special_id`) REFERENCES `api_special` (`id`);
ALTER TABLE `api_specialseckillservice` ADD CONSTRAINT `service_id_refs_id_122a878e` FOREIGN KEY (`service_id`) REFERENCES `api_service` (`id`);

ALTER TABLE `api_service` MODIFY COLUMN `is_seckill` tinyint(1) DEFAULT NULL;
ALTER TABLE `api_service` MODIFY COLUMN `seckill_price` int(11) DEFAULT NULL;

COMMIT;
