<?php

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

class ChangeStationTaskTablesColumnStationId extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('station_tasks', function (Blueprint $table) {
            $table->dropColumn('station_id');
            $table->dropColumn('station_type_id');
        });
        Schema::table('station_task_batches', function (Blueprint $table) {
            $table->integer('station_id')->index();
        });
        Schema::table('station_task_commodities', function (Blueprint $table) {
            $table->integer('station_id')->index();
        });
        Schema::table('station_task_material_boxes', function (Blueprint $table) {
            $table->integer('station_id')->index();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('station_tasks', function (Blueprint $table) {
            $table->integer('station_id');
            $table->integer('station_type_id')->nullable()->index();
        });
        Schema::table('station_task_batches', function (Blueprint $table) {
            $table->dropColumn('station_id');
        });
        Schema::table('station_task_commodities', function (Blueprint $table) {
            $table->dropColumn('station_id');
        });
        Schema::table('station_task_material_boxes', function (Blueprint $table) {
            $table->dropColumn('station_id');
        });
    }
}
