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

Add a migration that fails telling the user that upgrade is not supported #711

Merged
merged 3 commits into from
Oct 5, 2021

Conversation

tolikzinovyev
Copy link
Contributor

No description provided.

@codecov-commenter
Copy link

codecov-commenter commented Oct 4, 2021

Codecov Report

Merging #711 (54fbfaf) into develop (9053c11) will decrease coverage by 0.00%.
The diff coverage is 50.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #711      +/-   ##
===========================================
- Coverage    53.03%   53.03%   -0.01%     
===========================================
  Files           23       23              
  Lines         3622     3624       +2     
===========================================
+ Hits          1921     1922       +1     
- Misses        1444     1445       +1     
  Partials       257      257              
Impacted Files Coverage Δ
idb/postgres/postgres_migrations.go 35.63% <50.00%> (+0.33%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9053c11...54fbfaf. Read the comment docs.

Copy link
Contributor

@winder winder left a comment

Choose a reason for hiding this comment

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

Great idea

@@ -199,8 +201,13 @@ func sqlMigration(db *IndexerDb, state *types.MigrationState, sqlLines []string)
const unsupportedMigrationErrorMsg = "unsupported migration: please downgrade to %s to run this migration"

// disabled creates a simple migration handler for unsupported migrations.
//lint:ignore U1000 this function might be used in the future
func disabled(version string) func(db *IndexerDb, migrationState *types.MigrationState) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

LOL, that was short-lived.

func disabled(version string) func(db *IndexerDb, migrationState *types.MigrationState) error {
return func(_ *IndexerDb, _ *types.MigrationState) error {
return fmt.Errorf(unsupportedMigrationErrorMsg, version)
}
}

func upgradeNotSupported(db *IndexerDb, migrationState *types.MigrationState) error {
return errors.New("upgrading to Indexer 2.7 is not supported; create a new database")
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is slightly more accurate and would still be correct when we reach 2.8.

Suggested change
return errors.New("upgrading to Indexer 2.7 is not supported; create a new database")
return errors.New("upgrading from this version is not supported; create a new database")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good idea

@tolikzinovyev tolikzinovyev merged commit a1415b8 into develop Oct 5, 2021
@tolikzinovyev tolikzinovyev deleted the tolik/upg-migration branch October 5, 2021 19:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants