@@ -21,10 +21,55 @@ struct Opts {
2121#[derive(Parser)]
2222#[clap(about)]
2323enum Command {
24+ #[clap(subcommand)]
25+ Migration(MigrationCommand),
26+
27+ #[clap(
28+ about = "Output the query your application should use to select the right schema",
29+ display_order = 2
30+ )]
31+ SchemaQuery(FindMigrationsOptions),
32+
33+ #[clap(
34+ about = "Deprecated. Use `reshape schema-query` instead",
35+ display_order = 3
36+ )]
37+ GenerateSchemaQuery(FindMigrationsOptions),
38+
39+ #[clap(
40+ about = "Deprecated. Use `reshape migration start` instead",
41+ display_order = 4
42+ )]
2443 Migrate(MigrateOptions),
44+ #[clap(
45+ about = "Deprecated. Use `reshape migration complete` instead",
46+ display_order = 5
47+ )]
2548 Complete(ConnectionOptions),
49+ #[clap(
50+ about = "Deprecated. Use `reshape migration abort` instead",
51+ display_order = 6
52+ )]
53+ Abort(ConnectionOptions),
54+}
55+
56+#[derive(Parser)]
57+#[clap(about = "Commands for managing migrations", display_order = 1)]
58+enum MigrationCommand {
59+ #[clap(
60+ about = "Starts a new migration, applying any migrations which haven't yet been applied",
61+ display_order = 1
62+ )]
63+ Start(MigrateOptions),
64+
65+ #[clap(about = "Completes an in-progress migration", display_order = 2)]
66+ Complete(ConnectionOptions),
67+
68+ #[clap(
69+ about = "Aborts an in-progress migration without losing any data",
70+ display_order = 3
71+ )]
2672 Abort(ConnectionOptions),
27− GenerateSchemaQuery(FindMigrationsOptions),
2873}
2974
3075#[derive(Args)]
@@ -67,7 +112,7 @@ fn main() -> anyhow::Result<()> {
67112
68113fn run(opts: Opts) -> anyhow::Result<()> {
69114 match opts.cmd {
70− Command::Migrate(opts) => {
115+ Command::Migration(MigrationCommand::Start(opts)) | Command::Migrate(opts) => {
71116 let mut reshape = reshape_from_connection_options(&opts.connection_options)?;
72117 let migrations = find_migrations(&opts.find_migrations_options)?;
73118 reshape.migrate(migrations)?;
@@ -79,16 +124,16 @@ fn run(opts: Opts) -> anyhow::Result<()> {
79124
80125 Ok(())
81126 }
82− Command::Complete(opts) => {
127+ Command::Migration(MigrationCommand::Complete(opts)) | Command::Complete(opts) => {
83128 let mut reshape = reshape_from_connection_options(&opts)?;
84129 reshape.complete()
85130 }
86− Command::Abort(opts) => {
131+ Command::Migration(MigrationCommand::Abort(opts)) | Command::Abort(opts) => {
87132 let mut reshape = reshape_from_connection_options(&opts)?;
88133 reshape.abort()
89134 }
90− Command::GenerateSchemaQuery(find_migrations_options) => {
91− let migrations = find_migrations(&find_migrations_options)?;
135+ Command::SchemaQuery(opts) | Command::GenerateSchemaQuery(opts) => {
136+ let migrations = find_migrations(&opts)?;
92137 let query = migrations
93138 .last()
94139 .map(|migration| reshape::schema_query_for_migration(&migration.name));