我在我的数据库迁移中使用 flyway 插件,我的一个迁移有这个 sql:
-- Inserts sequential number into `id`
ALTER TABLE `DEVICES` MODIFY `id` BIGINT(20) AUTO_INCREMENT;
-- we don't need the auto_increment anymore
ALTER TABLE `DEVICES` MODIFY `id` BIGINT(20) UNIQUE;
-- This simulates a sequence. Starts at max(id); next id will be max(id)+1.
CREATE TABLE `DEVICES_ID_SEQUENCE` (id BIGINT(20) NOT NULL);
INSERT INTO `DEVICES_ID_SEQUENCE` (SELECT max(id) from `DEVICES`);
但 flyway 不会在现有行上填充表 DEVICES 的列 ID。但是,如果我手动执行这些语句,则会填充现有行。
有一些解决方法吗?