yesodweb / persistent

Persistence interface for Haskell allowing multiple storage methods.
MIT License
467 stars 297 forks source link

incorrect casing of false in `someField default=false` silently causes migrations to always happen #1171

Open codygman opened 3 years ago

codygman commented 3 years ago

We had a splice in production like:

Persist.share [Persist.mkPersist Persist.sqlSettings, Persist.mkMigrate "migrateAll"] [Persist.persistLowerCase|
Person
    isAwake Bool default=False
|]

When it came time to migrate, persistent would apply it. The next reload though, persistent would apply it again and then every run after.

If you lowercase False to false then the correct behavior happens: migration only happens once until something changes.

Postgres seems to not care about the casing here, but the check for if a migration is necessary does.

I think the correct behavior would be for either the quasiquoter to fail here for default=False or for the migration check to be case insensitive.

parsonsmatt commented 3 years ago

It would make sense for the migration to be case insensitive, I think. I'd prefer not to break code if possible.

parsonsmatt commented 3 years ago

Is this postgres?

tfausak commented 3 years ago

Yup!