Skip to content

Commit 526b333

Browse files
committed
Fixing conflict with main
2 parents 3e96c0c + b7c8d44 commit 526b333

35 files changed

+517
-161
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ jobs:
6161
- run: rustup self update
6262
- run: cd refinery_core && cargo test --all-features -- --test-threads 1
6363
- run: cd refinery && cargo build --all-features
64-
- run: cd refinery_macros && cargo test --features=enums
64+
- run: cd refinery_macros && cargo test --all-features
6565
- run: cd refinery_cli && cargo test
6666

6767
test-sqlite:
@@ -98,6 +98,7 @@ jobs:
9898
toolchain: ${{ matrix.rust }}
9999
- run: cargo install --path ./refinery_cli --no-default-features --features=postgresql
100100
- run: cd refinery && cargo test --features postgres --test postgres -- --test-threads 1
101+
- run: cd refinery && cargo test --features postgres,int8-versions --test postgres -- --test-threads 1
101102

102103
test-tokio-postgres:
103104
name: Test tokio-postgres

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ If you are using a driver that is not yet supported, namely [`SQLx`](https://git
3535
- Migrations, both .sql files and Rust modules must be named in the format `[U|V]{1}__{2}.sql` or `[U|V]{1}__{2}.rs`, where `{1}` represents the migration version and `{2}` the name.
3636
- Migrations can be run either by embedding them in your Rust code with `embed_migrations` macro, or via [refinery_cli].
3737

38+
NOTE:
39+
40+
- By default, migration version numbers are restricted to `i32` (signed, 32-bit integers).
41+
- If you enable the `int8-versions` feature, this restriction is lifted to being able to use `i64`s for your migration version numbers.
42+
Bear in mind that this feature must be enabled *before* you start using refinery on a given database.
43+
Migrating an existing database's `refinery_schema_history` table to use `int8` versions **will break the checksums on all previously-applied migrations**.
44+
3845
### Example: Library
3946
```rust,no_run
4047
use rusqlite::Connection;
@@ -53,15 +60,10 @@ fn main() {
5360
For more library examples, refer to the [`examples`](https://github.com/rust-db/refinery/tree/main/examples).
5461
### Example: CLI
5562

56-
NOTE:
57-
58-
- Contiguous (adjacent) migration version numbers are restricted to `u32` (unsigned, 32-bit integers).
59-
- Non-contiguous (not adjacent) migration version numbers are restricted to `u32` (unsigned, 32-bit integers).
60-
6163
```bash
6264
export DATABASE_URL="postgres://postgres:secret@localhost:5432/your-db"
6365
pushd migrations
64-
# Runs ./src/V1__*.rs or ./src/V1__*.sql
66+
# Runs ./src/V1__*.rs or ./src/V1__*.sql
6567
refinery migrate -e DATABASE_URL -p ./src -t 1
6668
popd
6769
```

examples/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ edition = "2021"
1010

1111
[features]
1212
enums = ["refinery/enums"]
13+
int8-versions = ["refinery/int8-versions"]
1314

1415
[dependencies]
1516
refinery = { path = "../refinery", features = ["rusqlite"] }

refinery/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ tiberius-config = ["refinery-core/tiberius", "refinery-core/tiberius-config"]
2525
serde = ["refinery-core/serde"]
2626
toml = ["refinery-core/toml"]
2727
enums = ["refinery-macros/enums"]
28+
int8-versions = ["refinery-core/int8-versions", "refinery-macros/int8-versions"]
2829

2930
[dependencies]
3031
refinery-core = { version = "0.8.16", path = "../refinery_core" }

refinery/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ for more examples refer to the [examples](https://github.com/rust-db/refinery/tr
3333

3434
pub use refinery_core::config;
3535
pub use refinery_core::{
36-
error, load_sql_migrations, Error, Migration, MigrationFlags, Report, Runner, Target,
36+
error, load_sql_migrations, Error, Migration, MigrationFlags, Report, Runner, SchemaVersion,
37+
Target,
3738
};
3839
#[doc(hidden)]
3940
pub use refinery_core::{AsyncMigrate, Migrate};
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
use barrel::{types, Migration};
2+
3+
use crate::Sql;
4+
5+
pub fn migration() -> String {
6+
let mut m = Migration::new();
7+
8+
m.create_table("persons", |t| {
9+
t.add_column("id", types::primary());
10+
t.add_column("name", types::varchar(255));
11+
t.add_column("city", types::varchar(255));
12+
});
13+
14+
m.make::<Sql>()
15+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CREATE TABLE cars (
2+
id int,
3+
name varchar(255)
4+
);
5+
CREATE TABLE motos (
6+
id int,
7+
name varchar(255)
8+
);
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER TABLE cars
2+
ADD brand varchar(255);
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
use barrel::{types, Migration};
2+
3+
use crate::Sql;
4+
5+
pub fn migration() -> String {
6+
let mut m = Migration::new();
7+
8+
m.change_table("motos", |t| {
9+
t.add_column("brand", types::varchar(255).nullable(true));
10+
});
11+
12+
m.make::<Sql>()
13+
}

refinery/tests/mysql.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,7 @@ mod mysql {
133133
let mut conn = pool.get_conn().unwrap();
134134
embedded::migrations::runner().run(&mut conn).unwrap();
135135
for row in format!(
136-
"SELECT table_name FROM information_schema.tables WHERE table_name='{}'",
137-
DEFAULT_TABLE_NAME
136+
"SELECT table_name FROM information_schema.tables WHERE table_name='{DEFAULT_TABLE_NAME}'",
138137
)
139138
.run(conn)
140139
.unwrap()
@@ -158,8 +157,7 @@ mod mysql {
158157
.unwrap();
159158

160159
for row in format!(
161-
"SELECT table_name FROM information_schema.tables WHERE table_name='{}'",
162-
DEFAULT_TABLE_NAME
160+
"SELECT table_name FROM information_schema.tables WHERE table_name='{DEFAULT_TABLE_NAME}'",
163161
)
164162
.run(conn)
165163
.unwrap()

0 commit comments

Comments
 (0)