<?php

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

class Add5e1c4c0ab1ff8RelationshipsToPriceTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('prices', function (Blueprint $table) {
            if (!Schema::hasColumn('prices', 'residential_complex_id')) {
                $table->integer('residential_complex_id')->unsigned()->nullable();
                $table->foreign('residential_complex_id',
                    '338949_5e1c41aa0aff0')->references('id')->on('residential_complexes')->onDelete('cascade');
            }
            if (!Schema::hasColumn('prices', 'section_id')) {
                $table->integer('section_id')->unsigned()->nullable();
                $table->foreign('section_id',
                    '338949_5e1c41a9e1029')->references('id')->on('sections')->onDelete('cascade');
            }
            if (!Schema::hasColumn('prices', 'room_count_id')) {
                $table->integer('room_count_id')->unsigned()->nullable();
                $table->foreign('room_count_id',
                    '338949_5e1c41aa25e4d')->references('id')->on('room_counts')->onDelete('cascade');
            }
            if (!Schema::hasColumn('prices', 'room_type_id')) {
                $table->integer('room_type_id')->unsigned()->nullable();
                $table->foreign('room_type_id',
                    '338949_5e1c41aa453bf')->references('id')->on('room_types')->onDelete('cascade');
            }
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('prices', function (Blueprint $table) {
        });
    }
}
