I have a local development script that resets the db via convex import which I'll often use when making changes to the schema to reset and re-seed the database. The problem is that when changing the schema it'll often cause the validation to fail and prevent the backend from running to perform the reset task. I can get around this by temporarily setting schemaValidation to false in the schema config then flipping it back, but is there some way to pass a flag to bypass schema validation when I'm running the reset script since the purpose is to clear the database anyway?
#Bypass schema validation
4 messages · Page 1 of 1 (latest)
Hi @frigid wyvern. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
There is currently no documented flag or CLI option to bypass schema validation directly when running a reset or import script with npx convex import. Schema validation is enforced at the time of schema push and during data import if schemaValidation is set to true. If your data does not match the schema, the import will fail, and you will not be able to proceed until the data and schema are compatible.
The recommended workaround is, as you mentioned, to temporarily set schemaValidation: false in your schema configuration, perform your reset or import, and then re-enable validation afterward. This approach is explicitly documented and supported:
You can disable
schemaValidationby passing inschemaValidation: false:defineSchema( { // Define tables here. }, { schemaValidation: false, }, );When
schemaValidationis disabled, Convex will not validate that new or existing documents match your schema. You'll still get schema-specific TypeScript types, but there will be no validation at runtime that your documents match those types.
There is no mention in the knowledge sources of a CLI flag or environment variable to bypass schema validation just for a single import or reset operation. The only way to bypass validation is by changing the schema configuration itself.
If this workflow is cumbersome, you might consider scripting the schema file change as part of your reset process, but this would still involve toggling the schemaValidation option in code.
If you need to clear all tables, you can use the documented one-liner to delete all documents, but schema validation will still apply if enabled:
for tableName in `npx convex data`; do npx convex import --table $tableName --replace -y --format jsonLines /dev/null; done
Source: YOLO: Get to an MVP fast