Skip to content

Commit 10991f3

Browse files
authored
Merge branch 'main' into update-msrv
2 parents 72524ef + 2187a03 commit 10991f3

File tree

22 files changed

+109
-126
lines changed

22 files changed

+109
-126
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -174,16 +174,12 @@ jobs:
174174
strategy:
175175
matrix:
176176
rust: ${{ fromJson(needs.set-rust-versions.outputs.versions) }}
177-
services:
178-
mssql:
179-
image: mcr.microsoft.com/mssql/server:2017-latest
180-
ports:
181-
- 1433:1433
182-
env:
183-
ACCEPT_EULA: yes
184-
SA_PASSWORD: Passw0rd
185177
steps:
186178
- uses: actions/checkout@v2
179+
- uses: potatoqualitee/[email protected]
180+
with:
181+
install: sqlengine, sqlpackage
182+
sa-password: Passw0rd
187183
- uses: actions-rs/toolchain@v1
188184
with:
189185
toolchain: ${{ matrix.rust }}

CHANGELOG.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,28 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [0.8.16] - 2024-02-21
8+
### Fixed
9+
- Revert [#346](https://github.com/rust-db/refinery/pull/346) as it breaks Semver, save it for a minor release in the future.
10+
11+
## [0.8.15] - **YANKED** - 2024-02-18
12+
13+
### Added
14+
- Make a query overridable. [#358](https://github.com/rust-db/refinery/pull/358)
15+
- Enable math functions for SQLite. [#335](https://github.com/rust-db/refinery/pull/335)
16+
- Add serde subfeature to tiberius-config. [#334](https://github.com/rust-db/refinery/pull/334)
17+
18+
### Changed
19+
- Update `mysql` version to allow `26`, [#365](https://github.com/rust-db/refinery/pull/365)
20+
- Update `mysql_async` to allow `0.35`, [#359](https://github.com/rust-db/refinery/pull/359)
21+
- Update `rusqlite` to allow `0.33`, [#361](https://github.com/rust-db/refinery/pull/361)
22+
- Update migrate Transaction and AsyncTransaction execute functions to avoid double iteration when calling migrate with the grouped option active. [#346](https://github.com/rust-db/refinery/pull/346)
23+
- Update overall dependencies. [#340](https://github.com/rust-db/refinery/pull/340)
24+
25+
### Fixed
26+
- Fix misleading CLI arguments descriptions [#336](https://github.com/rust-db/refinery/pull/336)
27+
28+
729
## [0.8.14] - 2024-04-03
830

931
### Added

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,7 @@ members = [
77
"refinery_macros",
88
"examples",
99
]
10+
11+
[profile.release]
12+
codegen-units = 1
13+
lto = true

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ This would stop developer 1's migration from ever running if you were using cont
9696

9797
refinery works by creating a table that keeps all the applied migrations' versions and their metadata. When you [run](https://docs.rs/refinery/latest/refinery/struct.Runner.html#method.run) the migrations `Runner`, refinery compares the applied migrations with the ones to be applied, checking for [divergent](https://docs.rs/refinery/latest/refinery/struct.Runner.html#method.set_abort_divergent) and [missing](https://docs.rs/refinery/latest/refinery/struct.Runner.html#method.set_abort_missing) and executing unapplied migrations.\
9898
By default, refinery runs each migration in a single transaction. Alternatively, you can also configure refinery to wrap the entire execution of all migrations in a single transaction by setting [set_grouped](https://docs.rs/refinery/latest/refinery/struct.Runner.html#method.set_grouped) to true.
99+
The rust crate intentionally ignores new migration files until your sourcecode is rebuild. This prevents accidental migrations and altering the database schema without any code changes. We can also bake the migrations into the binary, so no additional files are needed when deployed.
99100

100101
### Rollback
101102

examples/src/main.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use barrel::backend::Sqlite as Sql;
21
use log::info;
32
use refinery::Migration;
43
use rusqlite::Connection;

refinery/Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[package]
22
name = "refinery"
33
version = "0.8.14"
4+
version = "0.8.16"
45
rust-version = "1.83"
56
authors = ["Katharina Fey <[email protected]>", "João Oliveira <[email protected]>"]
67
license = "MIT"
@@ -27,8 +28,8 @@ toml = ["refinery-core/toml"]
2728
enums = ["refinery-macros/enums"]
2829

2930
[dependencies]
30-
refinery-core = { version = "0.8.14", path = "../refinery_core" }
31-
refinery-macros = { version = "0.8.14", path = "../refinery_macros" }
31+
refinery-core = { version = "0.8.16", path = "../refinery_core" }
32+
refinery-macros = { version = "0.8.16", path = "../refinery_macros" }
3233

3334
[dev-dependencies]
3435
barrel = { git = "https://github.com/jxs/barrel", features = ["sqlite3", "pg", "mysql", "mssql"] }

refinery/tests/mysql_async.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ mod mysql_async {
9494
.await
9595
.unwrap();
9696

97-
conn.query(&format!(
97+
conn.query(format!(
9898
"SELECT table_name FROM information_schema.tables WHERE table_name='{}'",
9999
DEFAULT_TABLE_NAME
100100
))
@@ -122,7 +122,7 @@ mod mysql_async {
122122
.unwrap();
123123

124124
let result = conn
125-
.query(&format!(
125+
.query(format!(
126126
"SELECT table_name FROM information_schema.tables WHERE table_name='{}'",
127127
DEFAULT_TABLE_NAME
128128
))

refinery/tests/postgres.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@ mod postgres {
6767
}
6868

6969
fn prep_database() {
70-
let uri = db_uri();
71-
7270
let mut client = Client::connect(&db_uri(), NoTls).unwrap();
7371

7472
client

refinery_cli/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "refinery_cli"
3-
version = "0.8.14"
3+
version = "0.8.16"
44
authors = ["Katharina Fey <[email protected]>", "João Oliveira <[email protected]>"]
55
license = "MIT OR Apache-2.0"
66
description = "Provides the CLI for the Refinery crate"
@@ -23,7 +23,7 @@ sqlite-bundled = ["sqlite", "refinery-core/rusqlite-bundled"]
2323
mssql = ["refinery-core/tiberius-config", "tokio"]
2424

2525
[dependencies]
26-
refinery-core = { version = "0.8.14", path = "../refinery_core", default-features = false, features = ["toml"] }
26+
refinery-core = { version = "0.8.16", path = "../refinery_core", default-features = false, features = ["toml"] }
2727
clap = { version = "4", features = ["derive"] }
2828
human-panic = "2"
2929
toml = "0.8"

refinery_core/Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "refinery-core"
3-
version = "0.8.14"
3+
version = "0.8.16"
44
authors = ["Katharina Fey <[email protected]>", "João Oliveira <[email protected]>"]
55
description = "This crate should not be used directly, it is internally related to Refinery"
66
license = "MIT OR Apache-2.0"
@@ -24,16 +24,16 @@ cfg-if = "1.0"
2424
log = "0.4"
2525
regex = "1"
2626
siphasher = "1.0"
27-
thiserror = "1"
27+
thiserror = "2"
2828
url = "2.0"
2929
walkdir = "2.3.1"
3030

3131
# allow multiple versions of the same dependency if API is similar
32-
rusqlite = { version = ">= 0.23, <= 0.32", optional = true }
32+
rusqlite = { version = ">= 0.23, <= 0.34", optional = true }
3333
postgres = { version = ">=0.17, <= 0.19", optional = true }
3434
tokio-postgres = { version = ">= 0.5, <= 0.7", optional = true }
35-
mysql = { version = ">= 21.0.0, <= 25", optional = true, default-features = false, features = ["minimal"] }
36-
mysql_async = { version = ">= 0.28, <= 0.34", optional = true, default-features = false, features = ["minimal"] }
35+
mysql = { version = ">= 21.0.0, <= 26", optional = true, default-features = false, features = ["minimal"] }
36+
mysql_async = { version = ">= 0.28, <= 0.35", optional = true, default-features = false, features = ["minimal"] }
3737
tiberius = { version = ">= 0.7, <= 0.12", optional = true, default-features = false }
3838
tokio = { version = "1.0", optional = true }
3939
futures = { version = "0.3.16", optional = true, features = ["async-await"] }

refinery_core/src/drivers/config.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@ use std::convert::Infallible;
1818
impl Transaction for Config {
1919
type Error = Infallible;
2020

21-
fn execute<'a, T: Iterator<Item = &'a str>>(
22-
&mut self,
23-
_queries: T,
24-
) -> Result<usize, Self::Error> {
21+
fn execute(&mut self, _queries: &[&str]) -> Result<usize, Self::Error> {
2522
Ok(0)
2623
}
2724
}
@@ -36,10 +33,7 @@ impl Query<Vec<Migration>> for Config {
3633
impl AsyncTransaction for Config {
3734
type Error = Infallible;
3835

39-
async fn execute<'a, T: Iterator<Item = &'a str> + Send>(
40-
&mut self,
41-
_queries: T,
42-
) -> Result<usize, Self::Error> {
36+
async fn execute(&mut self, _queries: &[&str]) -> Result<usize, Self::Error> {
4337
Ok(0)
4438
}
4539
}

refinery_core/src/drivers/mysql.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,10 @@ fn query_applied_migrations(
4343
impl Transaction for Conn {
4444
type Error = MError;
4545

46-
fn execute<'a, T: Iterator<Item = &'a str>>(
47-
&mut self,
48-
queries: T,
49-
) -> Result<usize, Self::Error> {
46+
fn execute(&mut self, queries: &[&str]) -> Result<usize, Self::Error> {
5047
let mut transaction = self.start_transaction(get_tx_opts())?;
5148
let mut count = 0;
52-
for query in queries {
49+
for query in queries.iter() {
5350
transaction.query_iter(query)?;
5451
count += 1;
5552
}
@@ -61,14 +58,11 @@ impl Transaction for Conn {
6158
impl Transaction for PooledConn {
6259
type Error = MError;
6360

64-
fn execute<'a, T: Iterator<Item = &'a str>>(
65-
&mut self,
66-
queries: T,
67-
) -> Result<usize, Self::Error> {
61+
fn execute(&mut self, queries: &[&str]) -> Result<usize, Self::Error> {
6862
let mut transaction = self.start_transaction(get_tx_opts())?;
6963
let mut count = 0;
7064

71-
for query in queries {
65+
for query in queries.iter() {
7266
transaction.query_iter(query)?;
7367
count += 1;
7468
}

refinery_core/src/drivers/mysql_async.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,15 @@ async fn query_applied_migrations<'a>(
3939
impl AsyncTransaction for Pool {
4040
type Error = MError;
4141

42-
async fn execute<'a, T: Iterator<Item = &'a str> + Send>(
43-
&mut self,
44-
queries: T,
45-
) -> Result<usize, Self::Error> {
42+
async fn execute(&mut self, queries: &[&str]) -> Result<usize, Self::Error> {
4643
let mut conn = self.get_conn().await?;
4744
let mut options = TxOpts::new();
4845
options.with_isolation_level(Some(IsolationLevel::ReadCommitted));
4946

5047
let mut transaction = conn.start_transaction(options).await?;
5148
let mut count = 0;
5249
for query in queries {
53-
transaction.query_drop(query).await?;
50+
transaction.query_drop(*query).await?;
5451
count += 1;
5552
}
5653
transaction.commit().await?;

refinery_core/src/drivers/postgres.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,10 @@ fn query_applied_migrations(
3333
impl Transaction for PgClient {
3434
type Error = PgError;
3535

36-
fn execute<'a, T: Iterator<Item = &'a str>>(
37-
&mut self,
38-
queries: T,
39-
) -> Result<usize, Self::Error> {
36+
fn execute(&mut self, queries: &[&str]) -> Result<usize, Self::Error> {
4037
let mut transaction = PgClient::transaction(self)?;
4138
let mut count = 0;
42-
for query in queries {
39+
for query in queries.iter() {
4340
PgTransaction::batch_execute(&mut transaction, query)?;
4441
count += 1;
4542
}

refinery_core/src/drivers/rusqlite.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,10 @@ fn query_applied_migrations(
3232

3333
impl Transaction for RqlConnection {
3434
type Error = RqlError;
35-
fn execute<'a, T: Iterator<Item = &'a str>>(
36-
&mut self,
37-
queries: T,
38-
) -> Result<usize, Self::Error> {
35+
fn execute(&mut self, queries: &[&str]) -> Result<usize, Self::Error> {
3936
let transaction = self.transaction()?;
4037
let mut count = 0;
41-
for query in queries {
38+
for query in queries.iter() {
4239
transaction.execute_batch(query)?;
4340
count += 1;
4441
}

refinery_core/src/drivers/tiberius.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,13 @@ where
4646
{
4747
type Error = Error;
4848

49-
async fn execute<'a, T: Iterator<Item = &'a str> + Send>(
50-
&mut self,
51-
queries: T,
52-
) -> Result<usize, Self::Error> {
49+
async fn execute(&mut self, queries: &[&str]) -> Result<usize, Self::Error> {
5350
// Tiberius doesn't support transactions, see https://github.com/prisma/tiberius/issues/28
5451
self.simple_query("BEGIN TRAN T1;").await?;
5552
let mut count = 0;
5653
for query in queries {
5754
// Drop the returning `QueryStream<'a>` to avoid compiler complaning regarding lifetimes
58-
if let Err(err) = self.simple_query(query).await.map(drop) {
55+
if let Err(err) = self.simple_query(*query).await.map(drop) {
5956
if let Err(err) = self.simple_query("ROLLBACK TRAN T1").await {
6057
log::error!("could not ROLLBACK transaction, {}", err);
6158
}

refinery_core/src/drivers/tokio_postgres.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,7 @@ async fn query_applied_migrations(
3535
impl AsyncTransaction for Client {
3636
type Error = PgError;
3737

38-
async fn execute<'a, T: Iterator<Item = &'a str> + Send>(
39-
&mut self,
40-
queries: T,
41-
) -> Result<usize, Self::Error> {
38+
async fn execute(&mut self, queries: &[&str]) -> Result<usize, Self::Error> {
4239
let transaction = self.transaction().await?;
4340
let mut count = 0;
4441
for query in queries {

refinery_core/src/runner.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ pub struct Report {
204204

205205
impl Report {
206206
/// Instantiate a new Report
207-
pub(crate) fn new(applied_migrations: Vec<Migration>) -> Report {
207+
pub fn new(applied_migrations: Vec<Migration>) -> Report {
208208
Report { applied_migrations }
209209
}
210210

0 commit comments

Comments
 (0)