#how i can clear local deployment db ?
4 messages · Page 1 of 1 (latest)
You have a few options, depending on what you mean by “local deployment” and how thorough you want to be:
1. Clear tables via CLI (recommended for dev/local)
You can delete all documents from every table with a shell one‑liner using npx convex import and an empty file: [YOLO tips]
# Clear a single table
npx convex import --table <tableName> --replace --format jsonLines /dev/null
# Clear all tables in the deployment
for tableName in `npx convex data`; do
npx convex import --table $tableName --replace -y --format jsonLines /dev/null
done
This works the same for cloud dev and for a local deployment started with npx convex dev --local. [Local deployments]
2. Clear tables from the dashboard
If your local deployment is visible in the Convex dashboard, you can:
- Go to Deployments → Data
- For each table, use the
⋮menu → Clear table to delete all documents (table remains). [Clear a table]
3. Delete the local backend’s data file (OSS backend only)
If you’re using the open‑source backend binary (convex-local-backend), its state is stored in a local SQLite file. You can wipe everything by deleting that file:
rm convex_local_backend.sqlite3
This is explicitly mentioned as the way to “wipe your local database” when upgrading the OSS backend. [OSS backend dev; OSS build notes]
4. Programmatic “clear all” mutation (for tests)
For test setups, you can add a mutation that deletes all documents from all tables (plus scheduled jobs and storage) and call it when you need a clean DB. [Writing tests]
export const clearAll = testingMutation(async (ctx) => {
for (const table of Object.keys(schema.tables)) {
const docs = await ctx.db.query(table as any).collect();
await Promise.all(docs.map((doc) => ctx.db.delete(doc._id)));
}
const scheduled = await ctx.db.system.query("_scheduled_functions").collect();
await Promise.all(scheduled.map((s) => ctx.scheduler.cancel(s._id)));
const storedFiles = await ctx.db.system.query("_storage").collect();
await Promise.all(storedFiles.map((s) => ctx.storage.delete(s._id)));
});
If you tell me whether you’re using npx convex dev --local or the OSS convex-local-backend binary, I can suggest the exact command flow.
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
@zenith trellis Kapa.ai is still learning and improving, please let me know how I did by reacting below.