-- Deploy gaia:create_table_settlementitem to mysql

BEGIN;

CREATE TABLE `api_settlementitem` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `settlement_id` varchar(12) NOT NULL,
    `order_id` varchar(12) NOT NULL,
    `points_deduction` double DEFAULT NULL,
    PRIMARY KEY (`id`),
    UNIQUE KEY `order_id` (`order_id`),
    CONSTRAINT `api_settlementitem_settlement_id_ref_api_settlement_id` FOREIGN KEY (`settlement_id`) REFERENCES `api_settlement` (`id`) ON DELETE CASCADE,
    CONSTRAINT `api_settlementitem_order_id_ref_api_order_id` FOREIGN KEY (`order_id`) REFERENCES `api_order` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

COMMIT;
