Commit Graph

163 Commits

Author SHA1 Message Date
fabianlindfors
6034dfebbd Add up option to create_table 2023-11-22 22:18:52 +01:00
fabianlindfors
42257be9cf Add README section on cross-table migrations 2023-11-22 00:15:21 +01:00
fabianlindfors
4e5cc5c4ff Add support for complex up function in 2023-11-22 00:04:45 +01:00
fabianlindfors
fc3b29d090 Fix incorrect example 2023-11-21 23:25:51 +01:00
fabianlindfors
b4baef2bc8 Add support for user defined types 2023-11-21 23:23:23 +01:00
fabianlindfors
9512c80de9 Add support for complex down function in 2023-11-21 23:22:20 +01:00
fabianlindfors
21266e227f Add ReshapeDB callout to README 2023-11-07 00:41:47 +01:00
fabianlindfors
0df9f8b27e Remove experimental note from README 2023-11-07 00:40:46 +01:00
fabianlindfors
d07ceb01eb Reformat README 2023-11-07 00:40:20 +01:00
Leo Urbina
be035462f5
Add reference to Go helper library (#26)
Co-authored-by: Leo Urbina <me@leourbina.com>
2023-10-06 23:39:50 +02:00
iko
7be33f7b7e
Added yet more quotes (#23) 2023-04-05 23:36:12 +02:00
iko
21b064532a
Added missing quotes (#21) 2023-01-28 17:06:22 +01:00
fabianlindfors
7be3afa336 Fix error not stopping migration 2023-01-09 17:26:57 +01:00
April Schleck
afddfbff88
Fix syntax error in README (#16)
Co-authored-by: April Schleck <april@exclusivelyducks.com>
2022-10-02 22:03:12 +02:00
fabianlindfors
706a4505c4 Add link to Python helper library to README 2022-08-03 19:02:43 +02:00
fabianlindfors
d74ab4f34f Version 0.6.1 2022-08-03 16:04:23 +02:00
fabianlindfors
5a6aff1290 Fix migration files not sorted naturally
Closes #15
2022-07-26 16:00:08 +02:00
April Schleck
ce7a0b38ee
Output the failing filename when showing a parse error (#13)
Co-authored-by: April Schleck <april@exclusivelyducks.com>
2022-07-26 15:59:16 +02:00
April Schleck
b626ee119f
Fix incorrect example (#14)
Co-authored-by: April Schleck <april@exclusivelyducks.com>
2022-07-26 15:23:51 +02:00
fabianlindfors
57160e14b3 Fix missing test run call 2022-06-30 17:17:50 +02:00
fabianlindfors
8b6c817b30 Update README with details on Ruby helper library 2022-05-18 14:58:21 +02:00
fabianlindfors
0195102e9b Version 0.6.0 2022-04-22 10:47:33 +02:00
fabianlindfors
df938fa4d4 Update docs and error messages with new CLI commands 2022-04-22 10:45:03 +02:00
fabianlindfors
88fca45c06 Add new custom action
This action enables migrations to run custom SQL and is meant to be used
when no other actions fit. It doesn't provide any guarantees for
zero-downtime.
2022-04-21 23:42:41 +02:00
fabianlindfors
696a6e57da Switch CLI command names
All the existing commands have been replaced with new commands which
read a bit better and leave better room for more commands in the future.

The following changes have been made:
- `reshape start` -> `reshape migration start`
- `reshape complete` -> `reshape migration complete`
- `reshape abort` -> `reshape migration abort`
- `reshape generate-schema-query` -> `reshape schema-query`

The old commands are still available but are marked as deprecated in the
help output and will be removed in the future. The README will be
updated later.

Closes #10
2022-04-19 23:24:29 +02:00
fabianlindfors
8f0658ab64 Update clap to 3.1.9 2022-04-19 23:24:05 +02:00
fabianlindfors
8a61a03ab8 Add note on the Rust helper library 2022-04-19 20:15:59 +02:00
fabianlindfors
7be40f2b29 Version 0.5.1 2022-02-05 22:16:49 +01:00
fabianlindfors
4025b7d811 Remove duplicate word in README 2022-02-05 22:16:34 +01:00
fabianlindfors
336e73394d Remove remove command from CLI
The `remove` command isn't very useful to end users and is also
dangerous as it will delete all data.
2022-02-04 17:56:36 +01:00
fabianlindfors
72c42ba912 Remove extra backtick in README 2022-02-04 17:55:48 +01:00
fabianlindfors
7cc4f23db9 Fix changing nullability not working with alter_column
The existing test to set a column as NOT NULL didn't actually check that
the constraint was added, which has also been fixed. I also added a new
test for the opposite change, making a NOT NULL column nullable. The
README has also been updated with a new example for setting a column as
NOT NULL.
2022-02-04 17:47:39 +01:00
fabianlindfors
aff5527799 Version 0.5.0 2022-02-04 00:08:28 +01:00
fabianlindfors
a07979a97a Use .env file for environment variables 2022-02-03 23:57:02 +01:00
fabianlindfors
8129fdbf41 Add env var alternatives for all connection options
Also fixes a bug where the `--database` option would do nothing.
2022-02-03 23:48:59 +01:00
fabianlindfors
5529d224b6 Replace POSTGRES_URL env var with DB_URL
Also fixes the documentation which was incorrect before.
2022-02-03 23:27:44 +01:00
fabianlindfors
033ac5b2f1 Add version and description to CLI 2022-02-03 23:26:50 +01:00
fabianlindfors
ef6fe64918 Fix incorrect minimum Rust version 2022-02-03 14:25:06 +01:00
fabianlindfors
8b2efd9624 Add minimum Rust version to Cargo.toml 2022-02-03 14:22:58 +01:00
fabianlindfors
3a4f0f7f9a Remove autocompletion of first migration
For Reshape to work with an existing database, the first migration
shouldn't autocomplete as then there can't be a zero-downtime
deployment. The user should instead use `--complete` if they don't care
about zero-downtime, for example when setting up a dev or CI
environment. We should update the `--complete` flag to apply and
complete each migration one by one for efficiency.
2022-02-01 09:50:02 +01:00
fabianlindfors
8888557c38 Check for new schema rather than old in helper
We want it to be possible for Reshape to be adopted for existing
databases with an existing schema. To make this possible, we can't check
if the schema path matches the current migration as there won't be a
current migration at first. Instead we'll compare against the target
migration.

The next step in making Reshape work with existing databases is to not
automatically complete the first migration. This will not be safe for an
existing application adopting Reshape.
2022-01-31 19:53:49 +01:00
fabianlindfors
4e93a39be0 Add remove_foreign_key action 2022-01-27 23:33:23 +01:00
fabianlindfors
5984c1c507 Fix typo in README 2022-01-25 22:26:03 +01:00
fabianlindfors
3a6c57c145 Add JSON extraction example to README 2022-01-25 22:14:47 +01:00
fabianlindfors
f6d6f28546 Fix misaligned delimiters in test output 2022-01-25 21:55:46 +01:00
fabianlindfors
6fcab3c88d Fix clippy warning for match on DB error 2022-01-25 21:45:48 +01:00
fabianlindfors
40fb39741d Add automatic retry of queries
Database queries will now be retried if possible using exponential
backoff with jitter. This should help protect against connection
problems and also timeouts caused by us now setting lock_timeout to
avoid blocking other queries. If such a timeout occurs, we should fail
to let waiting queries execute and then try again until the blocking
queries have completed.
2022-01-25 16:27:33 +01:00
fabianlindfors
c3369a4c12 Set lock_timeout to limit blocking of other queries
When attempting to acquire a lock for DDL queries, Postgres will wait
for any long-running queries to complete first. It will also block any
other queries that need access, which causes a queue of queries until we
release our lock. This has the effect of long-running queries blocking
other queries when we perform migrations, which is equivalent to
downtime if the query runs for long enough.

To avoid this, we set the `lock_timeout` setting. This puts an upper
bound on how long we will wait for a lock and also for how long other
queries can be blocked by a long-running query. The next step will be to
add automatic retries to handle timeouts gracefully.

Reference: https://medium.com/paypal-tech/postgresql-at-scale-database-schema-changes-without-downtime-20d3749ed680
2022-01-25 10:45:04 +01:00
fabianlindfors
f754ac0abc Version 0.4.0 2022-01-24 11:44:26 +01:00
fabianlindfors
814620a215 Add new add_foreign_key action 2022-01-21 18:00:41 +01:00