A crate for testing Sea Orm Migrators. To check if when you call up
and then down
on them. They work in both directions.
It runs your migrations up and down one at a time. Taking a look at the differences it does to a database. Checking if the reverse returns a database into it's previous state.
Example
The most common use case is simply to test if your Migrator
is reversible.
In a test. Then error if it is not.
To do this add the following test to your migrations project ...
= "1"
Example with tokio::test
If you are already using Tokio to test your project. Then the following may be better.
= { = "1", = false }
Caveats
- This only tests for structural differences. It does not look for data changes.
- It uses an in-memeory SQLite database to test the migrator. Any Postgres or MySQL specific features may not work correctly.
API
The library provides two non-async functions. These handle the async bits for you by bundling Tokio.
assert_migrator_reversible
- The main way to test if your Migrator is reversible. Pass in a Migrator. It'll run it up and down. If it isn't reversible, it will panic.find_index_of_non_reversible_migration
- This is very similar toassert_migrator_reversible
. It will find a migration that isn't reversible. When found, it will return the index. It will not panic.
Async versions of those functions are available. This is useful if you wish to not have this import Tokio (as it's quite big). Instead handle this yourself.
Features
tokio
Default - This adds Tokio support. Which enables the functionsassert_migrator_reversible
andfind_index_of_non_reversible_migration
. This makes testing easier and simpler. You might want to disable this if you are already using Tokio in your tests, and wish to make this dependency smaller.runtime-actix-native-tls
- Sets Sea-Orm Migrations to use this runtime.runtime-actix-rustls
- Sets Sea-Orm Migrations to use this runtime.runtime-async-std-native-tls
- Sets Sea-Orm Migrations to use this runtime.runtime-async-std-rustls
- Sets Sea-Orm Migrations to use this runtime.runtime-tokio-native-tls
Default - Sets Sea-Orm Migrations to use this runtime.runtime-tokio-rustls
- Sets Sea-Orm Migrations to use this runtime.