Skip to content

Latest commit

 

History

History
48 lines (40 loc) · 2.02 KB

README.md

File metadata and controls

48 lines (40 loc) · 2.02 KB

drifter-project-m36

Haskell Programming Language BSD3 License Hackage Build status Hackage-Deps

Drifter migration backend for the amazing Project: M36 database.

This package is maintained by Grafted-In.

Example

import qualified Data.Map.Strict as Map
import Data.Text (Text)
import Drifter.ProjectM36
import Drifter.ProjectM36.RelSchema
import ProjectM36.Atomable (toAtomType)
import ProjectM36.Client.Simple

main :: IO ()
main = do
  dbConn <- ... -- use ProjectM36.Client.Simple
  runMigrations dbConn schemaChanges

schemaChanges :: [Change PM36Migration]
schemaChanges = [
    Change{
      changeName         = ChangeName "make-relvar-purchases",
      changeDescription  = Nothing,
      changeDependencies = [],
      changeMethod       = MigrationStep (
        defineRelSchema $ RelSchema "purchases" $ Map.fromList [
            ("purchaseUuid",        (TextAtomType,                   Unique)),
            ("purchasePersonName",  (TextAtomType,                   NonUnique)),
            ("purchasePersonEmail", (TextAtomType,                   NonUnique)),
            ("purchaseStates",      (toAtomType $ undefined @[Text], NonUnique)),
            ("purchasePriceCents",  (IntAtomType,                    NonUnique)),
            ("purchaseDownloads",   (IntAtomType,                    NonUnique)),
            ("purchaseTimestamp",   (DateTimeAtomType,               NonUnique))
          ]
      )
    }
  ]