Skip to content

Attribute's "default" and "default_for_new" should be allowed together #1292

@Soul-Burn

Description

@Soul-Burn

When adding a new attribute an existing model, sometimes we want a default for new items, while older items having a different default.

For example, adding an attribute for a new setting in a user config. We want new users to have the feature enabled, while old users defaulting to off.

Old users without the attribute in the db will get the "default" which is "off" (and then get backfilled when saved), while new users will get the new default.

This can also be achieved by explicitly setting the new value everywhere we create a new model, but easy to miss if a "default" already exists.


There should probably be 3 different options here:

  • Default that is applied when reading from a DB missing that attribute (currently part of default)
  • Default that is applied when writing a new item to the DB, but not explicitly giving it a value (currently default_for_new and default)
  • Whether or not to backfill a read default when re-saving the the item (currently implicit when default exists)

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