git.gnu.io has moved to IP address 209.51.188.249 -- please double check where you are logging in.

Commit d2e0eeac authored by Bryan Richter's avatar Bryan Richter

Effect a safe migration

parent b7012f6a
......@@ -28,8 +28,10 @@ User
statement Markdown Maybe
ircNick Text Maybe
languages [Language]
readNotifications UTCTime default=now() SafeToRemove
readApplications UTCTime default=now()
established Established default='EstUnestablished'
discussion DiscussionId default=nextval('discussion_id_seq'::regclass) MigrationOnly
UniqueUser ident
UniqueUserAccount account
......@@ -100,6 +102,7 @@ Project
shareValue Milray
lastPayday PaydayId Maybe
githubRepo Text Maybe
discussion DiscussionId default=nextval('discussion_id_seq'::regclass) MigrationOnly
public Bool default=true
logo Text Maybe
......@@ -195,6 +198,10 @@ VolunteerInterest
volunteer VolunteerApplicationId
interest InterestId
-- Deprecated. Necessary for MigrationOnly fields.
Discussion
nothing Int64
Tag
name Text
UniqueTag name
......
......@@ -17,6 +17,7 @@ import Yesod.Auth.HashDB (HashDBUser (..))
import Yesod.Markdown (Markdown)
import Model.Currency (Milray)
import Model.Discussion.TH (mkDiscussionTypes)
import Model.Established.Internal (Established(..))
import Model.Language
import Model.License.Internal
......@@ -55,6 +56,7 @@ import Model.ViewType.Internal (ViewType)
share [ mkPersist sqlSettings
, mkMigrate "migrateAll"
, mkDeleteCascade sqlSettings
, mkDiscussionTypes
]
$(persistFileWith lowerCaseSettings "config/models")
......
{-# LANGUAGE RecordWildCards #-}
module Model.Discussion.TH where
import Prelude
import Control.Monad
import Data.Maybe
import Data.Monoid
import Database.Persist.Types
import Language.Haskell.TH
import qualified Data.Text as T
mkDiscussionTypes :: [EntityDef] -> Q [Dec]
mkDiscussionTypes defs = do
let discussion_types = flip mapMaybe defs $ \EntityDef {..} -> do
guard $ entityHaskell /= HaskellName "Comment"
guard
(any
(\FieldDef {..} ->
fieldType == FTTypeCon Nothing "DiscussionId")
entityFields)
return $ T.unpack $ unHaskellName entityHaskell
mkTypeConstructor name = NormalC (mkName $ "DiscussionType" <> name) []
return
[ DataD
[]
(mkName "DiscussionType")
[]
(map mkTypeConstructor discussion_types)
[mkName "Bounded", mkName "Enum"]
]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment