-- Deploy gaia:add_table_api_settlement to mysql

BEGIN;

CREATE TABLE `api_settlement` (
    `id` varchar(12) NOT NULL,
    `name` varchar(255) NOT NULL,
    `person_id` char(32) NOT NULL,
    `use_coupon_type` varchar(1) NOT NULL,
    `service_payment_type` varchar(1) NOT NULL,
    `status` varchar(1) NOT NULL,
    `payment` double NOT NULL,
    `pay_callback_info` longtext NOT NULL,
    `points_deduction` double DEFAULT NULL,
    `coupon_deduction` double DEFAULT NULL,
    `created_at` datetime NOT NULL,
    `expired_at` datetime NOT NULL,
    PRIMARY KEY (`id`),
    CONSTRAINT `api_settlement_ref_api_person` FOREIGN KEY (`person_id`) REFERENCES `api_person` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

COMMIT;
