-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Closed as not planned
Closed as not planned
Copy link
Labels
Description
GORM Playground Link
Description
old table:
CREATE TABLE `workspace_binding` (
`toolchain_id` int NOT NULL,
`workspace_id` int NOT NULL,
`resource_id` int NOT NULL,
UNIQUE KEY `tid_wid_rid_unique_index` (`toolchain_id`,`workspace_id`,`resource_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3
new talbe:
CREATE TABLE `workspace_binding_ddd` (
`id` bigint NOT NULL AUTO_INCREMENT,
`created_at` datetime(3) DEFAULT NULL,
`updated_at` datetime(3) DEFAULT NULL,
`toolchain_id` bigint NOT NULL,
`workspace_id` bigint NOT NULL,
`resource_id` bigint NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `tid_wid_rid_unique_index` (`toolchain_id`,`workspace_id`,`resource_id`)
) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8mb3
when auto migrate, the error is:
ALTER TABLE `workspace_binding` ADD `id` bigint AUTO_INCREMENT
Incorrect table definition; there can be only one auto column and it must be defined as a key
The statement should be: ALTER TABLE
workspace_bindingADD
id bigint AUTO_INCREMENT primary key
, the primary key
missed
is there any solution?