pub struct FileBasedMigrations { /* private fields */ }
Expand description

A migration source based on a migration directory in the file system

A valid migration directroy contains a sub folder per migration. Each migration folder contains a up.sql file containing the migration itself and a down.sql file containing the nessesary SQL to revert the migration. Additionaly each folder can contain a metadata.toml file controling how the individual migration should be handled by the migration harness.

To embed an existing migration folder into the final binary see embed_migrations!.

Example

- 20151219180527_create_users
    - up.sql
    - down.sql
- 20160107082941_create_posts
    - up.sql
    - down.sql
-- 20151219180527_create_users/up.sql
CREATE TABLE users (
  id SERIAL PRIMARY KEY,
  name VARCHAR NOT NULL,
  hair_color VARCHAR
);
-- 20151219180527_create_users/down.sql
DROP TABLE users;
-- 20160107082941_create_posts/up.sql
CREATE TABLE posts (
  id SERIAL PRIMARY KEY,
  user_id INTEGER NOT NULL,
  title VARCHAR NOT NULL,
  body TEXT
);
-- 20160107082941_create_posts/down.sql
DROP TABLE posts;

run_in_transaction = true

Implementations

Create a new file based migration source based on a specific path

This methods fails if the path passed as argument is no valid migration directory

Create a new file based migration source by searching the migration diretcory

This method looks in the current and all parent directories for a folder named migrations

This method fails if no valid migration directory is found

Create a new file based migration source by searching a give path for the migration directory

This method looks in the passed directory and all parent directories for a folder named migrations

This method fails if no valid migration directory is found

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Get a list of migrations associated with this migration soucre. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Convert self to an expression for Diesel’s query builder. Read more

Convert &self to an expression for Diesel’s query builder. Read more

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.