@@ -21,10 +21,55 @@ struct Opts {
21#[derive(Parser)]
21#[derive(Parser)]
22#[clap(about)]
22#[clap(about)]
23enum Command {
23enum Command {
25+ Migration(MigrationCommand),
28+ about = "Output the query your application should use to select the right schema",
31+ SchemaQuery(FindMigrationsOptions),
34+ about = "Deprecated. Use `reshape schema-query` instead",
37+ GenerateSchemaQuery(FindMigrationsOptions),
40+ about = "Deprecated. Use `reshape migration start` instead",
24 Migrate(MigrateOptions),
43 Migrate(MigrateOptions),
45+ about = "Deprecated. Use `reshape migration complete` instead",
25 Complete(ConnectionOptions),
48 Complete(ConnectionOptions),
50+ about = "Deprecated. Use `reshape migration abort` instead",
53+ Abort(ConnectionOptions),
57+#[clap(about = "Commands for managing migrations", display_order = 1)]
58+enum MigrationCommand {
60+ about = "Starts a new migration, applying any migrations which haven't yet been applied",
63+ Start(MigrateOptions),
65+ #[clap(about = "Completes an in-progress migration", display_order = 2)]
66+ Complete(ConnectionOptions),
69+ about = "Aborts an in-progress migration without losing any data",
26 Abort(ConnectionOptions),
72 Abort(ConnectionOptions),
27− GenerateSchemaQuery(FindMigrationsOptions),
30#[derive(Args)]
75#[derive(Args)]
@@ -67,7 +112,7 @@ fn main() -> anyhow::Result<()> {
68fn run(opts: Opts) -> anyhow::Result<()> {
113fn run(opts: Opts) -> anyhow::Result<()> {
69 match opts.cmd {
114 match opts.cmd {
70− Command::Migrate(opts) => {
115+ Command::Migration(MigrationCommand::Start(opts)) | Command::Migrate(opts) => {
71 let mut reshape = reshape_from_connection_options(&opts.connection_options)?;
116 let mut reshape = reshape_from_connection_options(&opts.connection_options)?;
72 let migrations = find_migrations(&opts.find_migrations_options)?;
117 let migrations = find_migrations(&opts.find_migrations_options)?;
73 reshape.migrate(migrations)?;
118 reshape.migrate(migrations)?;
@@ -79,16 +124,16 @@ fn run(opts: Opts) -> anyhow::Result<()> {
82− Command::Complete(opts) => {
127+ Command::Migration(MigrationCommand::Complete(opts)) | Command::Complete(opts) => {
83 let mut reshape = reshape_from_connection_options(&opts)?;
128 let mut reshape = reshape_from_connection_options(&opts)?;
84 reshape.complete()
129 reshape.complete()
86− Command::Abort(opts) => {
131+ Command::Migration(MigrationCommand::Abort(opts)) | Command::Abort(opts) => {
87 let mut reshape = reshape_from_connection_options(&opts)?;
132 let mut reshape = reshape_from_connection_options(&opts)?;
88 reshape.abort()
133 reshape.abort()
90− Command::GenerateSchemaQuery(find_migrations_options) => {
135+ Command::SchemaQuery(opts) | Command::GenerateSchemaQuery(opts) => {
91− let migrations = find_migrations(&find_migrations_options)?;
136+ let migrations = find_migrations(&opts)?;
92 let query = migrations
137 let query = migrations
94 .map(|migration| reshape::schema_query_for_migration(&migration.name));
139 .map(|migration| reshape::schema_query_for_migration(&migration.name));