Skip to content

*** Exception: user error (Pattern match failure in do expression at Database/PostgreSQL/Migrations.hs:377:3-16) #29

@chrissound

Description

@chrissound
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DeriveGeneric #-}

module Main where

import Database.PostgreSQL.ORM
import Data.Text
import GHC.Generics
import Database.PostgreSQL.Simple
import Database.PostgreSQL.Migrations

data Post = Post {
    postId :: DBKey
  , postTitle :: Text
  , postBody :: Text
  } deriving (Generic, Show)

instance Model Post

up :: Connection -> IO ()
up = migrate $ do
    create_table "posts"
      [ column "title" "VARCHAR(255) NOT NULL"
      , column "author_id" "integer references authors(id)"]

down :: Connection -> IO ()
down = migrate $ drop_table "posts"

main :: IO ()
main = do
  defaultMain up down
  conn <- connect $ defaultConnectInfo { connectHost = "172.17.0.2"}
  putStrLn "Hello, Haskell!"
  x <- save conn (Post (DBKey 1) "Chris" "test")
  print x

*** Exception: user error (Pattern match failure in do expression at Database/PostgreSQL/Migrations.hs:377:3-16)

stack list-dependencies:

aeson 1.2.3.0
app 0.1.0.0
array 0.5.2.0
attoparsec 0.13.2.0
base 4.10.1.0
base-compat 0.9.3
binary 0.8.5.1
blaze-builder 0.4.0.2
bytestring 0.10.8.2
bytestring-builder 0.10.8.1.0
case-insensitive 1.2.0.10
containers 0.5.10.2
deepseq 1.4.3.0
directory 1.3.0.2
dlist 0.8.0.3
filepath 1.4.1.2
ghc-boot-th 8.2.2
ghc-prim 0.5.1.1
hashable 1.2.6.1
integer-gmp 1.0.1.0
integer-logarithms 1.0.2
mtl 2.2.1
old-locale 1.0.0.7
postgresql-libpq 0.9.3.1
postgresql-orm 0.5.0
postgresql-simple 0.5.3.0
pretty 1.1.3.3
primitive 0.6.2.0
process 1.6.1.0
random 1.1
rts 1.0
scientific 0.3.5.2
tagged 0.8.5
template-haskell 2.12.0.0
text 1.2.2.2
th-abstraction 0.2.6.0
time 1.8.0.2
time-locale-compat 0.1.1.3
transformers 0.5.2.0
transformers-compat 0.5.1.4
unix 2.7.2.2
unordered-containers 0.2.8.0
uuid-types 1.0.3
vector 0.12.0.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions