Skip to content

Instantly share code, notes, and snippets.

@Philonous
Created April 16, 2014 11:07
Show Gist options
  • Select an option

  • Save Philonous/10853831 to your computer and use it in GitHub Desktop.

Select an option

Save Philonous/10853831 to your computer and use it in GitHub Desktop.
DB layout
{-# LANGUAGE EmptyDataDecls #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE NoMonomorphismRestriction #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
module DBLayout where
import Data.ByteString (ByteString)
import Data.Int (Int64)
import Data.Text (Text)
import qualified Data.Text as Text
import Database.Persist
import Database.Persist.TH
-- import Types
import PersistStage
import qualified Data.UUID as UUID
share [mkPersist sqlSettings, mkMigrate "migrateAll"] [persistLowerCase|
Product
uniqueId UUID.UUID
name Text Asc
permalink Text
description Text
sku Text
UniqueProduct uniqueId
UniqueProductPermalink permalink
UniqueProductSku sku
deriving Show
ProductPrice
productId ProductId
currency Currency Eq
value Int64
UniqueProductPrice productId currency
deriving Show
Taxon
uniqueId UUID.UUID
name Text
permalink Text
UniqueTaxon uniqueId
UniqueTaxonName name
UniqueTaxonPermaLink permalink
ProductTaxon
productId ProductId
productTaxon TaxonId
UniqueProductTaxon productId productTaxon
ProductOption
productId ProductId
name Text
value Text
UniqueProductOption productId name
Attribute
name Text -- Name of the attribute Type, e.g. "colour"
type ByteString -- JSON encoding of the Attribute Type
UniqueAttributeName name
ProductAttribute
productId ProductId
attributeType AttributeId
attributeValue ByteString -- JSON encoding of the attribute value
Variant
uniqueId UUID.UUID
stock Int64
UniqueVariant uniqueId
VariantAttributes
variantId VariantId
type AttributeId
value Text -- JSON encoding of the value
|]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment