goal:companies:sync-to-goal-databaseMirrors the companies table from goal-db (DB_CORE, source of truth) to goal-data-db (DB_DATA, Goal::db()), using the same path as the REST API: Company::replicateToGoalDatabase() / replicateToGoalDatabaseIfChanged().
Operational apps read company rows from goal-data-db by the same numeric id.
# Incremental sync (all companies that changed or are missing on replica)
php artisan goal:companies:sync-to-goal-database
# Single company
php artisan goal:companies:sync-to-goal-database --company=8
# Full scan (still skips rows whose normalized payload already matches)
php artisan goal:companies:sync-to-goal-database --force
# Preview without writes
php artisan goal:companies:sync-to-goal-database --dry-run --json
| Option | Description |
|---|---|
--company |
Sync one company id only (-c alias). |
--force |
Examine every company on core (not only incremental candidates). |
--dry-run |
Report would_sync / would_skip without updating goal-data-db. |
--trigger=manual |
Label stored in metrics (manual, scheduled, etc.). |
--json |
Machine-readable ActionResult envelope. |
Because core and goal-data are separate PostgreSQL databases, the command does not use a cross-database SQL join. Instead:
id, updated_at, and deleted_at from goal-data-db (unless --force).updated_at is newer, or deleted_at differs (soft deletes included via withTrashed()).| Event | Replication |
|---|---|
POST /v1/base/master/companies (create) |
Immediate replicateToGoalDatabase after insert. |
PUT (update) |
Immediate replicate via UpdateCompanyAction. |
| Drift / missed paths | This command (scheduled every 5 minutes on scheduler nodes). |
See Companies API for productive_mode and insert rules on the replica.
When the app label scheduler is enabled, the command runs every 5 minutes:
goal:companies:sync-to-goal-database --trigger=scheduled
Output is appended to storage/logs/sync-companies-to-goal-database.log.
Uses onOneServer() and withoutOverlapping() like goal:refresh-materialized-views.
GOAL API test deploy workflows run this command before database migrations (after the API container is healthy):
php artisan goal:companies:sync-to-goal-database --trigger=scheduled
Workflows: publish-roma.test.yml (test branch), publish-roma.test-v2.yml (test-qa branch).
data)| Field | Meaning |
|---|---|
examined |
Companies evaluated in this run. |
synced |
Rows written (or would sync with --dry-run). |
skipped_unchanged |
Payload already matched replica. |
skipped_missing_core |
--company id not found on core. |
errors |
Per-row failures (logged; batch continues). |
company_ids_synced |
IDs replicated in this run. |