Closed ianmacartney closed 3 months ago
But isn't it better to turn off schema validation? This doesn't really work for online migrations, because your reads will be broken (the schema pretends the data is there, but it is not).
Turning off schema validation stops checking all the other fields, and can take a long time to turn back on to validate literal unions etc. And yes this makes it your problem to read bad data- similar to a typical ORM. This is a more targeted way to turn off schema validation that is hopefully short-term
On Thu, Mar 14, 2024 at 2:15 AM Michal Srb @.***> wrote:
But isn't it better to turn off schema validation? This doesn't really work for online migrations, because your reads will be broken (the schema pretends the data is there, but it is not).
— Reply to this email directly, view it on GitHub https://github.com/get-convex/convex-helpers/pull/82#issuecomment-1996982038, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACZQW75ZPYCBYIQQAQ6E6LYYFTBNAVCNFSM6AAAAABEVBHXICVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOJWHE4DEMBTHA . You are receiving this because you authored the thread.Message ID: @.***>
other naming thoughts:
typesOnly
instead of pretend
optionalButTypeAsRequired
instead of pretendRequired
but I want to keep the latter as easy to type as possible, since it'll (hopefully) be used in dev mode mostly.
Adds convenience validators for when you don't mind some targeted incorrectness, esp. while you do migrations
Can be part of a post on pragmatic migration dev tips. Saves you from turning on & off schemaValidation.
Flow to add a field:
myField: pretendRequired(v.string()),
and code that sets & uses myField as if it exists[ and a migration to set it].pretendRequired
wrapper and deploy.Improves over the following in that you don't have to sprinkle
if
statements everywhere:myField: v.optional(v.string())
and code that handles it not being there[ and a migration to set it].if(!doc.newField) throw ...
lines) and deploy.Flow to change a field's type:
myField: pretend(v.number())
and code that assumes number, and a migration to change string -> number.pretend
and deploy.This saves you from changing all of your code to handle the union, just in order to deploy something that allows you to edit data in the dashboard.