3 use Illuminate\Database\Migrations\Migration;
4 use Illuminate\Database\Schema\Blueprint;
5 use Illuminate\Support\Facades\DB;
6 use Illuminate\Support\Facades\Schema;
8 return new class extends Migration
13 public function up(): void
15 Schema::table('activities', function (Blueprint $table) {
16 $table->renameColumn('key', 'type');
17 $table->renameColumn('extra', 'detail');
18 $table->dropColumn('book_id');
19 $table->integer('entity_id')->nullable()->change();
20 $table->string('entity_type', 191)->nullable()->change();
23 DB::table('activities')
24 ->where('entity_id', '=', 0)
27 'entity_type' => null,
32 * Reverse the migrations.
34 public function down(): void
36 DB::table('activities')
37 ->whereNull('entity_id')
43 Schema::table('activities', function (Blueprint $table) {
44 $table->renameColumn('type', 'key');
45 $table->renameColumn('detail', 'extra');
46 $table->integer('book_id');
48 $table->integer('entity_id')->change();
49 $table->string('entity_type', 191)->change();
51 $table->index('book_id');