How should I handle AUTO_INCREMENT in declarative workflow for MySQL? #3283
-
I export the schemas from DB_1 using What I expected was that it would create the missing tables and columns but not the But I received this error when I applied the schema: $ atlas schema apply --env local
Abort: the planned state does not match the desired state after applying the file:
--- planned state
+++ desired state
@@ -37,7 +37,7 @@
`updated_at` datetime NULL COMMENT "",
`deleted_at` datetime NULL COMMENT "",
PRIMARY KEY (`id`)
-) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT "";
+) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT "" AUTO_INCREMENT 8;
CREATE TABLE `hg_addon_hgexample_tenant_order` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT "",
`tenant_id` bigint NULL COMMENT "",
@@ -88,7 +88,7 @@
`updated_at` datetime NULL COMMENT "",
PRIMARY KEY (`id`),
INDEX `member_id` (`member_id`)
-) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT "";
+) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT "" AUTO_INCREMENT 3;
CREATE TABLE `hg_admin_dept` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT "",
`pid` bigint NULL DEFAULT 0 COMMENT "",
... BTW, the issue still exists even after I delete Is my approach correct? If yes, how can I ignore the |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Thanks for reporting this, @RyoJerryYu. I'll give it a look. |
Beta Was this translation helpful? Give feedback.
-
The issue was resolved with the latest binary. Starting with this version, Atlas proposes |
Beta Was this translation helpful? Give feedback.
The issue was resolved with the latest binary. Starting with this version, Atlas proposes
AUTO_INCREMENT
changes only if the compared tables define this value in their schema file(s) (i.e., this value will be ignored from inspection).