Commit Graph

14 Commits

Author SHA1 Message Date
fabianlindfors
814620a215 Add new add_foreign_key action 2022-01-21 18:00:41 +01:00
fabianlindfors
9cac25299a Refactor tests to use test framework
This has the added benefit of removing the need for builders and the
derive_builder dependency.
2022-01-15 16:15:31 +01:00
fabianlindfors
a7d70f80b8 Use TOML for migrations in test framework
Previously we set up migrations directly as structs which doesn't match
how users will create them. For the new test framework, we'll instead
write TOML for migrations. This brings the tests closer to how an end
user will interact with Reshape and also lets us write tests to match
the examples in the documentation.
2022-01-15 14:47:28 +01:00
fabianlindfors
945e6374d8 Add test framework
This reduces the amount of boilerplate required to run a test and also
has the added benefit of extending tests as we can now easily test both the
completion and abort paths. So far two tests have been ported over,
create_table and add_column, with the rest to follow.

The framework also improves the output of tests, adding sections clearly
indicating in which part of the migration process a test failed.
2022-01-14 23:49:19 +01:00
fabianlindfors
2d04d33b95 Switch State struct into enum
With the old fields in the `State` broken out we can now make `State` a
proper enum, replacing the nested `Status`. The naming with both `State`
and `Status` was a bit confusing.
2022-01-14 00:12:01 +01:00
fabianlindfors
7c48974308 Use separate table for completed migrations
Before, the entire state was stored as a JSON encoded blob including all
completed migrations. This commits moves the migrations into a dedicated
table, which prevents the encoded from growing indefinitely. The size of
the state probably wouldn't have become a problem but it feels weird for
a schema migration tool to not use a proper schema.

Next, the version stored in the state struct will be moved to a separate
key in the `reshape.data` table and `State` will become an enum with the
same structure as `Status`. The naming right now is a bit confusing.
2022-01-13 23:46:07 +01:00
fabianlindfors
86b649d14a Copy indices to temporary columns for alter_column
Until now, using alter_column would cause indices to be lost as they
weren't copied to the temporary column. This fixes that for indices that
consist of one or more actual columns. It won't work for indices on
expressions.
2022-01-13 18:19:54 +01:00
fabianlindfors
c76ea1fba6 Add builder for create_table migration
The builder will help simplify the tests and avoid boilerplate updates
when need fields are added to the create_table migration. We might want
to add builders all migrations later.
2022-01-10 21:59:20 +01:00
fabianlindfors
9b21ebfb86 Add check for dangling changes at end of tests
This checks for dangling temporary columns, triggers and function which
were used by migrations but should be removed once the migration has
been completed or aborted.
2022-01-03 22:09:16 +01:00
fabianlindfors
fda6dc8f40 Add support for generated constraints on columns 2021-12-28 16:01:11 +01:00
fabianlindfors
78d8aabd5b Enable composite primary keys when creating table
Also makes the primary key a mandatory field. We'll need primary keys in
order to perform efficient batch updates later.
2021-11-08 23:32:14 +01:00
fabianlindfors
c27afadbd2 Add foreign keys option to create table migration 2021-10-27 00:10:02 +02:00
fabianlindfors
10699fa46c Add primary key option to create table migration 2021-10-26 23:00:18 +02:00
fabianlindfors
7d8302a0a4 Initial commit 2021-10-26 00:31:09 +02:00