Clean up this migration so it runs forwards and backwards OK

This commit is contained in:
Brady Wetherington 2023-09-14 21:14:26 +01:00
parent 873d260f55
commit 58656fbaec

View file

@ -1,5 +1,7 @@
<?php
use App\Models\Asset;
use App\Models\DefaultValuesForCustomFields;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
@ -14,9 +16,16 @@ class AddTypeColumnToDefaultValuesForCustomFields extends Migration
public function up()
{
Schema::table('default_values_for_custom_fields', function (Blueprint $table) {
$table->text('type')->default('App\\Models\\Asset');
$table->renameColumn('asset_model_id','item_pivot_id');
$table->string('type')->nullable();
$table->renameColumn('asset_model_id','item_pivot_id'); //this one works. okay. that's someting.
//$table->text('type')->nullable(false)->change();
});
DefaultValuesForCustomFields::query()->update(['type' => Asset::class]);
Schema::table('default_values_for_custom_fields', function (Blueprint $table) {
//$table->renameColumn('asset_model_id','item_pivot_id'); //this one works. okay. that's someting.
$table->string('type')->nullable(false)->change();
});
}
/**