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 is not idempotent when combining default=null and Maybe type #1534

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
11 changes: 11 additions & 0 deletions persistent-test/src/MigrationTest.hs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ Source1 sql=source
field4 Target1Id
|]

share [mkPersist sqlSettings, mkMigrate "migrationWithDefaultMaybeText"] [persistLowerCase|
TextMaybeDefault
field1 Int
field2 T.Text Maybe default=null
deriving Eq Show
|]

specsWith :: (MonadUnliftIO m) => RunDb SqlBackend m -> Spec
specsWith runDb = describe "Migration" $ do
it "is idempotent" $ runDb $ do
Expand All @@ -53,3 +60,7 @@ specsWith runDb = describe "Migration" $ do
void $ runMigrationSilent migrationAddCol
again <- getMigration migrationAddCol
liftIO $ again @?= []
fit "is idempotent (default text example)" $ runDb $ do
void $ runMigrationSilent migrationWithDefaultMaybeText
again <- getMigration migrationWithDefaultMaybeText
liftIO $ again @?= ["ALTER TABLE \"text_maybe_default\" ALTER COLUMN \"field2\" SET DEFAULT null"]
Copy link
Contributor Author

@danbroooks danbroooks May 22, 2024

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