[][src]Crate schemer_rusqlite

An adapter enabling use of the schemer schema migration library with SQLite3.

Examples:

extern crate rusqlite;
#[macro_use]
extern crate schemer;
extern crate schemer_rusqlite;
extern crate uuid;

use std::collections::HashSet;

use rusqlite::{Connection, Transaction};
use schemer::{Migration, Migrator};
use schemer_rusqlite::{RusqliteAdapter, RusqliteAdapterError, RusqliteMigration};
use uuid::Uuid;

struct MyExampleMigration;
migration!(
    MyExampleMigration,
    "4885e8ab-dafa-4d76-a565-2dee8b04ef60",
    [],
    "An example migration without dependencies.");

impl RusqliteMigration for MyExampleMigration {
    fn up(&self, transaction: &Transaction) -> Result<(), RusqliteAdapterError> {
        transaction.execute("CREATE TABLE my_example (id integer PRIMARY KEY);", &[])?;
        Ok(())
    }

    fn down(&self, transaction: &Transaction) -> Result<(), RusqliteAdapterError> {
        transaction.execute("DROP TABLE my_example;", &[])?;
        Ok(())
    }
}

fn main() {
    let mut conn = Connection::open_in_memory().unwrap();
    let adapter = RusqliteAdapter::new(&mut conn, None);

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

    let migration = Box::new(MyExampleMigration {});
    migrator.register(migration);
    migrator.up(None);
}

Structs

RusqliteAdapter

Adapter between schemer and SQLite.

Traits

RusqliteMigration

SQlite-specific trait for schema migrations.

Type Definitions

RusqliteAdapterError