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

Relocant.Script

Contents

Description

This module deals with migrations that haven't yet been applied.

Synopsis

Documentation

data Script Source #

A migration script. Most users would get them by running readScripts, but those wanting a more fine-grained control would use readScript.

Constructors

Script 

Fields

Instances

Instances details
ToJSON Script Source #

The content (as in actual bytes) is skipped.

Instance details

Defined in Relocant.Script

Show Script Source # 
Instance details

Defined in Relocant.Script

Eq Script Source # 
Instance details

Defined in Relocant.Script

Methods

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

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

HasField "bytes" Script ByteString Source # 
Instance details

Defined in Relocant.Script

readScripts :: FilePath -> IO [Script] Source #

Read migration Scripts from a directory. It only tries to read paths ending with the .sql extension and doesn't recurse into subdirectories.

Note: the directory must exist

readScript :: FilePath -> IO Script Source #

Read migration Scripts from a file. Useful when you need a more fine-grained control over which paths are read then what readScripts provides.

apply :: Script -> Connection -> IO Applied Source #

Run a Script against the database, get an Applied migration back if successful.

Note: You probably want to run this together with record in a single transaction.

markApplied :: Script -> IO Applied Source #

Get an Applied migration from a Script, without running it. This should not be normally used, but can be useful for fixing checksums after cosmetics updates of migration Scripts (such as adding comments, for example).

Extra

parseFilePath :: FilePath -> (ID, Name) Source #

Get XXX as the ID and XXX-YYYY as the Name from XXX-YYYY.sql

Basically, the longest alphanumeric prefix of the basename is the ID, and the basename is the Name.

readContent :: FilePath -> IO Content Source #

Get migration Script's content and its checksum.