@@ -35,10 +35,10 @@ Designed for Postgres 12 and later.
3535 - [Remove enum](#remove-enum)
3636 - [Custom](#custom)
3737- [Commands and options](#commands-and-options)
38− - [`reshape migrate`](#reshape-migrate)
39− - [`reshape complete`](#reshape-complete)
40− - [`reshape abort`](#reshape-abort)
41− - [`reshape generate-schema-query`](#reshape-generate-schema-query)
38+ - [`reshape migration start`](#reshape-migration-start)
39+ - [`reshape migration complete`](#reshape-migration-complete)
40+ - [`reshape migration abort`](#reshape-migration-abort)
41+ - [`reshape schema-query`](#reshape-schema-query)
4242 - [Connection options](#connection-options)
4343- [License](#license)
4444
@@ -47,11 +47,11 @@ Designed for Postgres 12 and later.
4747
4848Reshape works by creating views that encapsulate the underlying tables, which your application will interact with. During a migration, Reshape will automatically create a new set of views and set up triggers to translate inserts and updates between the old and new schema. This means that every deployment is a three-phase process:
4949
50−1. **Start migration** (`reshape migrate`): Sets up views and triggers to ensure both the new and old schema are usable at the same time.
50+1. **Start migration** (`reshape migration start`): Sets up views and triggers to ensure both the new and old schema are usable at the same time.
51512. **Roll out application**: Your application can be gradually rolled out without downtime. The existing deployment will continue using the old schema whilst the new deployment uses the new schema.
52−3. **Complete migration** (`reshape complete`): Removes the old schema and any intermediate data and triggers.
52+3. **Complete migration** (`reshape migration complete`): Removes the old schema and any intermediate data and triggers.
5353
54−If the application deployment fails, you should run `reshape abort` which will roll back any changes made by `reshape migrate` without losing data.
54+If the application deployment fails, you should run `reshape migration abort` which will roll back any changes made by `reshape migration start` without losing data.
5555
5656## Getting started
5757
@@ -74,7 +74,7 @@ cargo install reshape
7474Reshape is available as a Docker image on [Docker Hub](https://hub.docker.com/repository/docker/fabianlindfors/reshape).
7575
7676```shell
77−docker run -v $(pwd):/usr/share/app fabianlindfors/reshape reshape migrate
77+docker run -v $(pwd):/usr/share/app fabianlindfors/reshape reshape migration start
7878```
7979
8080### Creating your first migration
@@ -103,9 +103,9 @@ This is the equivalent of running `CREATE TABLE users (id INTEGER GENERATED ALWA
103103
104104### Preparing your application
105105
106−Reshape relies on your application using a specific schema. When establishing the connection to Postgres in your application, you need to run a query to select the most recent schema. This query can be generated using: `reshape generate-schema-query`.
106+Reshape relies on your application using a specific schema. When establishing the connection to Postgres in your application, you need to run a query to select the most recent schema. This query can be generated using: `reshape schema-query`.
107107
108−To pass it along to your application, you can for example use an environment variable in your run script: `RESHAPE_SCHEMA_QUERY=$(reshape generate-schema-query)`. Then in your application:
108+To pass it along to your application, you can for example use an environment variable in your run script: `RESHAPE_SCHEMA_QUERY=$(reshape schema-query)`. Then in your application:
109109
110110```python
111111# Example for Python
@@ -120,16 +120,16 @@ If your application is written in Rust, you might prefer the [Rust helper librar
120120To create your new `users` table, run:
121121
122122```bash
123−reshape migrate --complete
123+reshape migration start --complete
124124```
125125
126−We use the `--complete` flag to automatically complete the migration. During a production deployment, you should first run `reshape migrate` followed by `reshape complete` once your application has been fully rolled out.
126+We use the `--complete` flag to automatically complete the migration. During a production deployment, you should first run `reshape migration start` followed by `reshape migration complete` once your application has been fully rolled out.
127127
128128If nothing else is specified, Reshape will try to connect to a Postgres database running on `localhost` using `postgres` as both username and password. See [Connection options](#connection-options) for details on how to change the connection settings.
129129
130130### Using during development
131131
132−When adding new migrations during development, we recommend running `reshape migrate` but skipping `reshape complete`. This way, the new migrations can be iterated on by updating the migration file and running `reshape abort` followed by `reshape migrate`.
132+When adding new migrations during development, we recommend running `reshape migration start` but skipping `reshape migration complete`. This way, the new migrations can be iterated on by updating the migration file and running `reshape migration abort` followed by `reshape migration start`.
133133
134134## Writing migrations
135135
@@ -538,9 +538,9 @@ The `custom` action lets you create a migration which runs custom SQL. It should
538538
539539There are three optional settings available which all accept SQL queries. All queries need to be idempotent, for example by using `IF NOT EXISTS` wherever available.
540540
541−- `start`: run when a migration is started using `reshape migrate`
542−- `complete`: run when a migration is completed using `reshape complete`
543−- `abort`: run when a migration is aborted using `reshape abort`
541+- `start`: run when a migration is started using `reshape migration start`
542+- `complete`: run when a migration is completed using `reshape migration complete`
543+- `abort`: run when a migration is aborted using `reshape migration abort`
544544
545545*Example: enable PostGIS and pg_stat_statements extensions*
546546
@@ -561,9 +561,9 @@ abort = """
561561
562562## Commands and options
563563
564−### `reshape migrate`
564+### `reshape migration start`
565565
566−Starts a new migration, applying all migrations under `migrations/` that haven't yet been applied. After the command has completed, both the old and new schema will be usable at the same time. When you have rolled out the new version of your application which uses the new schema, you should run `reshape complete`.
566+Starts a new migration, applying all migrations under `migrations/` that haven't yet been applied. After the command has completed, both the old and new schema will be usable at the same time. When you have rolled out the new version of your application which uses the new schema, you should run `reshape migration complete`.
567567
568568#### Options
569569
@@ -574,15 +574,15 @@ Starts a new migration, applying all migrations under `migrations/` that haven't
574574| `--complete`, `-c` | `false` | Automatically complete migration after applying it. |
575575| `--dirs` | `migrations/` | Directories to search for migration files. Multiple directories can be specified using `--dirs dir1 dir2 dir3`. |
576576
577−### `reshape complete`
577+### `reshape migration complete`
578578
579−Completes migrations previously started with `reshape complete`.
579+Completes migrations previously started with `reshape migration complete`.
580580
581581#### Options
582582
583583See [Connection options](#connection-options)
584584
585−### `reshape abort`
585+### `reshape migration abort`
586586
587587Aborts any migrations which haven't yet been completed.
588588
@@ -590,10 +590,12 @@ Aborts any migrations which haven't yet been completed.
590590
591591See [Connection options](#connection-options)
592592
593−### `reshape generate-schema-query`
593+### `reshape schema-query`
594594
595595Generates the SQL query you need to run in your application before using the database. This command does not require a database connection. Instead it will generate the query based on the latest migration in the `migrations/` directory (or the directories specified by `--dirs`).
596596
597+If your application is written in Rust, we recommend using the [Rust helper library](https://github.com/fabianlindfors/reshape-helper/) instead.
598+
597599The query should look something like `SET search_path TO migration_1_initial_migration`.
598600
599601#### Options