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:
@@ -285,7 +285,7 @@ func AssignCampaign(d *db.DB, source, id string, signalID int64) error {
|
||||
// Campaigns lists the outside campaigns, unassigned first, newest sync first.
|
||||
func Campaigns(d *db.DB) ([]Campaign, error) {
|
||||
rows, err := d.Query(`SELECT source, id, name, status, coalesce(signal_id, 0), spend_cents, stats, synced_at
|
||||
FROM outside_campaigns ORDER BY signal_id IS NOT NULL, source, name COLLATE NOCASE`)
|
||||
FROM outside_campaigns ORDER BY signal_id IS NOT NULL, source, name COLLATE NOCASE, id`)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user