2024-03-14 13:38:42 +00:00
|
|
|
-- +migrate Up
|
|
|
|
CREATE TABLE `kind_boxes` (
|
|
|
|
`id` INT PRIMARY KEY AUTO_INCREMENT,
|
|
|
|
`kind_box_req_id` INT NOT NULL,
|
|
|
|
`benefactor_id` INT NOT NULL,
|
|
|
|
`type` ENUM('on-table','cylindrical','stand-up') NOT NULL,
|
|
|
|
`amount` INT UNSIGNED,
|
2024-07-12 21:25:20 +00:00
|
|
|
`serial_number` VARCHAR(191) UNIQUE,
|
2024-03-14 13:38:42 +00:00
|
|
|
`status` ENUM('delivered','ready-to-return','assigned-receiver-agent','returned','enumerated') NOT NULL,
|
2024-07-12 21:25:20 +00:00
|
|
|
`deliver_refer_time_id` INT NOT NULL,
|
2024-03-14 13:38:42 +00:00
|
|
|
`deliver_refer_date` DATETIME NOT NULL,
|
|
|
|
`deliver_address_id` INT NOT NULL,
|
|
|
|
`sender_agent_id` INT NOT NULL,
|
|
|
|
`delivered_at` DATETIME NOT NULL,
|
2024-06-25 21:58:11 +00:00
|
|
|
`return_refer_time_id` INT,
|
2024-03-14 13:38:42 +00:00
|
|
|
`return_refer_date` DATETIME,
|
|
|
|
`return_address_id` INT,
|
|
|
|
`receiver_agent_id` INT,
|
|
|
|
`returned_at` DATETIME,
|
|
|
|
|
|
|
|
`created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
2024-05-17 20:16:28 +00:00
|
|
|
`updated_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
2024-06-25 21:58:11 +00:00
|
|
|
`deleted_at` TIMESTAMP NULL,
|
2024-07-12 21:25:20 +00:00
|
|
|
FOREIGN KEY (`kind_box_req_id`) REFERENCES `kind_box_reqs` (`id`),
|
|
|
|
FOREIGN KEY (`benefactor_id`) REFERENCES `benefactors` (`id`),
|
|
|
|
FOREIGN KEY (`deliver_refer_time_id`) REFERENCES `refer_times` (`id`),
|
|
|
|
FOREIGN KEY (`deliver_address_id`) REFERENCES `addresses` (`id`),
|
|
|
|
FOREIGN KEY (`sender_agent_id`) REFERENCES `admins` (`id`),
|
|
|
|
FOREIGN KEY (`return_refer_time_id`) REFERENCES `refer_times` (`id`),
|
|
|
|
FOREIGN KEY (`return_address_id`) REFERENCES `addresses` (`id`),
|
|
|
|
FOREIGN KEY (`receiver_agent_id`) REFERENCES `admins` (`id`),
|
2024-03-14 13:38:42 +00:00
|
|
|
INDEX `index_serial_number` (`serial_number`)
|
|
|
|
);
|
|
|
|
|
|
|
|
-- +migrate Down
|
|
|
|
DROP TABLE `kind_boxes`;
|