Skip to content

Redundant migrations for fields' default values #401

@tlaitinen

Description

@tlaitinen

I added a Boolean field "authorized" in the User table defined in "config/models" using a clean scaffolded site.

-- snip --
User
ident Text
password Text Maybe
authorized Bool default=True
UniqueUser ident
-- snip --

As expected, upon next startup of the development server, yesod migrates the table correctly:

Starting devel application
Devel application launched: http://localhost:3000
Migrating: ALTER TABLE "user" ADD COLUMN "authorized" BOOLEAN NOT NULL DEFAULT True

However, when the development server is launched for the second time, it sets the default value again even if it has not been changed:

Starting devel application
Devel application launched: http://localhost:3000
Migrating: ALTER TABLE "user" ALTER COLUMN "authorized" SET DEFAULT True

Is this intended behavior? Is it not possible to retrieve the default value from the database, so yesod takes a conservative approach and rewrites the default value every time?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions