I have a production system made in Laravel and Postgress and one of the migrations creates a view as follows:
$statement = "CREATE VIEW property_view AS SELECT property.id as property_id, ";
foreach($this->sections as $section) {
$statement = array_reduce($section->getFillable(), function($statement, $field)
use ($section) {
return $statement .= "{$section->getTable()}.{$field}, ";
}, $statement);
}
return rtrim($statement, ", ");
This works very well, but now a new field has been added to one of the tables, so being in production I cannot modify the previous migration and create a new one and there I tried several ways to add this field but without success:
DB::statement("ALTER VIEW property_view ADD COLUMN apn_number VARCHAR");
It is worth remembering that it is postgress