module Drifter
(
resolveDependencyOrder
, changeSequence
, migrate
, Drifter(..)
, ChangeName(..)
, Change(..)
, Description
, Method
, DBConnection
) where
import Data.List
import Drifter.Graph
import Drifter.Types
changeSequence :: [Change a] -> [Change a]
changeSequence [] = []
changeSequence (x:xs) = reverse $ snd $ foldl' go (x, [x]) xs
where
go :: (Change a, [Change a]) -> Change a -> (Change a, [Change a])
go (lastChange, xs') c =
let c' = c { changeDependencies = [changeName lastChange] }
in (c', c':xs')