-
-
Notifications
You must be signed in to change notification settings - Fork 707
[management] add gorm tag for primary key for the networks objects #3758
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR updates the Gorm tagging for network-related objects by replacing the indexing annotation with the primary key annotation on the ID fields.
- Updates the ID field in management/server/networks/types/network.go to use "primaryKey".
- Updates the ID field in management/server/networks/routers/types/router.go to use "primaryKey".
- Updates the ID field in management/server/networks/resources/types/resource.go to use "primaryKey".
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
File | Description |
---|---|
management/server/networks/types/network.go | Changed the ID tag from an index to a primary key. |
management/server/networks/routers/types/router.go | Updated the ID tag to a primary key for consistency. |
management/server/networks/resources/types/resource.go | Modified the ID tag to a primary key for correct database schema. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds gorm primary key tags to various ID fields and introduces migration functions to drop unused indexes, along with corresponding test adjustments.
- Changed gorm tag on ID fields in group, network, router, and resource types to "primaryKey".
- Added migration functions to drop indexes for network, network resource, and network router.
- Updated test cases to use t.Fatalf for early test termination and adjusted SQLite store initialization to enable foreign keys.
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
management/server/types/group.go | Added primary key tag for Group.ID |
management/server/store/store.go | Added migration functions to drop indexes for network objects |
management/server/store/sql_store_test.go | Updated test failure calls and modified AccountID in tests |
management/server/store/sql_store.go | Configured SQLite to enable foreign keys with PRAGMA execution |
management/server/networks/types/network.go | Changed tag to primaryKey for Network.ID |
management/server/networks/routers/types/router.go | Changed tag to primaryKey for NetworkRouter.ID |
management/server/networks/resources/types/resource.go | Changed tag to primaryKey for NetworkResource.ID |
management/server/migration/migration_test.go | Added tests for the new DropIndex migration function |
management/server/migration/migration.go | Added a generic DropIndex migration function |
Co-authored-by: Copilot <[email protected]>
|
Describe your changes
Issue ticket number and link
Stack
Checklist