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() does not update ENUM fields in MySQL #7364

Open
dark06 opened this issue Feb 3, 2025 · 0 comments
Open

AutoMigrate() does not update ENUM fields in MySQL #7364

dark06 opened this issue Feb 3, 2025 · 0 comments
Assignees
Labels
type:with reproduction steps with reproduction steps

Comments

@dark06
Copy link

dark06 commented Feb 3, 2025

GORM Playground Link

go-gorm/playground#787

Description

When using AutoMigrate() to modify an existing ENUM field in a MySQL database, the changes are not applied. If an ENUM option is added or removed from the model, the corresponding column in the database remains unchanged, leading to inconsistencies between the model and the actual schema.

Example Code

Here are the two relevant commits that demonstrate the issue.

  1. go-gorm/playground@6e9304e
  2. go-gorm/playground@eb0116b

The other commits in the MR are not as important because the go-gorm/playground setup deletes tables before recreating them. Initially, this made it seem like there was no issue, but this approach is not suitable for a production environment.

Additionally, one commit disables dependency between pipeline jobs, which isn’t necessary here since I’m only targeting the MySQL driver. I don’t need to account for SQLite’s lack of enum support.

Lastly, the entire test is only reproducible on a local machine because databases in the pipeline lose their state between runs, meaning I can’t retain table state for the next pipeline execution.

@github-actions github-actions bot added the type:with reproduction steps with reproduction steps label Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:with reproduction steps with reproduction steps
Projects
None yet
Development

No branches or pull requests

2 participants