Skip to content

3noch/drifter-project-m36

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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))
          ]
      )
    }
  ]

Releases

No releases published

Packages

No packages published