Skip to content

[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

Merged
merged 5 commits into from
May 4, 2025

Conversation

pascal-fischer
Copy link
Collaborator

Describe your changes

Issue ticket number and link

Stack

Checklist

  • Is it a bug fix
  • Is a typo/documentation fix
  • Is a feature enhancement
  • It is a refactor
  • Created tests that fail without the change (if possible)
  • Extended the README / documentation, if necessary

@Copilot Copilot AI review requested due to automatic review settings April 29, 2025 10:23
Copy link
Contributor

@Copilot Copilot AI left a 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.

bcmmbaga
bcmmbaga previously approved these changes Apr 29, 2025
@bcmmbaga bcmmbaga requested a review from Copilot April 30, 2025 14:37
Copy link
Contributor

@Copilot Copilot AI left a 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

Copy link

@pascal-fischer pascal-fischer merged commit 055df98 into main May 4, 2025
35 checks passed
@pascal-fischer pascal-fischer deleted the feature/add-primary-key-to-networks branch May 4, 2025 18:58
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.

2 participants