cigogne

Functions

pub fn apply_migration(
  connection: Connection,
  migration: Migration,
) -> Result(Nil, MigrateError)

Apply a migration to the database.
This function does not create a schema file.

pub fn apply_next_migration(
  connection: Connection,
) -> Result(Nil, MigrateError)

Apply the next migration that wasn’t applied yet.
The migrations are acquired from **/migrations/*.sql files.
This function does not create a schema file.

pub fn execute_migrations_to(
  connection: Connection,
  migration_number: Int,
) -> Result(Nil, MigrateError)

Apply or roll back migrations until we reach the migration corresponding to the provided number.
The migrations are acquired from **/migrations/*.sql files.
This function does not create a schema file.

pub fn execute_migrations_to_last(
  connection: Connection,
) -> Result(Nil, MigrateError)

Apply migrations until we reach the last defined migration.
The migrations are acquired from **/migrations/*.sql files.
This function does not create a schema file.

pub fn get_migrations() -> Result(List(Migration), MigrateError)

Get all defined migrations in your project.
Migration files are searched in /migrations folders.

pub fn get_schema(url: String) -> Result(String, MigrateError)

Get details about the schema of the database at the provided url.

pub fn main() -> Result(Nil, Nil)
pub fn migrate_down() -> Result(Nil, MigrateError)

Roll back the last applied migration.
This function will get the database url from the DATABASE_URL environment variable.
The migrations are then acquired from **/migrations/*.sql files.
If successful, it will also create a file and write details of the new schema in it.

pub fn migrate_to(
  migration_number: Int,
) -> Result(Nil, MigrateError)

Apply or roll back migrations until we reach the migration corresponding to the provided number.
This function will get the database url from the DATABASE_URL environment variable.
The migrations are then acquired from **/migrations/*.sql files.
If successful, it will also create a file and write details of the new schema in it.

pub fn migrate_to_last() -> Result(Nil, MigrateError)

Apply migrations until we reach the last defined migration.
This function will get the database url from the DATABASE_URL environment variable.
The migrations are then acquired from **/migrations/*.sql files.
If successful, it will also create a file and write details of the new schema in it.

pub fn migrate_up() -> Result(Nil, MigrateError)

Apply the next migration that wasn’t applied yet.
This function will get the database url from the DATABASE_URL environment variable.
The migrations are then acquired from **/migrations/*.sql files.
If successful, it will also create a file and write details of the new schema in it.

pub fn print_error(error: MigrateError) -> Nil

Print a MigrateError to the standard error stream.

pub fn roll_back_migration(
  connection: Connection,
  migration: Migration,
) -> Result(Nil, MigrateError)

Roll back a migration from the database.
This function does not create a schema file.

pub fn roll_back_previous_migration(
  connection: Connection,
) -> Result(Nil, MigrateError)

Roll back the last applied migration.
The migrations are acquired from **/migrations/*.sql files.
This function does not create a schema file.

pub fn update_schema_file(
  url: String,
) -> Result(Nil, MigrateError)

Create or update a schema file with details of the schema of the database at the provided url. The schema file is created at ./sql.schema.

Search Document