-
Notifications
You must be signed in to change notification settings - Fork 296
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix add reference * Changelog/cabal * no
- Loading branch information
1 parent
6de3ffe
commit 2aa65e2
Showing
5 changed files
with
66 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
{-# LANGUAGE ExistentialQuantification #-} | ||
{-# LANGUAGE OverloadedStrings, DataKinds, FlexibleInstances #-} | ||
{-# LANGUAGE QuasiQuotes #-} | ||
{-# LANGUAGE MultiParamTypeClasses #-} | ||
{-# LANGUAGE TemplateHaskell #-} | ||
{-# LANGUAGE TypeFamilies #-} | ||
{-# LANGUAGE UndecidableInstances #-} | ||
{-# LANGUAGE StandaloneDeriving #-} | ||
{-# LANGUAGE DerivingStrategies #-} | ||
{-# LANGUAGE GeneralizedNewtypeDeriving #-} | ||
{-# OPTIONS_GHC -Wno-unused-top-binds #-} | ||
|
||
module MigrationReferenceSpec where | ||
|
||
import PgInit | ||
|
||
import Control.Monad.Trans.Writer (censor, mapWriterT) | ||
import Data.Text (Text, isInfixOf) | ||
|
||
share [mkPersist sqlSettings, mkMigrate "referenceMigrate"] [persistLowerCase| | ||
|
||
LocationCapabilities | ||
Id Text | ||
bio Text | ||
|
||
LocationCapabilitiesPrintingProcess | ||
locationCapabilitiesId LocationCapabilitiesId | ||
|
||
LocationCapabilitiesPrintingFinish | ||
locationCapabilitiesId LocationCapabilitiesId | ||
|
||
LocationCapabilitiesSubstrate | ||
locationCapabilitiesId LocationCapabilitiesId | ||
|
||
|] | ||
|
||
spec :: Spec | ||
spec = describe "MigrationReferenceSpec" $ do | ||
it "works" $ runConnAssert $ do | ||
let | ||
noForeignKeys :: CautiousMigration -> CautiousMigration | ||
noForeignKeys = filter ((not . isReference) . snd) | ||
|
||
onlyForeignKeys :: CautiousMigration -> CautiousMigration | ||
onlyForeignKeys = filter (isReference . snd) | ||
|
||
isReference :: Text -> Bool | ||
isReference migration = "REFERENCES" `isInfixOf` migration | ||
|
||
runMigration | ||
$ mapWriterT (censor noForeignKeys) | ||
$ referenceMigrate | ||
|
||
runMigration | ||
$ mapWriterT (censor onlyForeignKeys) | ||
$ referenceMigrate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters