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

Migrations allow new mandatory fields without a default #182

Open
jayvdb opened this issue Jan 21, 2024 · 0 comments
Open

Migrations allow new mandatory fields without a default #182

jayvdb opened this issue Jan 21, 2024 · 0 comments

Comments

@jayvdb
Copy link
Collaborator

jayvdb commented Jan 21, 2024

#[default] needs to be added to any mandatory fields added after the initial migration.

Currently this isnt enforced. I expect the place to issue the warning or error is in make-migration.

IMO it should be a warning (initially, at least) as having no default is only critical when updating existing data - while that is an important feature, the majority of database column additions occur before the schema is in production.

Perhaps before it is enforced, there are alternatives, such as using the Default trait as a fallback. Another way to achieve that is to support #[serde(default)] https://serde.rs/attr-default.html , which avoids developing our own syntax when one already exists that should be sufficient, and then perhaps adding #[butane(default)] if there are some database specific "default" behaviours that are needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant