How does import affect the ids
If I use import --replace does it delete all my documents and then pushes the new ones?
How can I just replace the fields (not entries) that are outdated and keep the same _id? Or does the id gets created through a hash on some fields so the same entry gets the same _id.
2 Replies
When you import from an existing snapshot, say you exported, edited, and re-imported, it will replace all your documents. however, it will re-use the _id and _creationTime fields that you provide, if they're valid. They aren't a hash of the contents. So you can change the fields and re-import. However, if you are wanting to change fields on all your documents, I'd suggest writing a migration mutation. Here's a post on it: https://stack.convex.dev/migrating-data-with-mutations
I'm also almost done with a new stateful migration helper, so stay tuned for that
Migrating Data With Mutations
Using mutations to migrate data in Convex.
Stateful migration helper has been released! Details in the same link: https://stack.convex.dev/migrating-data-with-mutations
Stateful Migrations using Mutations
Online migrations in Convex using mutations. Including a helper to track migration state!