<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateStationTaskChildren2 extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('station_task_children', function (Blueprint $table) {
            $table->id();
            $table->bigInteger('station_task_id')->index();
            $table->string('station_taskable_type');
            $table->bigInteger('station_taskable_id');
            $table->index(['station_taskable_type','station_taskable_id'],'station_taskable_t_i');
            $table->timestamps();
        });
        Schema::table('station_tasks', function (Blueprint $table) {
            $table->dropColumn('station_taskable_type');
            $table->dropColumn('station_taskable_id');
//            $table->dropIndex('station_taskable_type');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('station_task_children');
        Schema::table('station_tasks', function (Blueprint $table) {
            $table->string('station_taskable_type');
            $table->integer('station_taskable_id');
            $table->index(['station_taskable_id','station_taskable_id'],'station_taskable_type');
        });
    }
}
