dev/sg: include migration names in migration files
Created by: bobheadxi
https://sourcegraph.slack.com/archives/C01N83PS4TU/p1655114273358869
would it be possible to include the name of a migration in the folder name? So instead of
migrations/frontend/1648115472 migrations/frontend/1646027072 migrations/frontend/1645554732 migrations/frontend/1650456734
we’d have
migrations/frontend/1648115472_add_index_to_repo migrations/frontend/1646027072_lol_jk_remove_index migrations/frontend/1645554732_add_middle_name_to_users migrations/frontend/1650456734_add_new_favorite_animals_table
10 upvotes, so thought I'd take a stab at it
Rough design from Eric:
Not hard to do. If anyone wants to take this on, I can own testing a solution and review. Otherwise if someone can make a ticket I can get to it after ~2 weeks (if I don’t get to it during the offsite this week). What needs to be done:
-
modify readDefinitions in internal/database/migration/definition/read.go to ignore anything after the first _ in the Atoi call: https://github.com/sourcegraph/sourcegraph/pull/37247 -
modify makeMigrationFilenames in makeMigrationFilenames to take a name as well as an index. Sanitize (s/ /_/g et al) the name and add it to the end of the created filenames: https://github.com/sourcegraph/sourcegraph/pull/37248 -
(a little less trivial) ensure the call to makeMigrationFilenames in the sg migration revert command receives the correct name so it can actually revert the correct filenames to modify: https://github.com/sourcegraph/sourcegraph/pull/37248 -
rewrite all migration directories to include the name