-- Deploy gaia:2016_08_11_yinuo to mysql

BEGIN;

ALTER TABLE `api_service` ADD COLUMN `is_insurance` BOOL NOT NULL;
CREATE TABLE `pay_policyholder` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `user_id` integer NOT NULL UNIQUE,
    `id_card` varchar(34) NOT NULL,
    `name` varchar(34) NOT NULL,
    `created_time` datetime(6) NOT NULL
)
;
ALTER TABLE `pay_policyholder` ADD CONSTRAINT `user_id_refs_id_70029fc3` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`);
CREATE TABLE `pay_yinuoorder` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `order_id` varchar(12) NOT NULL UNIQUE,
    `payment_id` varchar(16) NOT NULL,
    `premium` integer NOT NULL,
    `yinuo_id` varchar(16),
    `credential_id` varchar(40),
    `confirmed_at` datetime(6),
    `paid_at` datetime(6),
    `created_at` datetime(6),
    `expiration` integer NOT NULL
)
;
ALTER TABLE `pay_yinuoorder` ADD CONSTRAINT `order_id_refs_id_0fa0d72c` FOREIGN KEY (`order_id`) REFERENCES `api_order` (`id`);
ALTER TABLE `pay_servicesnapshot` ADD COLUMN `is_insurance` BOOL NOT NULL;
COMMIT;