niki/repository/mysql/migration/1705399370_create_addresses...

21 lines
1.1 KiB
MySQL
Raw Normal View History

-- +migrate Up
CREATE TABLE `addresses` (
`id` INT PRIMARY KEY AUTO_INCREMENT,
`postal_code` VARCHAR(191) NOT NULL,
`address` TEXT NOT NULL,
`lat` FLOAT,
`lon` FLOAT,
`is_main` BOOL NOT NULL DEFAULT FALSE,
`city_id` INT NOT NULL,
`province_id` INT NOT NULL,
`benefactor_id` INT NOT NULL,
`created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` TIMESTAMP,
FOREIGN KEY (`province_id`) REFERENCES `provinces` (`id`),
FOREIGN KEY (`city_id`) REFERENCES `cities` (`id`),
FOREIGN KEY (`benefactor_id`) REFERENCES `benefactors` (`id`)
);
-- +migrate Down
DROP TABLE `addresses`;