-
Notifications
You must be signed in to change notification settings - Fork 302
Description
The change made in #641 created a problem: migration now attempts to alter the default value of text
(and presumably blob
) fields, but mysql does not allow these types to have defaults. Rather distressingly, the migration is actually trying to drop the default (even though there isn't one) but it is still a fatal error!
It's easy to reproduce this using an out-of-the-box yesod-mysql scaffolding:
stack --resolver lts-8.13 new foo yesod-mysql
cd foo
<create a clean mysql database, and edit config/settings.yml accordingly>
stack build
stack exec foo # First run sets up the database without problem
stack exec foo # Second run attempts a spurious migration and fails with an error from mysql
The error message is:
Migrating: ALTER TABLE `user` ALTER COLUMN `password` DROP DEFAULT
foo: ConnectionError {errFunction = "query", errNumber = 1101, errMessage = "BLOB/TEXT column 'password' can't have a default value"}
Reverting the two lines changed in #641 fixes this completely. The password
field in the scaffolding is indeed nullable, so the new logic applies to it, but it is a text field, so the null in COLUMN_DEFAULT really does mean "unset", because it is not allowed to a default.
@qrilka I can see what you you wanted to achieve, but I am not sure how to fix it. What do you think?