admin Tested: December 23, 2025

Data Management & Import/Export

Comprehensive database backup, restore, and migration tools with JSON import/export for all tables and records.

admindata-managementimport-exportbackupmigration
Data Management & Import/Export

Overview

The Data Management page provides enterprise-grade tools for database backup, restore, and migration operations critical for production deployments and disaster recovery.

Key Features

Database Overview

Real-time statistics showing record counts across all tables:

  • 5,179 total records in production database
  • 52 States: US state reference data
  • 3,222 Counties: Complete county boundaries
  • 9 Brokers: Active real estate partnerships
  • 5 Agents: Registered real estate agents
  • 1,882 Coverage: Broker-to-county assignments
  • 8 Leads: Customer inquiries
  • 1 Assignment: Lead routing history

Export Capabilities

Full Database Export

  • One-Click Backup: Export entire database as single JSON file
  • Automatic Timestamping: Files named hure-full-export-YYYY-MM-DD.json
  • Metadata Included: Schema version, export timestamp, record counts
  • Foreign Key Safe: Export respects table dependencies

Individual Table Export

Export specific tables independently:

  • States
  • Counties
  • Brokers
  • Agents
  • Coverage (broker_counties)
  • Leads

Use Cases:

  • Selective backups for specific data types
  • Sharing county data with external systems
  • Creating test datasets
  • Auditing specific table changes

Import Capabilities

Smart Import Features

  • Duplicate Detection: Automatically skips existing records by ID and unique constraints
  • Full/Partial Support: Accepts complete exports or single table files
  • Validation: Schema validation before import to catch errors
  • Transaction Safety: All-or-nothing import for data integrity
  • Progress Feedback: Real-time import statistics and error reporting

Import Workflow

  1. Click “Import from File” button
  2. Select JSON export file (full or single table)
  3. Optionally enable “Clear Before Import” mode
  4. System validates file format and schema version
  5. Import executes with duplicate skipping
  6. Success notification with statistics:
    • Records imported
    • Records skipped (duplicates)
    • Errors encountered

Import Order

The system respects foreign key dependencies:

  1. States (no dependencies)
  2. Counties (depends on states)
  3. Brokers (no dependencies)
  4. Agents (depends on brokers)
  5. Coverage (depends on brokers + counties)
  6. Leads (depends on counties)
  7. Assignments (depends on leads + agents)

Clear Data Operations

Full Database Clear

Destructive Operation - Removes all records from all tables

  • Confirmation dialog required
  • Respects foreign key order (reverse of import)
  • Use for fresh starts or testing scenarios

Individual Table Clear

Clear specific tables while preserving others:

  • Useful for resetting test data
  • Clearing outdated leads
  • Removing inactive brokers

Safety Features:

  • Multiple confirmation prompts
  • Admin-only access
  • Audit logging of clear operations

Production Deployment Workflow

Initial Deployment

This feature was used to populate the production database:

  1. Local Export: Exported dev database with test data
  2. Upload to Production: Accessed /admin/data on production server
  3. Import Operation: Clicked “Import from File”
  4. Selected Export: Chose hure-full-export-2025-12-23.json
  5. Import Success: 5,179 records imported successfully
  6. Verification: Map loaded all 3,222 counties correctly

Ongoing Operations

Daily Backups:

  • Export full database to secure storage
  • Version control for disaster recovery
  • Retain 30-day backup history

Data Migration:

  • Export from old system
  • Transform data format if needed
  • Import into new system
  • Verify data integrity

Testing:

  • Export production data
  • Import to staging environment
  • Test new features with real data
  • Clear staging data when done

Testing Results

  • ✅ Database overview shows accurate record counts
  • ✅ Full database export downloads complete JSON file
  • ✅ Individual table exports work for all tables
  • ✅ Import successfully loaded 5,179 records
  • ✅ Duplicate detection skipped existing records
  • ✅ Import statistics displayed correctly
  • ✅ Refresh button updates statistics
  • ✅ All action buttons are functional
  • ✅ Icons and visual indicators clear
  • ✅ No data corruption after import/export cycle
  • ✅ Foreign key constraints maintained