NoahN
Convex Community6mo ago
2 replies
Noah

Request to support `args` parameter in Convex Migrations

With Convex migrations I can use table indexes to only run the migration on a subset.

But I can't find a way to take in an argument for which subset to run it on. So every time I wanna change the customRange query I'm forced to push a change.

Here's what I'd like to do:

export const validateRequiredField = migrations.define({
  table: "myTable",
  args: {
    organizationId: v.string(),
  },
  customRange: (query, args) =>
    query.withIndex("byorganizationid", (q) => q.eq("organizationId", args.organizationId)),
  migrateOne: async (_ctx, doc) => {
    console.log("Needs fixup: " + doc._id);
    // Shorthand for patching
    return { requiredField: "<unknown>" };
  },
});


But the args parameter is not supported at the moment.
Was this page helpful?