Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

async: add tiberius driver support #169

Merged
merged 2 commits into from
Aug 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:
- test-tokio-postgres
- test-mysql
- test-mysql-async
- test-tiberius
- doc
steps:
- run: exit 0
Expand Down Expand Up @@ -88,7 +89,7 @@ jobs:
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
- run: cd refinery && cargo test --features tokio,tokio-postgres --test tokio_postgres -- --test-threads 1
- run: cd refinery && cargo test --features tokio-postgres --test tokio_postgres -- --test-threads 1

test-mysql:
name: Test mysql
Expand Down Expand Up @@ -135,7 +136,29 @@ jobs:
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
- run: cd refinery && cargo test --features tokio,mysql_async --test mysql_async -- --test-threads 1
- run: cd refinery && cargo test --features mysql_async --test mysql_async -- --test-threads 1

test-tiberius:
name: Test tiberius
runs-on: ubuntu-latest
strategy:
matrix:
rust: [stable, nightly, 1.52.0]
services:
mssql:
image: mcr.microsoft.com/mssql/server:2017-latest
ports:
- 1433:1433
env:
ACCEPT_EULA: yes
SA_PASSWORD: Passw0rd
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
- run: cargo install --path ./refinery_cli --no-default-features --features=mssql
- run: cd refinery && cargo test --features tiberius --test tiberius -- --test-threads 1

doc:
name: Build docs
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ For more examples, refer to the [`examples`](examples).
### Unversioned VS Versioned migrations

Depending on how your project / team has been structured will define whether you want to use Versioned migrations `V{1}__{2}.[sql|rs]` or Unversioned migrations `U{1}__{2}.[sql|rs]`.
If all migrations are created synchronously and are deployed synchronously you won't run into any problems using Versioned migrations.
If all migrations are created synchronously and are deployed synchronously you won't run into any problems using Versioned migrations.
This is because you can be sure the next migration being run is _always_ going to have a version number greater than the previous.

With Unversioned migrations there is more flexibility in the order that the migrations can be created and deployed.
With Unversioned migrations there is more flexibility in the order that the migrations can be created and deployed.
If developer 1 creates a PR with a migration today `U11__update_cars_table.sql`, but it is reviewed for a week.
Meanwhile developer 2 creates a PR with migration `U12__create_model_tags.sql` that is much simpler and gets merged and deployed immediately.
This would stop developer 1's migration from ever running if you were using Versioned migrations because the next migration would need to be > 12.
Expand All @@ -67,15 +67,15 @@ By default, refinery runs each migration in a single transaction. Alternatively,

refinery's design is based on [flyway](https://flywaydb.org/) and so, shares its [perspective](https://flywaydb.org/documentation/command/undo#important-notes) on undo/rollback migrations. To undo/rollback a migration, you have to generate a new one and write specifically what you want to undo.

## Compatibility
## MSRV

refinery aims to support stable Rust, the previous Rust version, and nightly.

## Async

Starting with version 0.2 refinery supports [tokio-postgres](https://crates.io/crates/tokio-postgres) and [`mysql_async`](https://crates.io/crates/mysql_async). To migrate async you have to call `Runner`'s [run_async](https://docs.rs/refinery/latest/refinery/struct.Runner.html).
There are plans to support [Tiberius](https://github.com/steffengy/tiberius) when futures 0.3 support stabilizes.
For Rusqlite, the best way to run migrations in an async context is to run them inside tokio's [`spawn_blocking`](https://docs.rs/tokio/0.2.21/tokio/task/fn.spawn_blocking.html) for example.
Starting with version 0.2 refinery supports [tokio-postgres](https://crates.io/crates/tokio-postgres), [`mysql_async`](https://crates.io/crates/mysql_async)
and [Tiberius](https://github.com/prisma/tiberius)
For Rusqlite, the best way to run migrations in an async context is to run them inside tokio's [`spawn_blocking`](https://docs.rs/tokio/1.10.0/tokio/task/fn.spawn_blocking.html) for example.

## Contributing

Expand Down
7 changes: 5 additions & 2 deletions refinery/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,19 @@ postgres = ["refinery-core/postgres"]
mysql = ["refinery-core/mysql"]
tokio-postgres = ["refinery-core/tokio-postgres"]
mysql_async = ["refinery-core/mysql_async"]
tokio = ["refinery-core/tokio"]
tiberius = ["refinery-core/tiberius"]
tiberius-config = ["refinery-core/tiberius", "refinery-core/tiberius-config"]

[dependencies]
refinery-core= { version = "0.6.0", path = "../refinery_core" }
refinery-macros= { version = "0.6.0", path = "../refinery_macros" }

[dev-dependencies]
barrel = { version = "0.6", features = ["sqlite3", "pg", "mysql"] }
barrel = { git = "https://git.irde.st/spacekookie/barrel.git", features = ["sqlite3", "pg", "mysql", "mssql"] }
futures = "0.3"
assert_cmd = "1.0"
predicates = "1"
tempfile = "3"
chrono = "0.4"
tokio-util = { version = "0.6.7", features = ["compat"] }
tokio = { version = "1.9.0", features = ["full"] }
Loading