shepherd icon indicating copy to clipboard operation
shepherd copied to clipboard

Feature: Commands to manage migrations + migration state

Open alexturek opened this issue 6 years ago • 1 comments

One thing I've found difficult when writing/attempting migrations is figuring out what I have, what state they're in, and what my next steps are.

There are four commands I'd like to add to help with this (btw naming suggestions welcome; these make sense to me but I haven't run them by anybody else)

shepherd migrations

List all migrations I have in my local cache (default: ~/.shepherd)

shepherd migrations
2019-09-15-add-foo
2019-09-16-remove-bars

shepherd migration-state

Tell me how much progress I've made in each migration

shepherd migration-state

(This is a rough sketch; I'd want to use something like cli-table to render this)

migration   | checked out | applied    | committed          | pushed     | pr opened | pr mergeable
------------|-------------|------------|--------------------|------------|-----------|-------------
add-foo     |  150/200    | 130/150    |  130/130           |            |           |       
            |   (75%)     |  (86%)     |  (100%)            |            |           |       
            |             |            |  *OLD*: 1 hour ago |            |           |       
------------|-------------|------------|--------------------|------------|-----------|-------------
remove-bar  | 200/200     | 130/200    | 130/130            | 130/130    | 130/130   |  120/130
            |  (100%)     |  (65%)     |  (100%)            | (100%)     | (100%)    |   (92%)
  • Lists all migrations in my local shepherd dir
  • Prints out a summary of how many repos made it through each stage, total numbers and percentage
  • Flags old stages. If I apply-ed the migration add-foo after committing it, let me know I need to re-do that

This reqires doing more state tracking, probably in a JSON file in the shepherd migration directory. Every time I run a shepherd command I should update that JSON file as I pass through each repo, and then shepherd migration-state does aggregation across all the migrations.

shepherd migration-state <migration>

Tell me how much progress I've made in a given migration. Again, rough sketch

repo        | checked out | applied    | committed  | pushed     | pr opened | pr mergeable
------------|-------------|------------|------------|------------|-----------|-------------
lib-foo     |      ✓      |     ✓      |  ✓         |     ✓      |     ✓     |       ✗
app-baz     |      ✓      |     ✓      |  ✓         |     ?      |           |       
lib-boop    |      ✓      |     ✗      |            |            |           |       
app-bar     |      ✗      |            |            |            |           |  
------------|-------------|------------|------------|------------|-----------|-------------
summaries   |     75%     |    66%     |     100%   |     50%    |    100%   |     100%
  • List every repo I've gone through for a given migration, and the progress we've made on it
  • Mark each one that explicitly failed a step with an X
  • Mark each one that we just haven't run yet (see: app-bar in example) with a ?
  • Probably flag old commands the same as the version that isn't migration-specific, so if we needed to e.g. re-run apply + commit for app-baz it would be flagged as old
  • Summarize by percentage at bottom

alexturek avatar Sep 16 '19 18:09 alexturek

Oh, there was one more I wanted to add!

shepherd done <migration>

This just blows away that particular migration in my Shepherd dir, so it no longer shows up for the above commands

alexturek avatar Sep 16 '19 18:09 alexturek