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

AutoMigrate error for 1.3.2 #94

Closed
strive1216 opened this issue Jun 1, 2022 · 1 comment
Closed

AutoMigrate error for 1.3.2 #94

strive1216 opened this issue Jun 1, 2022 · 1 comment
Assignees

Comments

@strive1216
Copy link

GORM Playground Link

go-gorm/playground#1

Description

.....
	if err := db.DB.AutoMigrate(&sys.RoleMenu{}); err != nil {
		log.Errorf("%s", err.Error())
	}
......

log

[0.455ms] [rows:0] CREATE TABLE `tb_sys_role_menu__temp` (
  "id" integer  PRIMARY KEY AUTOINCREMENT,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  `created_by` integer NOT NULL DEFAULT 0,
  `updated_by` integer NOT NULL DEFAULT 0,
  `role_id` integer NOT NULL,
  "menu_id" bigint NOT NULL
)

pkg/mod/gorm.io/driver/sqlite@v1.3.2/migrator.go:411 near ")": syntax error
[0.011ms] [rows:0] INSERT INTO `tb_sys_role_menu__temp`() SELECT  FROM `tb_sys_role_menu`
2022-06-01T09:45:25.751+0800	ERROR	models/base.go:54	创建RoleMenu表异常:near ")": syntax error
@strive1216
Copy link
Author

如果此处获取的sql 存在"\n 换行符:
image

image

那么图中columns := createDDL.getColumns() 为nil

@jinzhu 大佬我手动修改数据表的DDL ,则规避掉此issues问题

@jinzhu jinzhu closed this as completed in c86933b Oct 9, 2022
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

No branches or pull requests

2 participants