-- Deploy gaia:pay_2016_03_04_create_tables_for_pay_settlement to mysql

BEGIN;

CREATE TABLE `pay_alipaysettlement` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `settlement_id` varchar(12) NOT NULL,
    `trade_no` varchar(64),
    `trade_status` varchar(32),
    `origin_data` longtext,
    `buyer_id` varchar(30),
    `buyer_email` varchar(254),
    `total_fee` double precision,
    `gmt_create` datetime(6),
    `gmt_payment` datetime(6),
    `created_time` datetime(6) NOT NULL
)
;
ALTER TABLE `pay_alipaysettlement` ADD CONSTRAINT `settlement_id_refs_id_623d3f53`
FOREIGN KEY (`settlement_id`) REFERENCES `api_settlement` (`id`);
CREATE TABLE `pay_wechatsettlement` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `settlement_id` varchar(12) NOT NULL,
    `appid` varchar(32) NOT NULL,
    `bank_type` varchar(32) NOT NULL,
    `cash_fee` integer NOT NULL,
    `fee_type` varchar(16) NOT NULL,
    `is_subscribe` varchar(4) NOT NULL,
    `mch_id` varchar(32) NOT NULL,
    `nonce_str` varchar(32) NOT NULL,
    `openid` varchar(32) NOT NULL,
    `out_trade_no` varchar(32) NOT NULL,
    `result_code` varchar(32) NOT NULL,
    `sign` varchar(32) NOT NULL,
    `total_fee` DOUBLE PRECISION NOT NULL,
    `time_end` varchar(32) NOT NULL,
    `trade_type` varchar(16) NOT NULL,
    `transaction_id` varchar(32) NOT NULL,
    `created_time` datetime(6) NOT NULL
)
;
ALTER TABLE `pay_wechatsettlement` ADD CONSTRAINT `settlement_id_refs_id_f1c88d8a`
FOREIGN KEY (`settlement_id`) REFERENCES `api_settlement` (`id`);

COMMIT;
