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 helpers for common add/remove setting migrations #695

Merged
merged 1 commit into from
Feb 1, 2020

Conversation

tjkirch
Copy link
Contributor

@tjkirch tjkirch commented Jan 29, 2020

I'm still thinking about how we could automate away the need for common migrations, but this at least makes adding or removing a setting a one-liner that you barely have to think about, rather than copy/paste or new code each time.

Testing done:

Rebuild and ran the remove-region migration forward and backward. It has no work to do on upgrade:

$ cargo run -- --log-level trace --datastore-path datastore-sample/current --migration-directories ./migration-binaries --migrate-to-version 0.2
...
19:59:08 [DEBUG] (1) migrator: Sorted migrations: ["migrate_v0.2_remove-region"]
19:59:08 [ INFO] New data store is being built at work location /home/ANT.AMAZON.COM/tjk/work/thar/workspaces/api/migration/migrator/datastore-sample/v0.2_AqZorFmcnAhXpUNF
19:59:08 [ INFO] Running migration command: "./migration-binaries/migrate_v0.2_remove-region" "--forward" "--source-datastore" "/home/ANT.AMAZON.COM/tjk/work/thar/workspaces/api/migration/migrator/datastore-sample/v0.1_j52ioMoTEFBcHM0Z" "--target-datastore" "/home/ANT.AMAZON.COM/tjk/work/thar/workspaces/api/migration/migrator/datastore-sample/v0.2_AqZorFmcnAhXpUNF"
19:59:08 [DEBUG] (1) migrator: Migration stdout: AddSettingMigration(settings.aws.region) has no work to do on upgrade.
AddSettingMigration(settings.aws.region) has no work to do on upgrade.

19:59:08 [DEBUG] (1) migrator: Migration stderr: 
19:59:08 [ INFO] Flipping /home/ANT.AMAZON.COM/tjk/work/thar/workspaces/api/migration/migrator/datastore-sample/v0.2 to point to v0.2_AqZorFmcnAhXpUNF
19:59:08 [ INFO] Flipping /home/ANT.AMAZON.COM/tjk/work/thar/workspaces/api/migration/migrator/datastore-sample/v0 to point to v0.2

On downgrade it did its job:

$ cargo run -- --log-level trace --datastore-path datastore-sample/current --migration-directories ./migration-binaries --migrate-to-version 0.1
...
19:59:23 [DEBUG] (1) migrator: Sorted migrations: ["migrate_v0.2_remove-region"]
19:59:23 [ INFO] New data store is being built at work location /home/ANT.AMAZON.COM/tjk/work/thar/workspaces/api/migration/migrator/datastore-sample/v0.1_lm9HzZmqysxr94CJ
19:59:23 [ INFO] Running migration command: "./migration-binaries/migrate_v0.2_remove-region" "--backward" "--source-datastore" "/home/ANT.AMAZON.COM/tjk/work/thar/workspaces/api/migration/migrator/datastore-sample/v0.2_AqZorFmcnAhXpUNF" "--target-datastore" "/home/ANT.AMAZON.COM/tjk/work/thar/workspaces/api/migration/migrator/datastore-sample/v0.1_lm9HzZmqysxr94CJ"
19:59:23 [DEBUG] (1) migrator: Migration stdout: Removed settings.aws.region, which was set to '"us-west-2"'
Found no settings.aws.region to remove

19:59:23 [DEBUG] (1) migrator: Migration stderr: 
19:59:23 [ INFO] Flipping /home/ANT.AMAZON.COM/tjk/work/thar/workspaces/api/migration/migrator/datastore-sample/v0.1 to point to v0.1_lm9HzZmqysxr94CJ
19:59:23 [ INFO] Flipping /home/ANT.AMAZON.COM/tjk/work/thar/workspaces/api/migration/migrator/datastore-sample/v0 to point to v0.1

Copy link
Contributor

@etungsten etungsten left a comment

Choose a reason for hiding this comment

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

🦆

@tjkirch
Copy link
Contributor Author

tjkirch commented Jan 31, 2020

This push was just a rebase onto changes from #644.

@tjkirch
Copy link
Contributor Author

tjkirch commented Feb 1, 2020

This push was just a rebase onto changes from #644.

@tjkirch tjkirch changed the base branch from release.toml-migrations to develop February 1, 2020 00:33
@tjkirch
Copy link
Contributor Author

tjkirch commented Feb 1, 2020

Just a rebase on develop.

@tjkirch tjkirch merged commit f4d9fa9 into develop Feb 1, 2020
@tjkirch tjkirch deleted the common-migrations branch February 1, 2020 00: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