relocant-1.0.0: A PostgreSQL migration CLI tool and library
Safe HaskellSafe-Inferred
LanguageHaskell2010

Relocant.DB

Description

This module manages PostgreSQL connections and relocant's DB schema.

Synopsis

Documentation

data Table Source #

relocant's migration table name.

Instances

Instances details
ToJSON Table Source # 
Instance details

Defined in Relocant.DB.Table

IsString Table Source # 
Instance details

Defined in Relocant.DB.Table

Methods

fromString :: String -> Table #

Show Table Source #

Return a String that can be fromStringed back to a Table.

Instance details

Defined in Relocant.DB.Table

Methods

showsPrec :: Int -> Table -> ShowS #

show :: Table -> String #

showList :: [Table] -> ShowS #

Eq Table Source # 
Instance details

Defined in Relocant.DB.Table

Methods

(==) :: Table -> Table -> Bool #

(/=) :: Table -> Table -> Bool #

ToField Table Source # 
Instance details

Defined in Relocant.DB.Table

Methods

toField :: Table -> Action #

defaultTable :: Table Source #

The default table name, which is "public.relocant_migration".

connect :: ConnectionString -> Table -> IO Connection Source #

Connect to the DB using the given ConnectionString and initialize the migrations table.

Note: If you get your Connection from elsewhere, remember to call init yourself.

init :: Table -> Connection -> IO () Source #

Initialize the migrations table.

withLock :: Table -> Connection -> IO a -> IO a Source #

Use pg_advisory_{lock,unlock} to restrict access to the migrations table. The given table is used to generate the lock's ID, so that in the unlikely case where you have multiple migrations tables in your database you can lock them separately.

withTryLock :: Table -> Connection -> (Bool -> IO a) -> IO a Source #

A non-blocking version of withLock. True is passed to the callback if the lock was successfully acquired, False otherwise.

lock :: Table -> Connection -> IO () Source #

Use pg_advisory_lock to lock the database, restricting access to the migrations table. The given table is used to generate the lock's ID, so that in the unlikely case where you have multiple migrations tables in your database you can lock them separately.

tryLock :: Table -> Connection -> IO Bool Source #

A non-blocking version of lock. Returns True if the lock was successfully acquired, False otherwise.

unlock :: Table -> Connection -> IO Bool Source #

Use pg_advisory_unlock to unlock the database.