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

Disable add existing constraint #145

Merged
merged 1 commit into from Dec 24, 2022
Merged

Disable add existing constraint #145

merged 1 commit into from Dec 24, 2022

Conversation

crastinus
Copy link
Contributor

Disabling add constraint when constraint doesn't present in model but present in the database.

User Case Description

For example run automigrate for this Model

type Values struct {
	Name  string `gorm:"unique"`
	MyVal  bool   
}

  ....

db.Migrator().AutoMigrate(&Values{})

Try again after removing constraint "unique" from Name field

type Values struct {
	Name  string 
	MyVal  bool   
}

  ....

db.Migrator().AutoMigrate(&Values{})

Got errors messages:

ERROR: relation "idx_valuses_name" already exists (SQLSTATE 42P07)

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.

None yet

2 participants