35 lines
917 B
PHP
35 lines
917 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
use Illuminate\Database\Migrations\Migration;
|
||
|
|
use Illuminate\Database\Schema\Blueprint;
|
||
|
|
use Illuminate\Support\Facades\Schema;
|
||
|
|
|
||
|
|
return new class extends Migration
|
||
|
|
{
|
||
|
|
public function up(): void
|
||
|
|
{
|
||
|
|
$tables = ['projects', 'phases', 'layers', 'features', 'inspections'];
|
||
|
|
|
||
|
|
foreach ($tables as $table) {
|
||
|
|
if (!Schema::hasColumn($table, 'deleted_at')) {
|
||
|
|
Schema::table($table, function (Blueprint $t) {
|
||
|
|
$t->softDeletes();
|
||
|
|
});
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public function down(): void
|
||
|
|
{
|
||
|
|
$tables = ['projects', 'phases', 'layers', 'features', 'inspections'];
|
||
|
|
|
||
|
|
foreach ($tables as $table) {
|
||
|
|
if (Schema::hasColumn($table, 'deleted_at')) {
|
||
|
|
Schema::table($table, function (Blueprint $t) {
|
||
|
|
$t->dropSoftDeletes();
|
||
|
|
});
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
};
|