docs.rs failed to build schemamama_postgres-0.0.6
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build:
schemamama_postgres-0.3.0
PostgreSQL for Schemamama
A PostgreSQL adapter for the lightweight database migration system
Schemamama. Depends on the
postgres
crate.
Installation
If you're using Cargo, just add Schemamama to your Cargo.toml
:
[]
= "*"
= "*"
= "0.8"
Usage
First, define some migrations:
extern crate schemamama;
extern crate schemamama_postgres;
extern crate postgres;
use ;
use ;
;
// Instead of using sequential numbers (1, 2, 3...), you may choose to use a collaborative
// versioning scheme, such as epoch timestamps.
migration!;
;
migration!;
Then, run the migrations!
let url = "postgres://postgres@localhost";
let connection = connect.unwrap;
let adapter = new;
// Create the metadata tables necessary for tracking migrations. This is safe to call more than
// once (`CREATE TABLE IF NOT EXISTS schemamama` is used internally):
adapter.setup_schema;
let mut migrator = new;
migrator.register;
migrator.register;
// Execute migrations up to and including version 2:
migrator.up;
assert_eq!;
// Reverse all migrations:
migrator.down;
assert_eq!;
Testing
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.
To-do
- Make metadata table name configurable (currently locked in to
schemamama
).