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

Migrate from varchar to text not work #5462

Closed
halfcrazy opened this issue Jun 25, 2022 · 3 comments · Fixed by #5465
Closed

Migrate from varchar to text not work #5462

halfcrazy opened this issue Jun 25, 2022 · 3 comments · Fixed by #5465
Assignees
Labels

Comments

@halfcrazy
Copy link
Contributor

GORM Playground Link

go-gorm/playground#1

Description

image

@github-actions github-actions bot added the type:missing reproduction steps missing reproduction steps label Jun 25, 2022
@github-actions
Copy link

The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.ioSearch Before Asking

@tfonfara
Copy link

tfonfara commented Jul 7, 2022

Unfortunately it seems that the fix of this ticket is not perfectly fine, especially this part:

// check type
if !field.PrimaryKey && !strings.HasPrefix(fullDataType, realDataType) {
	alterColumn = true
}

I was wondering why after updating gorm the auto migration was taking so long. I found that I was using type int32 (not null) in my models, which caused the issue. While debugging I found that in here for int32 and postgres dialect the fullDataType is integer not null and realDataType is int4 which is fine in general but due to the upper code snippet it runs a migration every time for all int32 fields.

@a631807682 is there any chance to limit this condition to the mentioned data types, as this might affect others as well.

@a631807682
Copy link
Member

related to go-gorm/postgres#111
@tfonfara integer is alias for int4, it will be fix after this PR merge.

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

Successfully merging a pull request may close this issue.

4 participants