goal:refresh-materialized-viewsRefreshes PostgreSQL materialized views in the publish schema only when underlying master data (base tables) has changed since the last successful refresh. Runs independently on:
| Target alias | Connection | Database role |
|---|---|---|
goal |
goal-data-db |
Operational data |
goalCore |
goal-db |
Core configuration / security |
State and history are stored in:
publish.materialized_view_refresh_statespublish.materialized_view_refresh_logson each database connection.
php artisan goal:refresh-materialized-views --target=all
php artisan goal:refresh-materialized-views --target=goal --dry-run --json
php artisan goal:refresh-materialized-views --target=goalCore --force
php artisan goal:refresh-materialized-views --view=mv_product_prices --view=v_product_details
| Option | Description |
|---|---|
--target=all |
goal, goalCore, or all (default all) |
--force |
Refresh every discovered view in publish |
--view=* |
Restrict to one or more materialized view names (without schema) |
--dry-run |
Compute stale views without REFRESH MATERIALIZED VIEW |
--trigger=manual |
Label stored in logs (manual, scheduled, etc.) |
--json |
Emit machine-readable summary |
When the app label scheduler is enabled, the command runs every 5 minutes:
goal:refresh-materialized-views --target=all --trigger=scheduled
Output is appended to storage/logs/refresh-materialized-views.log.
pg_matviews where schemaname = 'publish'.pg_depend / pg_rewrite), including cross-schema sources (e.g. public.products).sha256) from table watermarks:
GREATEST(MAX(updated_at), MAX(created_at), MAX(deleted_at)) when columns exist.pg_stat_user_tables tuple counters (documented limitation after stats reset).materialized_view_refresh_states, on --force, or when an upstream materialized view in publish was refreshed in the same run.publish.REFRESH MATERIALIZED VIEW CONCURRENTLY only when a unique index exists on the view; otherwise WITH DATA.File: config/materialized_views.php
schema: publishtargets: goal (goal-data-db) and goalCore (goal-db)excluded_views: optional name blocklistmax_views_per_run: optional safety cap{
"success": true,
"message": "Refresh de vistas materializadas completado correctamente.",
"data": {
"goal": {
"run_id": "…",
"refreshed": ["publish.mv_product_prices"],
"skipped": ["publish.v_product_classes"],
"failed": []
},
"goalCore": {
"run_id": "…",
"refreshed": [],
"skipped": [],
"failed": []
}
}
}
Domain\Database\MaterializedView\RefreshMaterializedViewsIfChangedActionDomain\Database\MaterializedView\DiscoverMaterializedViewsActionDomain\Database\MaterializedView\ResolveMaterializedViewDependenciesActionDomain\Database\MaterializedView\ComputeSourceFingerprintAction