packages feed

dag-migrations-0.1.0.0 / src / Database / DagMigrations / Error.hs

-- | The errors that validation, planning, and running report. A project-- imports "Database.DagMigrations", which re-exports everything that this-- module exports.module Database.DagMigrations.Error  ( ValidationError (..),    PlanError (..),    FingerprintMismatch (..),    AcceptError (..),    Direction (..),    RunError (..),  )whereimport Data.List.NonEmpty (NonEmpty)import Data.Text (Text)import Database.DagMigrations.Migration (Fingerprint)-- | A problem in a registry of migrations.data ValidationError i  = -- | More than one migration has this identifier.    DuplicateIdentifier i  | -- | The first migration depends on the second identifier, which no    -- migration has.    UnknownDependency i i  | -- | A cycle of dependencies: each identifier depends on the next, and    -- the last depends on the first.    DependencyCycle (NonEmpty i)  deriving (Eq, Ord, Show)-- | A reason why no plan exists for a database and a target.data PlanError i  = -- | No registered migration has the target identifier.    UnknownTarget i  | -- | A run applied this identifier to the database, and no registered    -- migration has it: the database is newer than the code.    UnregisteredApplied i  | -- | The applied set holds the first migration and not the second,    -- which the first depends on.    InconsistentApplied i i  | -- | Reaching the target requires reverting this migration, and it has    -- no down action.    Irreversible i  deriving (Eq, Ord, Show)-- | An applied migration whose recorded fingerprint differs from its-- registered one. The fields are the identifier, the recorded fingerprint,-- and the registered fingerprint.data FingerprintMismatch i  = FingerprintMismatch i (Maybe Fingerprint) (Maybe Fingerprint)  deriving (Eq, Ord, Show)-- | A reason why 'Database.DagMigrations.Run.acceptFingerprints' cannot-- accept the registered fingerprint of a named migration.data AcceptError i  = -- | No registered migration has this identifier.    NotRegistered i  | -- | The migration is registered, and the adapter does not report it as    -- applied.    NotApplied i  deriving (Eq, Ord, Show)-- | Whether a run applies migrations or reverts them.data Direction  = -- | The run applies migrations.    Up  | -- | The run reverts migrations.    Down  deriving (Eq, Ord, Show, Bounded, Enum)-- | A failed run. @e@ is the type of the errors that the project's-- interpreter reports, and @ae@ the type of the adapter's errors.data RunError i e ae  = -- | No plan exists, for the reasons listed.    PlanFailed (NonEmpty (PlanError i))  | -- | Under 'Database.DagMigrations.Run.MismatchIsError', the run found    -- these mismatches, and changed nothing.    FingerprintsMismatched (NonEmpty (FingerprintMismatch i))  | -- | The adapter read this text from the tracking table, and the    -- identifier codec does not decode it.    UndecodableIdentifier Text  | -- | The adapter read this text from the tracking table, and the    -- identifier codec decodes it to this identifier, whose encoding is    -- different text. The run writes rows by the encoding, so it could not    -- update or remove this row.    NonCanonicalIdentifier Text i  | -- | 'Database.DagMigrations.Run.acceptFingerprints' cannot accept these    -- names, and changed nothing.    CannotAccept (NonEmpty (AcceptError i))  | -- | The migration failed in the given direction, with the adapter's    -- error or the interpreter's.    MigrationFailed i Direction (Either ae e)  | -- | The adapter failed outside any migration.    AdapterFailed ae  deriving (Eq, Show)