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 class SimplifyActivitiesTable extends Migration
17 Schema::table('activities', function (Blueprint $table) {
18 $table->renameColumn('key', 'type');
19 $table->renameColumn('extra', 'detail');
20 $table->dropColumn('book_id');
21 $table->integer('entity_id')->nullable()->change();
22 $table->string('entity_type', 191)->nullable()->change();
25 DB::table('activities')
26 ->where('entity_id', '=', 0)
29 'entity_type' => null,
34 * Reverse the migrations.
38 public function down()
40 DB::table('activities')
41 ->whereNull('entity_id')
47 Schema::table('activities', function (Blueprint $table) {
48 $table->renameColumn('type', 'key');
49 $table->renameColumn('detail', 'extra');
50 $table->integer('book_id');
52 $table->integer('entity_id')->change();
53 $table->string('entity_type', 191)->change();
55 $table->index('book_id');