migrant-core-0.1.0.1: Semi-automatic database schema migrations
Safe HaskellNone
LanguageHaskell2010

Database.Migrant

Synopsis

Documentation

class Driver d where Source #

A migrations driver abstracts over the database to run over and the associated migration mechanism.

Methods

withTransaction :: (d -> IO a) -> d -> IO a Source #

initMigrations :: d -> IO () Source #

Initialize the migrations system on the backend. This should generally involve creating a table of ordered migration names, e.g.: @@ CREATE TABLE IF NOT EXISTS _migrations (id SERIAL PRIMARY KEY, name TEXT); @@

  • *Note** that initMigrations should be idempotent, that is, executing it when the migrations system has already been initialized should be a no-op.

markUp :: MigrationName -> d -> IO () Source #

Mark a migration as "executed". Typically, this will INSERT a row into the migrations table.

markDown :: MigrationName -> d -> IO () Source #

Mark a migration as "not executed" / "rolled back". Typically, this will DELETE a row from the migrations table.

getMigrations :: d -> IO [MigrationName] Source #

Get the list of migrations applied to the backend, in the order they were applied.

data MigrationDirection Source #

Instances

Instances details
Bounded MigrationDirection Source # 
Instance details

Defined in Database.Migrant.Run

Enum MigrationDirection Source # 
Instance details

Defined in Database.Migrant.Run

Eq MigrationDirection Source # 
Instance details

Defined in Database.Migrant.Run

Ord MigrationDirection Source # 
Instance details

Defined in Database.Migrant.Run

Show MigrationDirection Source # 
Instance details

Defined in Database.Migrant.Run

migrate Source #

Arguments

:: Driver d 
=> [MigrationName]

Target situation

-> (MigrationName -> d -> IO ())

Factory for 'up' migration actions

-> (MigrationName -> d -> IO ())

Factory for 'down' migration actions

-> d 
-> IO () 

Safely (transactionally) infer and execute a migration.

plan :: Driver d => [MigrationName] -> d -> IO [(MigrationDirection, MigrationName)] Source #

Create a migration plan based on the current situation on the database, and the specified target.