Phase 9, part 7: export and import, between SQLite and Postgres
supermarket export [--with-secrets] writes a whole Supermarket as a .tar.gz (a manifest, each table as JSON lines, secrets if asked for) to the file storage. supermarket import loads one into an empty database at the same schema, SQLite or Postgres, in one transaction, parents first, checking row counts and moving Postgres' identity counters past the imported ids. Checked on Federated's 112,543 rows: imported into Postgres and SQLite, every table and total matches, and TestPagesOnRealData renders all 57 pages the same from both. That found unsettled ordering (case-alike campaigns, customers with the same name, metrics' float sums), now fixed with ORDER BY and tie-breakers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+27
-1
@@ -20,6 +20,9 @@ Usage: supermarket [command]
|
||||
token Print the token agents use to reach Supermarket's MCP endpoint
|
||||
data Print where its data is kept
|
||||
config Show its edition and settings, and any problems with them
|
||||
export [--with-secrets] Export everything (to move to a server, or
|
||||
another computer); with --with-secrets, keys and tokens too
|
||||
import <file> Load an export into a new, empty Supermarket
|
||||
backup [note] Back up the database now (it also backs up daily)
|
||||
backup --with-secrets The same, with your keys and tokens, for moving
|
||||
to another computer (keep the file safe)
|
||||
@@ -64,7 +67,30 @@ case "${1:-open}" in
|
||||
logs) compose logs -f --tail 200 ;;
|
||||
hermes) shift; bash "$REPO/hermes/setup.sh" "$@" ;;
|
||||
token) cat "$DATA/mcp-token" ;;
|
||||
backup|backups|config)
|
||||
import)
|
||||
if ! docker exec supermarket true 2> /dev/null; then
|
||||
echo "Supermarket isn't running: start it first (supermarket start)."
|
||||
exit 1
|
||||
fi
|
||||
if [ -z "${2:-}" ]; then
|
||||
echo "Usage: supermarket import <export file>"
|
||||
exit 1
|
||||
fi
|
||||
target="$2"
|
||||
# A file elsewhere on this computer is copied in, where the app sees it.
|
||||
if [ -f "$target" ]; then
|
||||
case "$(realpath "$target")" in
|
||||
"$(realpath "$DATA")"/*) ;;
|
||||
*)
|
||||
mkdir -p "$DATA/files/imports"
|
||||
install -m 600 "$target" "$DATA/files/imports/$(basename "$target")"
|
||||
target="imports/$(basename "$target")"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
docker exec supermarket supermarket import "$target"
|
||||
;;
|
||||
backup|backups|config|export)
|
||||
if ! docker exec supermarket true 2> /dev/null; then
|
||||
echo "Supermarket isn't running: start it first (supermarket start)."
|
||||
exit 1
|
||||
|
||||
Reference in New Issue
Block a user