@@ -2,56 +2,56 @@
3[](https://github.com/fabianlindfors/reshape/actions/workflows/test.yaml) [](https://github.com/fabianlindfors/reshape/releases)
3[](https://github.com/fabianlindfors/reshape/actions/workflows/test.yaml) [](https://github.com/fabianlindfors/reshape/releases)
5−> Also check out [ReshapeDB](https://reshapedb.com), a new database built from the ground up to make zero-downtime schema and data migrations as simple and safe as possible. If you'd like to chat about it, please [reach out](contact@reshapedb.com)!
7Reshape is an easy-to-use, zero-downtime schema migration tool for Postgres. It automatically handles complex migrations that would normally require downtime or manual multi-step changes. During a migration, Reshape ensures both the old and new schema are available at the same time, allowing you to gradually roll out your application. It will also perform all changes without excessive locking, avoiding downtime caused by blocking other queries. For a more thorough introduction to Reshape, check out the [introductory blog post](https://fabianlindfors.se/blog/schema-migrations-in-postgres-using-reshape/).
5Reshape is an easy-to-use, zero-downtime schema migration tool for Postgres. It automatically handles complex migrations that would normally require downtime or manual multi-step changes. During a migration, Reshape ensures both the old and new schema are available at the same time, allowing you to gradually roll out your application. It will also perform all changes without excessive locking, avoiding downtime caused by blocking other queries. For a more thorough introduction to Reshape, check out the [introductory blog post](https://fabianlindfors.se/blog/schema-migrations-in-postgres-using-reshape/).
9Designed for Postgres 12 and later.
7Designed for Postgres 12 and later.
9+*Note: Reshape is **experimental** and should not be used in production. It can (and probably will) break your application.*
11- [How it works](#how-it-works)
11- [How it works](#how-it-works)
12- [Getting started](#getting-started)
12- [Getting started](#getting-started)
13− - [Installation](#installation)
13+ - [Installation](#installation)
14− - [Creating your first migration](#creating-your-first-migration)
14+ - [Creating your first migration](#creating-your-first-migration)
15− - [Preparing your application](#preparing-your-application)
15+ - [Preparing your application](#preparing-your-application)
16− - [Running your migration](#running-your-migration)
16+ - [Running your migration](#running-your-migration)
17− - [Using during development](#using-during-development)
17+ - [Using during development](#using-during-development)
18- [Writing migrations](#writing-migrations)
18- [Writing migrations](#writing-migrations)
19− - [Basics](#basics)
19+ - [Basics](#basics)
20− - [Tables](#tables)
20+ - [Tables](#tables)
21− - [Create table](#create-table)
21+ - [Create table](#create-table)
22− - [Rename table](#rename-table)
22+ - [Rename table](#rename-table)
23− - [Remove table](#remove-table)
23+ - [Remove table](#remove-table)
24− - [Add foreign key](#add-foreign-key)
24+ - [Add foreign key](#add-foreign-key)
25− - [Remove foreign key](#remove-foreign-key)
25+ - [Remove foreign key](#remove-foreign-key)
26− - [Columns](#columns)
26+ - [Columns](#columns)
27− - [Add column](#add-column)
27+ - [Add column](#add-column)
28− - [Alter column](#alter-column)
28+ - [Alter column](#alter-column)
29− - [Remove column](#remove-column)
29+ - [Remove column](#remove-column)
30− - [Indices](#indices)
30+ - [Indices](#indices)
31− - [Add index](#add-index)
31+ - [Add index](#add-index)
32− - [Remove index](#remove-index)
32+ - [Remove index](#remove-index)
33− - [Enums](#enums)
33+ - [Enums](#enums)
34− - [Create enum](#create-enum)
34+ - [Create enum](#create-enum)
35− - [Remove enum](#remove-enum)
35+ - [Remove enum](#remove-enum)
36− - [Custom](#custom)
36+ - [Custom](#custom)
37− - [Complex changes across tables](#complex-changes-across-tables)
38- [Commands and options](#commands-and-options)
37- [Commands and options](#commands-and-options)
39− - [`reshape migration start`](#reshape-migration-start)
38+ - [`reshape migrate`](#reshape-migrate)
40− - [`reshape migration complete`](#reshape-migration-complete)
39+ - [`reshape complete`](#reshape-complete)
41− - [`reshape migration abort`](#reshape-migration-abort)
40+ - [`reshape abort`](#reshape-abort)
42− - [`reshape schema-query`](#reshape-schema-query)
41+ - [`reshape generate-schema-query`](#reshape-generate-schema-query)
43− - [Connection options](#connection-options)
42+ - [Connection options](#connection-options)
44- [License](#license)
43- [License](#license)
46## How it works
46## How it works
48Reshape 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:
48Reshape 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:
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.
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.
512. **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.
512. **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 migration complete`): Removes the old schema and any intermediate data and triggers.
52+3. **Complete migration** (`reshape complete`): Removes the old schema and any intermediate data and triggers.
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.
54+If the application deployment fails, you should run `reshape abort` which will roll back any changes made by `reshape migrate` without losing data.
56## Getting started
56## Getting started
@@ -71,10 +71,10 @@ cargo install reshape
72#### Docker
72#### Docker
74−Reshape is available as a Docker image on [Docker Hub](https://hub.docker.com/repository/docker/fabianlindfors/reshape).
74+Reshape is available as a Docker image on [Docker Hub](https://hub.docker.com/repository/docker/fabianlindfors/reshape).
77−docker run -v $(pwd):/usr/share/app fabianlindfors/reshape reshape migration start
77+docker run -v $(pwd):/usr/share/app fabianlindfors/reshape reshape migrate
80### Creating your first migration
80### Creating your first migration
@@ -103,14 +103,9 @@ This is the equivalent of running `CREATE TABLE users (id INTEGER GENERATED ALWA
104### Preparing your application
104### Preparing your application
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. The simplest way to do this is to use one of the helper libraries:
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`.
108−- [Rust](https://github.com/fabianlindfors/reshape-helper)
109−- [Ruby (and Rails)](https://github.com/fabianlindfors/reshape-ruby)
110−- [Python (and Django)](https://github.com/fabianlindfors/reshape-python)
111−- [Go](https://github.com/leourbina/reshape-helper)
113−If your application is not using one of the languages with an available helper library, you can instead generate the query with the command: `reshape schema-query`. 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:
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:
116# Example for Python
111# Example for Python
@@ -118,21 +113,23 @@ reshape_schema_query = os.getenv("RESHAPE_SCHEMA_QUERY")
118db.execute(reshape_schema_query)
113db.execute(reshape_schema_query)
116+If your application is written in Rust, you might prefer the [Rust helper library](https://github.com/fabianlindfors/reshape-helper) which embeds the query directly in your application with a macro.
121### Running your migration
118### Running your migration
123To create your new `users` table, run:
120To create your new `users` table, run:
126−reshape migration start --complete
123+reshape migrate --complete
129−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.
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.
131If 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.
128If 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.
133### Using during development
130### Using during development
135−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`.
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`.
137## Writing migrations
134## Writing migrations
@@ -167,9 +164,9 @@ Every action has a `type`. The supported types are detailed below.
168#### Create table
165#### Create table
170−The `create_table` action will create a new table with the specified columns, indices and constraints. You can optionally provide an `up` option to backfill values from an existing table.
167+The `create_table` action will create a new table with the specified columns, indices and constraints.
172−_Example: create a `customers` table with a few columns and a primary key_
169+*Example: create a `customers` table with a few columns and a primary key*
175[[actions]]
172[[actions]]
@@ -187,13 +184,13 @@ primary_key = ["id"]
187 type = "TEXT"
184 type = "TEXT"
189 # Columns default to nullable
186 # Columns default to nullable
190− nullable = false
187+ nullable = false
192 # default can be any valid SQL value, in this case a string literal
189 # default can be any valid SQL value, in this case a string literal
193− default = "'PLACEHOLDER'"
190+ default = "'PLACEHOLDER'"
196−_Example: create `users` and `items` tables with a foreign key between them_
193+*Example: create `users` and `items` tables with a foreign key between them*
199[[actions]]
196[[actions]]
@@ -226,34 +223,11 @@ primary_key = ["id"]
226 referenced_columns = ["id"]
223 referenced_columns = ["id"]
229−_Example: create `profiles` table based on existing `users` table_
233−type = "create_table"
235−primary_key = ["user_id"]
245− # Backfill from `users` table and copy `users.email` to `user_email` column
246− # This will perform an upsert based on the primary key to avoid duplicate rows
249− values = { user_id = "id", user_email = "email" }
252#### Rename table
226#### Rename table
254The `rename_table` action will change the name of an existing table.
228The `rename_table` action will change the name of an existing table.
256−_Example: change name of `users` table to `customers`_
230+*Example: change name of `users` table to `customers`*
259[[actions]]
233[[actions]]
@@ -266,7 +240,7 @@ new_name = "customers"
267The `remove_table` action will remove an existing table.
241The `remove_table` action will remove an existing table.
269−_Example: remove `users` table_
243+*Example: remove `users` table*
272[[actions]]
246[[actions]]
@@ -278,7 +252,7 @@ table = "users"
279The `add_foreign_key` action will add a foreign key between two existing tables. The migration will fail if the existing column values aren't valid references.
253The `add_foreign_key` action will add a foreign key between two existing tables. The migration will fail if the existing column values aren't valid references.
281−_Example: create foreign key from `items` to `users` table_
255+*Example: create foreign key from `items` to `users` table*
284[[actions]]
258[[actions]]
@@ -295,7 +269,7 @@ table = "items"
296The `remove_foreign_key` action will remove an existing foreign key. The foreign key will only be removed once the migration is completed, which means that your new application must continue to adhere to the foreign key constraint.
270The `remove_foreign_key` action will remove an existing foreign key. The foreign key will only be removed once the migration is completed, which means that your new application must continue to adhere to the foreign key constraint.
298−_Example: remove foreign key `items_user_id_fkey` from `users` table_
272+*Example: remove foreign key `items_user_id_fkey` from `users` table*
301[[actions]]
275[[actions]]
@@ -308,9 +282,9 @@ foreign_key = "items_user_id_fkey"
309#### Add column
283#### Add column
311−The `add_column` action will add a new column to an existing table. You can optionally provide an `up` setting. This should be an SQL expression which will be run for all existing rows to backfill the new column. `up` may also reference another table to perform cross-table migrations (see ["Complex changes across tables"](#complex-changes-across-tables)).
285+The `add_column` action will add a new column to an existing table. You can optionally provide an `up` setting. This should be an SQL expression which will be run for all existing rows to backfill the new column.
313−_Example: add a new column `reference` to table `products`_
287+*Example: add a new column `reference` to table `products`*
316[[actions]]
290[[actions]]
@@ -324,7 +298,7 @@ table = "products"
324 default = "10"
298 default = "10"
327−_Example: replace an existing `name` column with two new columns, `first_name` and `last_name`_
301+*Example: replace an existing `name` column with two new columns, `first_name` and `last_name`*
330[[actions]]
304[[actions]]
@@ -360,7 +334,7 @@ column = "name"
360down = "first_name || ' ' || last_name"
334down = "first_name || ' ' || last_name"
363−_Example: extract nested value from unstructured JSON `data` column to new `name` column_
337+*Example: extract nested value from unstructured JSON `data` column to new `name` column*
366[[actions]]
340[[actions]]
@@ -375,25 +349,6 @@ up = "data['path']['to']['value'] #>> '{}'"
375 type = "TEXT"
349 type = "TEXT"
378−_Example: duplicate `email` column from `users` to `profiles` table_
381−# `profiles` has `user_id` column which maps to `users.id`
391− # When `users` is updated in the old schema, we write the email value to `profiles`
395− where = "user_id = id"
398#### Alter column
353#### Alter column
@@ -401,7 +356,7 @@ The `alter_column` action enables many different changes to an existing column,
402When performing more complex changes than a rename, `up` and `down` should be provided. These should be SQL expressions which determine how to transform between the new and old version of the column. Inside those expressions, you can reference the current column value by the column name.
357When performing more complex changes than a rename, `up` and `down` should be provided. These should be SQL expressions which determine how to transform between the new and old version of the column. Inside those expressions, you can reference the current column value by the column name.
404−_Example: rename `last_name` column on `users` table to `family_name`_
359+*Example: rename `last_name` column on `users` table to `family_name`*
407[[actions]]
362[[actions]]
@@ -413,7 +368,7 @@ column = "last_name"
413 name = "family_name"
368 name = "family_name"
416−_Example: change the type of `reference` column from `INTEGER` to `TEXT`_
371+*Example: change the type of `reference` column from `INTEGER` to `TEXT`*
419[[actions]]
374[[actions]]
@@ -428,7 +383,7 @@ down = "CAST(reference AS INTEGER)" # Converts from text value to integer
428 type = "TEXT" # Previous type was 'INTEGER'
383 type = "TEXT" # Previous type was 'INTEGER'
431−_Example: increment all values of an `index` column by one_
386+*Example: increment all values of an `index` column by one*
434[[actions]]
389[[actions]]
@@ -443,7 +398,7 @@ down = "index - 1" # Decrement to revert for old schema
443 name = "index"
398 name = "index"
446−_Example: make `name` column not nullable_
401+*Example: make `name` column not nullable*
449[[actions]]
404[[actions]]
@@ -458,7 +413,7 @@ up = "COALESCE(name, 'N/A')"
458 nullable = false
413 nullable = false
461−_Example: change default value of `created_at` column to current time_
416+*Example: change default value of `created_at` column to current time*
464[[actions]]
419[[actions]]
@@ -472,11 +427,11 @@ column = "created_at"
473#### Remove column
428#### Remove column
475−The `remove_column` action will remove an existing column from a table. You can optionally provide a `down` setting. This should be an SQL expression which will be used to determine values for the old schema when inserting or updating rows using the new schema. `down` may also reference another table to perform cross-table migrations (see ["Complex changes across tables"](#complex-changes-across-tables)) . The `down` setting must be provided when the removed column is `NOT NULL` or doesn't have a default value.
430+The `remove_column` action will remove an existing column from a table. You can optionally provide a `down` setting. This should be an SQL expression which will be used to determine values for the old schema when inserting or updating rows using the new schema. The `down` setting must be provided when the removed column is `NOT NULL` or doesn't have a default value.
477Any indices that cover the column will be removed.
432Any indices that cover the column will be removed.
479−_Example: remove column `name` from table `users`_
434+*Example: remove column `name` from table `users`*
482[[actions]]
437[[actions]]
@@ -488,34 +443,18 @@ column = "name"
488down = "'N/A'"
443down = "'N/A'"
491−_Example: remove `email` column from `users` table and use column from `profiles` table instead_
495−type = "remove_column"
499− # Our application will use the `profiles.email` column instead
500− # For backwards compatibility, we will write back to the removed `email` column whenever `profiles` is changed
503− value = "profiles.email"
504− where = "users.id = profiles.user_id"
507### Indices
446### Indices
509#### Add index
448#### Add index
511The `add_index` action will add a new index to an existing table.
450The `add_index` action will add a new index to an existing table.
513−_Example: create a `users` table with a unique index on the `name` column_
452+*Example: create a `users` table with a unique index on the `name` column*
516[[actions]]
455[[actions]]
517type = "create_table"
456type = "create_table"
518−name = "users"
457+table = "users"
519primary_key = "id"
458primary_key = "id"
521 [[actions.columns]]
460 [[actions.columns]]
@@ -539,7 +478,7 @@ table = "users"
539 unique = true
478 unique = true
542−_Example: add GIN index to `data` column on `products` table_
481+*Example: add GIN index to `data` column on `products` table*
545[[actions]]
484[[actions]]
@@ -558,7 +497,7 @@ table = "products"
559The `remove_index` action will remove an existing index. The index won't actually be removed until the migration is completed.
498The `remove_index` action will remove an existing index. The index won't actually be removed until the migration is completed.
561−_Example: remove the `name_idx` index_
500+*Example: remove the `name_idx` index*
564[[actions]]
503[[actions]]
@@ -572,7 +511,7 @@ index = "name_idx"
573The `create_enum` action will create a new [enum type](https://www.postgresql.org/docs/current/datatype-enum.html) with the specified values.
512The `create_enum` action will create a new [enum type](https://www.postgresql.org/docs/current/datatype-enum.html) with the specified values.
575−_Example: add a new `mood` enum type with three possible values_
514+*Example: add a new `mood` enum type with three possible values*
578[[actions]]
517[[actions]]
@@ -585,7 +524,7 @@ values = ["happy", "ok", "sad"]
586The `remove_enum` action will remove an existing [enum type](https://www.postgresql.org/docs/current/datatype-enum.html). Make sure all usages of the enum has been removed before running the migration. The enum will only be removed once the migration is completed.
525The `remove_enum` action will remove an existing [enum type](https://www.postgresql.org/docs/current/datatype-enum.html). Make sure all usages of the enum has been removed before running the migration. The enum will only be removed once the migration is completed.
588−_Example: remove the `mood` enum type_
527+*Example: remove the `mood` enum type*
591[[actions]]
530[[actions]]
@@ -599,11 +538,11 @@ The `custom` action lets you create a migration which runs custom SQL. It should
600There 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.
539There 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.
602−- `start`: run when a migration is started using `reshape migration start`
541+- `start`: run when a migration is started using `reshape migrate`
603−- `complete`: run when a migration is completed using `reshape migration complete`
542+- `complete`: run when a migration is completed using `reshape complete`
604−- `abort`: run when a migration is aborted using `reshape migration abort`
543+- `abort`: run when a migration is aborted using `reshape abort`
606−_Example: enable PostGIS and pg_stat_statements extensions_
545+*Example: enable PostGIS and pg_stat_statements extensions*
609[[actions]]
548[[actions]]
@@ -615,140 +554,52 @@ start = """
617abort = """
556abort = """
618− DROP EXTENSION IF EXISTS postgis;
557+ DROP EXTENSION IF NOT EXISTS postgis;
619− DROP EXTENSION IF EXISTS pg_stat_statements;
558+ DROP EXTENSION IF NOT EXISTS pg_stat_statements;
623−### Complex changes across tables
625−The `up` and `down` options available when creating tables, adding columns and removing columns can also perform more complex changes that span tables.
627−_Example: move `email` column from `users` to `profiles` table_
639− # When `users` is updated in the old schema, we write the email value to `profiles`
642− value = "users.email"
643− where = "profiles.user_id = users.id"
646−type = "remove_column"
650− # When `profiles` is changed in the new schema, we write the email address back to the removed column
653− value = "profiles.email"
654− where = "users.id = profiles.user_id"
657−_Example: turn a 1:N relationship between `users` and `accounts` into N:M and change the format of the associated `role`_
660−# Add `user_account_connections` as a junction table
662−type = "create_table"
663−name = "user_account_connections"
664−primary_key = ["account_id", "user_id"]
674− # `role` is currently stored directly on the `users` table but is part of the relationship
680− # Backfill the new table from `users` and uppercase the `role`
683− values = { user_id = "id", account_id = "account_id", role = "UPPER(account_role)" }
684− where = "user_account_connections.user_id = users.id"
687−type = "remove_column"
689−column = "account_id"
691− # When `user_account_connections` is updated, we write the `account_id` back to `users`
693− table = "user_account_connections"
694− value = "user_account_connections.account_id"
695− where = "users.id = user_account_connections.user_id"
698−type = "remove_column"
700−column = "account_role"
702− # When `user_account_connections` is updated, we write the lowercase role back to `users`
704− table = "user_account_connections"
705− value = "LOWER(user_account_connections.role)"
706− where = "users.id = user_account_connections.user_id"
709## Commands and options
562## Commands and options
711−### `reshape migration start`
564+### `reshape migrate`
713−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`.
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`.
715#### Options
568#### Options
717−_See also [Connection options](#connection-options)_
570+*See also [Connection options](#connection-options)*
719−| Option | Default | Description |
572+| Option | Default | Description |
720−| ------------------ | ------------- | --------------------------------------------------------------------------------------------------------------- |
573+| ------ | ------- | ----------- |
721−| `--complete`, `-c` | `false` | Automatically complete migration after applying it. |
574+| `--complete`, `-c` | `false` | Automatically complete migration after applying it. |
722−| `--dirs` | `migrations/` | Directories to search for migration files. Multiple directories can be specified using `--dirs dir1 dir2 dir3`. |
575+| `--dirs` | `migrations/` | Directories to search for migration files. Multiple directories can be specified using `--dirs dir1 dir2 dir3`. |
724−### `reshape migration complete`
577+### `reshape complete`
726−Completes migrations previously started with `reshape migration complete`.
579+Completes migrations previously started with `reshape complete`.
728#### Options
581#### Options
730See [Connection options](#connection-options)
583See [Connection options](#connection-options)
732−### `reshape migration abort`
585+### `reshape abort`
734−Aborts any migrations which haven't yet been completed.
587+Aborts any migrations which haven't yet been completed.
736#### Options
589#### Options
738See [Connection options](#connection-options)
591See [Connection options](#connection-options)
740−### `reshape schema-query`
593+### `reshape generate-schema-query`
742Generates 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`).
595Generates 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`).
744−If your application is written in Rust, we recommend using the [Rust helper library](https://github.com/fabianlindfors/reshape-helper/) instead.
746The query should look something like `SET search_path TO migration_1_initial_migration`.
597The query should look something like `SET search_path TO migration_1_initial_migration`.
748#### Options
599#### Options
750−| Option | Default | Description |
601+| Option | Default | Description |
751−| -------- | ------------- | --------------------------------------------------------------------------------------------------------------- |
602+| ------ | ------- | ----------- |
752| `--dirs` | `migrations/` | Directories to search for migration files. Multiple directories can be specified using `--dirs dir1 dir2 dir3`. |
603| `--dirs` | `migrations/` | Directories to search for migration files. Multiple directories can be specified using `--dirs dir1 dir2 dir3`. |
754### Connection options
605### Connection options
@@ -757,14 +608,14 @@ The options below can be used with all commands that communicate with Postgres.
758All options can also be set using environment variables instead of flags. If a `.env` file exists, then variables will be automatically loaded from there.
609All options can also be set using environment variables instead of flags. If a `.env` file exists, then variables will be automatically loaded from there.
760−| Option | Default | Environment variable | Description |
611+| Option | Default | Environment variable | Description |
761−| ------------ | ----------- | -------------------- | ------------------------------------------- |
612+| ------ | ------- | -------------------- | ----------- |
762−| `--url` | | `DB_URL` | URL to your Postgres database |
613+| `--url` | | `DB_URL` | URL to your Postgres database |
763−| `--host` | `localhost` | `DB_HOST` | Hostname to use when connecting to Postgres |
614+| `--host` | `localhost` | `DB_HOST` | Hostname to use when connecting to Postgres |
764−| `--port` | `5432` | `DB_PORT` | Port which Postgres is listening on |
615+| `--port` | `5432` | `DB_PORT` | Port which Postgres is listening on |
765−| `--database` | `postgres` | `DB_NAME` | Database name |
616+| `--database` | `postgres` | `DB_NAME` | Database name |
766−| `--username` | `postgres` | `DB_USERNAME` | Postgres username |
617+| `--username` | `postgres` | `DB_USERNAME` | Postgres username |
767−| `--password` | `postgres` | `DB_PASSWORD` | Postgres password |
618+| `--password` | `postgres` | `DB_PASSWORD` | Postgres password |
769## License
620## License