Skip to content

Commit d7618a5

Browse files
committed
Update README
1 parent 21140be commit d7618a5

File tree

1 file changed

+10
-17
lines changed

1 file changed

+10
-17
lines changed

Diff for: README.md

+10-17
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# PostgreSQL for Schemamama
22

3-
A PostgreSQL adapter for the lightweight database migration system
4-
[Schemamama](https://github.com/SkylerLipthay/schemamama). Depends on the
5-
`postgres` crate.
3+
A PostgreSQL adapter for the lightweight database migration system [Schemamama](https://github.com/SkylerLipthay/schemamama). Depends on the `postgres` crate.
64

75
## Installation
86

@@ -11,8 +9,8 @@ If you're using Cargo, just add Schemamama to your `Cargo.toml`:
119
```toml
1210
[dependencies]
1311
schemamama = "0.3"
14-
schemamama_postgres = "0.2"
15-
postgres = "0.15"
12+
schemamama_postgres = "0.3"
13+
postgres = "0.17"
1614
```
1715

1816
## Usage
@@ -25,6 +23,7 @@ extern crate schemamama;
2523
extern crate schemamama_postgres;
2624
extern crate postgres;
2725

26+
use postgres::{Client, Transaction, error::Error as PostgresError, NoTls};
2827
use schemamama::{Migration, Migrator};
2928
use schemamama_postgres::{PostgresAdapter, PostgresMigration};
3029

@@ -34,11 +33,11 @@ struct CreateUsers;
3433
migration!(CreateUsers, 1, "create users table");
3534

3635
impl PostgresMigration for CreateUsers {
37-
fn up(&self, transaction: &postgres::Transaction) -> Result<(), PostgresError> {
36+
fn up(&self, transaction: &mut Transaction) -> Result<(), PostgresError> {
3837
transaction.execute("CREATE TABLE users (id BIGINT PRIMARY KEY);", &[]).map(|_| ())
3938
}
4039

41-
fn down(&self, transaction: &postgres::Transaction) -> Result<(), PostgresError> {
40+
fn down(&self, transaction: &mut Transaction) -> Result<(), PostgresError> {
4241
transaction.execute("DROP TABLE users;", &[]).map(|_| ())
4342
}
4443
}
@@ -55,11 +54,11 @@ Then, run the migrations!
5554

5655
```rust
5756
let url = "postgres://postgres@localhost";
58-
let connection = postgres::Connection::connect(url, &SslMode::None).unwrap();
59-
let adapter = PostgresAdapter::new(&connection);
57+
let client = Client::connect(url, NoTls).unwrap();
58+
let adapter = PostgresAdapter::new(&mut client);
6059
// Create the metadata tables necessary for tracking migrations. This is safe to call more than
6160
// once (`CREATE TABLE IF NOT EXISTS schemamama` is used internally):
62-
adapter.setup_schema();
61+
adapter.setup_schema().unwrap();
6362

6463
let mut migrator = Migrator::new(adapter);
6564

@@ -77,10 +76,4 @@ assert_eq!(migrator.current_version(), None);
7776

7877
## Testing
7978

80-
To run `cargo test`, you must have PostgreSQL running locally with a user role
81-
named `postgres` with login access to a database named `postgres`. All tests
82-
will work in the `pg_temp` schema, so the database will not be modified.
83-
84-
## To-do
85-
86-
* Make metadata table name configurable (currently locked in to `schemamama`).
79+
To run `cargo test`, you must have PostgreSQL running locally with a user role named `postgres` with login access to a database named `postgres`. All tests will work in the `pg_temp` schema, so the database will not be modified.

0 commit comments

Comments
 (0)