Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

fix/enterpriseportal: drop old gorm fk constraints#63864

Merged
bobheadxi merged 1 commit into
mainfrom
07-16-fix_enterpriseportal_drop_old_constraints
Jul 17, 2024
Merged

fix/enterpriseportal: drop old gorm fk constraints#63864
bobheadxi merged 1 commit into
mainfrom
07-16-fix_enterpriseportal_drop_old_constraints

Conversation

@bobheadxi

@bobheadxi bobheadxi commented Jul 16, 2024

Copy link
Copy Markdown
Member

Turns out, gorm does not auto-migrate constraints you've removed from the struct schema. You must drop them by hand, or run the commands to drop them explicitly.

Test plan

sg start -cmd enterprise-portal
\d+ enterprise_portal_*

then, comment the custom migrations, and run sg start -cmd enterprise-portal again to re-do the migrations. The output of \d+ matches. Unexpected constraints are gone.

@bobheadxi bobheadxi force-pushed the 07-16-fix_enterpriseportal_drop_old_constraints branch from 58e9fb2 to 64c3a46 Compare July 16, 2024 22:23
@bobheadxi bobheadxi force-pushed the 07-16-fix_enterpriseportal_drop_old_constraints branch from 64c3a46 to ee2b5cb Compare July 16, 2024 22:24
@bobheadxi bobheadxi changed the title fix/enterpriseportal: drop old gorm constraints fix/enterpriseportal: drop old gorm fk constraints Jul 16, 2024
@bobheadxi bobheadxi marked this pull request as ready for review July 16, 2024 22:57
@bobheadxi bobheadxi requested a review from a team July 16, 2024 22:59
type TableSubscriptionLicense struct {
// ⚠️ DO NOT USE: This field is only used for creating foreign key constraint.
Conditions *[]SubscriptionLicenseCondition `gorm:"foreignKey:LicenseID"`
Conditions []*SubscriptionLicenseCondition `gorm:"foreignKey:LicenseID"`

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a consistency change

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The interface of RunCustomMigrations is smart! but really feeling like time to invest a proper migration system 😂

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants