Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

case: When adding a new column to a table, include a primary key if the field is either a primary key itself or has an auto-increment attribute #631

Closed
wants to merge 0 commits into from

Conversation

ckganesan
Copy link

Explain your user case and expected results

When adding a new column to a table, include a primary key if the field is either a primary key itself or has an auto-increment attribute

Reproduced Steps:

GORM_DIALECT=mysql go test

2023/08/02 08:17:35 testing mysql...

2023/08/02 08:17:35 /Users/I333296/Downloads/development/gorm-playground/db.go:103 Error 1075 (42000): Incorrect table definition; there can be only one auto column and it must be defined as a key
[1.425ms] [rows:0] ALTER TABLE `profile` ADD `id` bigint AUTO_INCREMENT

2023/08/02 08:17:35 /Users/I333296/Downloads/development/gorm-playground/main_test.go:14
[6.859ms] [rows:1] INSERT INTO `users` (`created_at`,`updated_at`,`deleted_at`,`name`,`age`,`birthday`,`company_id`,`manager_id`,`active`) VALUES ('2023-08-02 08:17:35.812','2023-08-02 08:17:35.812',NULL,'jinzhu',0,NULL,NULL,NULL,false)

2023/08/02 08:17:35 /Users/I333296/Downloads/development/gorm-playground/main_test.go:17
[2.400ms] [rows:1] SELECT * FROM `users` WHERE `users`.`id` = 1 AND `users`.`deleted_at` IS NULL ORDER BY `users`.`id` LIMIT 1
PASS
ok      gorm.io/playground      0.747s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant