Skip to content

[management] add flag to disable auto-migration #3840

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 19, 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 May 19, 2025 08:30
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 introduces a skipMigration flag to disable automatic database migrations when initializing stores.

  • Extended NewStore and all SQL store constructors to accept skipMigration and propagate it.
  • Wrapped existing migration steps in a conditional to skip or log migrations based on the new flag.
  • Updated callers (including the main command and test helpers) to pass a default false or true for testing/migration contexts.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
management/server/store/store.go Added skipMigration parameter to NewStore and propagated it.
management/server/store/sql_store.go Updated SQL store constructors & guarded migration logic.
management/cmd/management.go Passed default false for skipMigration when creating the store.
Comments suppressed due to low confidence (3)

management/server/store/store.go:245

  • [nitpick] Update this doc comment to include the new skipMigration parameter and describe how it affects auto-migration behavior.
// NewStore creates a new store based on the provided engine type, data directory, and telemetry metrics

management/server/store/sql_store.go:91

  • There are no tests verifying that migrations are correctly skipped or applied when skipMigration is toggled. Consider adding unit tests around both branches of this conditional.
if !skipMigration {

management/server/store/sql_store.go:1022

  • [nitpick] The doc comment for NewSqliteStore should be updated to mention the skipMigration parameter and explain its effect on automatic migrations.
// NewSqliteStore creates a new SQLite store.

Comment on lines 68 to +69
// NewSqlStore creates a new SqlStore instance.
func NewSqlStore(ctx context.Context, db *gorm.DB, storeEngine types.Engine, metrics telemetry.AppMetrics) (*SqlStore, error) {
func NewSqlStore(ctx context.Context, db *gorm.DB, storeEngine types.Engine, metrics telemetry.AppMetrics, skipMigration bool) (*SqlStore, error) {
Copy link
Preview

Copilot AI May 19, 2025

Choose a reason for hiding this comment

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

[nitpick] Consider replacing the boolean skipMigration flag with a functional options pattern or named configuration struct to improve readability at call sites (e.g., NewSqlStore(..., false) can be unclear).

Copilot uses AI. Check for mistakes.

Copy link

@pascal-fischer pascal-fischer merged commit 701c138 into main May 19, 2025
39 checks passed
@pascal-fischer pascal-fischer deleted the feature/flag-disable-auto-migrate branch May 19, 2025 11:36
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.

3 participants