Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migration with lowercase 'current_timestamp' is not idempotent #1533

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions persistent-test/src/MigrationTest.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module MigrationTest where

import Database.Persist.TH
import qualified Data.Text as T
import Data.Time

import Init

Expand Down Expand Up @@ -36,6 +37,13 @@ Source1 sql=source
field4 Target1Id
|]

share [mkPersist sqlSettings, mkMigrate "migrationWithDefaultTime"] [persistLowerCase|
TimeDefault
field3 Int
extra UTCTime default=current_timestamp
field4 Target1Id
|]

specsWith :: (MonadUnliftIO m) => RunDb SqlBackend m -> Spec
specsWith runDb = describe "Migration" $ do
it "is idempotent" $ runDb $ do
Expand All @@ -53,3 +61,7 @@ specsWith runDb = describe "Migration" $ do
void $ runMigrationSilent migrationAddCol
again <- getMigration migrationAddCol
liftIO $ again @?= []
it "is idempotent (default time example)" $ runDb $ do
void $ runMigrationSilent migrationWithDefaultTime
again <- getMigration migrationWithDefaultTime
liftIO $ again @?= ["ALTER TABLE \"time_default\" ALTER COLUMN \"extra\" SET DEFAULT current_timestamp"]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, the test should be:

liftIO $ again @?= []

Loading