schemamama_postgres 0.0.1

PostgreSQL adapter for the Schemamama migration system failed to build schemamama_postgres-0.0.1
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 builds.
If you believe this is' 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.


If you're using Cargo, just add Schemamama to your Cargo.toml:

schemamama = "*"
schemamama_postgres = "*"
postgres = "0.8"


First, define some migrations:

extern crate schemamama;
extern crate schemamama_postgres;
extern crate postgres;

// Needed to apply the `migration!` macro:
use schemamama::Migration;

struct CreateUsers;
// Instead of using sequential numbers (1, 2, 3...), you may instead choose to use a global
// versioning scheme, such as epoch timestamps.
migration!(CreateUsers, 1, "create users table");

impl PostgresMigration for CreateUsers {
    fn up(&self, transaction: &postgres::Transaction) {
        transaction.execute("CREATE TABLE users (id BIGINT PRIMARY KEY);", &[]).unwrap();

    fn down(&self, transaction: &postgres::Transaction) {
        transaction.execute("DROP TABLE users;", &[]).unwrap();

struct CreateProducts;
migration!(CreateProducts, 2, "create products table");

impl PostgresMigration for CreateProducts {
    // ...

Then, run the migrations!

let url = "postgres://postgres@localhost";
let connection = postgres::Connection::connect(url, &SslMode::None).unwrap();
let adapter = PostgresAdapter::new(&connection);
// 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):

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


// Execute migrations up to and including version 2:
assert_eq!(migrator.current_version(), Some(2));

// Reverse all migrations:
assert_eq!(migrator.current_version(), None);


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.


  • Make metadata table name configurable (currently locked in to schemamama).