You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the above example the column itself allows null values so this tool could extract that from the schema.
It would be tricky to pick out all of them with perfect accuracy since character lengths and things like ranges can have arbitrary expressions but maybe it's doable long term? I think capturing most of them with a reasonable amount of accuracy to get you going will be beneficial.
For example, check out this constraint:
add_check_constraint:packages,"discount_amount >= 0 AND discount_amount <= 2147483647 AND discount_amount <= amount",name: "discount_amount_range"
And then its column information:
t.integer:discount_amount,null: false,default: 0
If you wanted to programmatically create a validation from this you could factor:
It is of type integer so it must have whole numbers
I'm a big fan of having my database be the source of truth which often means setting up DB constraints.
For example:
Then my model would typically have a validation like this:
You can have different types of constraints too such as:
With a validation of:
You could also have:
With a validation of:
In the above example the column itself allows null values so this tool could extract that from the schema.
It would be tricky to pick out all of them with perfect accuracy since character lengths and things like ranges can have arbitrary expressions but maybe it's doable long term? I think capturing most of them with a reasonable amount of accuracy to get you going will be beneficial.
For example, check out this constraint:
And then its column information:
If you wanted to programmatically create a validation from this you could factor:
You could produce a validation like this:
It may save some time of checking Rails' docs to put together that validation?
The text was updated successfully, but these errors were encountered: