Skip to content

Commit

Permalink
snapshot import into a component (#29542)
Browse files Browse the repository at this point in the history
pass a `--component-path` flag to `npx convex import` to import into the specified component.

I think component path instead of ID makes sense here because (1) it's writing data, which should generally only happen in mounted components, (2) it's user-visible input, (3) the rest of the import uses table names and component paths in the zip file's paths, so this is consistent.

added a test of importing a CSV into a child component. And manually checked that you can export a single component in the dashboard as a ZIP file, and import it back in-place.

GitOrigin-RevId: cbe874ecf58b921befafca9dbb6f47d42a04a262
  • Loading branch information
ldanilek authored and Convex, Inc. committed Sep 5, 2024
1 parent 3d11684 commit aeab1f8
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/cli/convexImport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ export const convexImport = new Command("import")
"- ZIP files must have one directory per table, containing <table>/documents.jsonl. Snapshot exports from the Convex dashboard have this format.",
).choices(["csv", "jsonLines", "jsonArray", "zip"]),
)
.addOption(
new Option(
"--component-path <path>",
"Path to the component in the component tree defined in convex.config.ts",
// TODO(ENG-6967): Remove hideHelp before launching components
).hideHelp(),
)
.addDeploymentSelectionOptions(actionDescription("Import data into"))
.argument("<path>", "Path to the input file")
.showHelpAfterError()
Expand Down Expand Up @@ -156,6 +163,7 @@ export const convexImport = new Command("import")
}
const importArgs = {
tableName: tableName === null ? undefined : tableName,
componentPath: options.componentPath,
mode,
format,
};
Expand Down Expand Up @@ -458,7 +466,12 @@ export async function uploadForImport(
deploymentUrl: string;
adminKey: string;
filePath: string;
importArgs: { tableName?: string; mode: string; format: string };
importArgs: {
tableName?: string;
componentPath?: string;
mode: string;
format: string;
};
onImportFailed: (e: any) => Promise<void>;
},
) {
Expand Down

0 comments on commit aeab1f8

Please sign in to comment.