-- Deploy gaia:api_2017_12_27_add_budan_luru_table to mysql

BEGIN;

-- XXX Add DDLs here.

CREATE TABLE `api_budanluru` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `doctor_id` varchar(100) NOT NULL,
    `month` integer NOT NULL,
    `amount` integer NOT NULL,
    `desc` varchar(1000) NOT NULL,
    `created_time` datetime(6) NOT NULL,
    `status` integer NOT NULL,
    `is_settle` bool NOT NULL
)
;
ALTER TABLE `api_budanluru` ADD CONSTRAINT `doctor_id_refs_id_e4c9ebee` FOREIGN KEY (`doctor_id`) REFERENCES `api_doctor` (`id`);
CREATE TABLE `api_budanluruoperate` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `budanluru_id` integer NOT NULL,
    `user_id` char(32) NOT NULL,
    `operate` integer NOT NULL,
    `created_time` datetime(6) NOT NULL
)
;
ALTER TABLE `api_budanluruoperate` ADD CONSTRAINT `user_id_refs_id_f3fb5246` FOREIGN KEY (`user_id`) REFERENCES `api_person` (`id`);
ALTER TABLE `api_budanluruoperate` ADD CONSTRAINT `budanluru_id_refs_id_ccdaa684` FOREIGN KEY (`budanluru_id`) REFERENCES `api_budanluru` (`id`);

COMMIT;
