Skip to content

Commit 641a509

Browse files
committed
Merge branch 'main' of github.com:rust-db/refinery into int8-versions
2 parents 56b81b1 + 967f98e commit 641a509

File tree

25 files changed

+346
-162
lines changed

25 files changed

+346
-162
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ jobs:
6262
- run: cd refinery_core && cargo test --all-features -- --test-threads 1
6363
- run: cd refinery && cargo build --all-features
6464
- run: cd refinery_macros && cargo test --all-features
65-
- run: cd refinery_macros && cargo test --features enums enum_fn
6665
- run: cd refinery_cli && cargo test
6766

6867
test-sqlite:
@@ -176,16 +175,12 @@ jobs:
176175
strategy:
177176
matrix:
178177
rust: ${{ fromJson(needs.set-rust-versions.outputs.versions) }}
179-
services:
180-
mssql:
181-
image: mcr.microsoft.com/mssql/server:2017-latest
182-
ports:
183-
- 1433:1433
184-
env:
185-
ACCEPT_EULA: yes
186-
SA_PASSWORD: Passw0rd
187178
steps:
188179
- uses: actions/checkout@v2
180+
- uses: potatoqualitee/mssqlsuite@v1.8
181+
with:
182+
install: sqlengine, sqlpackage
183+
sa-password: Passw0rd
189184
- uses: actions-rs/toolchain@v1
190185
with:
191186
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: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,13 @@ let client = conn.deref_mut().deref_mut();
7676
let report = embedded::migrations::runner().run_async(client).await?;
7777
```
7878

79+
### Example: bb8
80+
81+
```rust
82+
let mut client = pool.dedicated_connection().await?;
83+
let report = embedded::migrations::runner().run_async(&mut client).await?;
84+
```
85+
7986
### Non-contiguous VS Contiguous migrations
8087

8188
Depending on how your project/team has been structured will define whether you want to use contiguous (adjacent) migrations `V{1}__{2}.[sql|rs]` or non-contiguous (not adjacent) migrations `U{1}__{2}.[sql|rs]`.
@@ -91,6 +98,7 @@ This would stop developer 1's migration from ever running if you were using cont
9198

9299
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.\
93100
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.
101+
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.
94102

95103
### Rollback
96104

examples/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ int8-versions = ["refinery/int8-versions"]
1414

1515
[dependencies]
1616
refinery = { path = "../refinery", features = ["rusqlite"] }
17-
rusqlite = "0.31"
17+
rusqlite = "0.37"
1818
barrel = { version = "0.7", features = ["sqlite3"] }
1919
log = "0.4"
2020
env_logger = "0.11"

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: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "refinery"
3-
version = "0.8.14"
4-
rust-version = "1.75"
3+
version = "0.8.16"
4+
rust-version = "1.83"
55
authors = ["Katharina Fey <kookie@spacekookie.de>", "João Oliveira <hello@jxs.pt>"]
66
license = "MIT"
77
description = "Powerful SQL migration toolkit for Rust"
@@ -28,8 +28,8 @@ enums = ["refinery-macros/enums"]
2828
int8-versions = ["refinery-core/int8-versions", "refinery-macros/int8-versions"]
2929

3030
[dependencies]
31-
refinery-core = { version = "0.8.14", path = "../refinery_core" }
32-
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" }
3333

3434
[dev-dependencies]
3535
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: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use barrel::backend::Pg as Sql;
44
mod postgres {
55
use assert_cmd::prelude::*;
66
use predicates::str::contains;
7+
use refinery::config::ConfigDbType;
78
use refinery::{
89
config::Config, embed_migrations, error::Kind, Migrate, Migration, Runner, Target,
910
};
@@ -73,8 +74,6 @@ mod postgres {
7374
}
7475

7576
fn prep_database() {
76-
let uri = db_uri();
77-
7877
let mut client = Client::connect(&db_uri(), NoTls).unwrap();
7978

8079
client
@@ -774,4 +773,38 @@ mod postgres {
774773
.stdout(contains("applying migration: V3__add_brand_to_cars_table"));
775774
})
776775
}
776+
777+
#[test]
778+
fn migrates_with_tls_enabled() {
779+
run_test(|| {
780+
let mut config = Config::new(ConfigDbType::Postgres)
781+
.set_db_name("postgres")
782+
.set_db_user("postgres")
783+
.set_db_host("localhost")
784+
.set_db_port("5432")
785+
.set_use_tls(true);
786+
787+
let migrations = get_migrations();
788+
let runner = Runner::new(&migrations)
789+
.set_grouped(false)
790+
.set_abort_divergent(true)
791+
.set_abort_missing(true);
792+
793+
let report = runner.run(&mut config).unwrap();
794+
795+
let applied_migrations = report.applied_migrations();
796+
assert_eq!(5, applied_migrations.len());
797+
798+
let last_migration = runner
799+
.get_last_applied_migration(&mut config)
800+
.unwrap()
801+
.unwrap();
802+
803+
assert_eq!(5, last_migration.version());
804+
assert_eq!(migrations[4].name(), last_migration.name());
805+
assert_eq!(migrations[4].checksum(), last_migration.checksum());
806+
807+
assert!(config.use_tls());
808+
});
809+
}
777810
}

refinery/tests/tokio_postgres.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ mod tokio_postgres {
1212
use refinery_core::tokio_postgres;
1313
use refinery_core::tokio_postgres::NoTls;
1414
use std::panic::AssertUnwindSafe;
15+
use std::str::FromStr;
1516
use time::OffsetDateTime;
1617

1718
const DEFAULT_TABLE_NAME: &str = "refinery_schema_history";
@@ -953,4 +954,37 @@ mod tokio_postgres {
953954
})
954955
.await;
955956
}
957+
958+
#[tokio::test]
959+
async fn migrates_with_tls_enabled() {
960+
run_test(async {
961+
let mut config =
962+
Config::from_str("postgres://postgres@localhost:5432/postgres?sslmode=require")
963+
.unwrap();
964+
965+
let migrations = get_migrations();
966+
let runner = Runner::new(&migrations)
967+
.set_grouped(false)
968+
.set_abort_divergent(true)
969+
.set_abort_missing(true);
970+
971+
let report = runner.run_async(&mut config).await.unwrap();
972+
973+
let applied_migrations = report.applied_migrations();
974+
assert_eq!(5, applied_migrations.len());
975+
976+
let last_migration = runner
977+
.get_last_applied_migration_async(&mut config)
978+
.await
979+
.unwrap()
980+
.unwrap();
981+
982+
assert_eq!(5, last_migration.version());
983+
assert_eq!(migrations[4].name(), last_migration.name());
984+
assert_eq!(migrations[4].checksum(), last_migration.checksum());
985+
986+
assert!(config.use_tls());
987+
})
988+
.await;
989+
}
956990
}

0 commit comments

Comments
 (0)