Skip to content

How to give Table BoolColumn a default (not const) value? #2728

Answered by simolus3
archsolar asked this question in Q&A
Discussion options

You must be logged in to vote

If you want the default value to be stored in the database as part of the table's definition, Constant(false) would be the appropriate value. If you want to change the value later, you'd re-run the build and write a schema migration to change the default value as stored in the database.

If you anticipate that you need to change the default value frequently, an alternative would be clientDefault. That value is filled in by drift when an insert happens and is not stored in the database itself, so you can change it without a schema migration.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by archsolar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants