<?php

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

class InventroyColumnsDesign extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {

        DB::statement('TRUNCATE TABLE `property_room_rate_price` ');
        DB::statement('
ALTER TABLE `property_room_rate_price`
CHANGE COLUMN `offer_id` `availability_type_id` int(10) UNSIGNED NOT NULL AFTER `room_rate_mapping_id`,
ADD FOREIGN KEY (`availability_type_id`) REFERENCES `property_availability_type` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT;
        ');


        DB::statement('TRUNCATE TABLE `property_room_availability` ');
        DB::statement('ALTER TABLE `property_room_availability`
ADD COLUMN `channel_id` int(10) UNSIGNED NOT NULL AFTER `room_rate_mapping_id`,
CHANGE COLUMN `offer_id` `availability_type_id` int(10) UNSIGNED NOT NULL AFTER `channel_id`,
ADD FOREIGN KEY (`availability_type_id`) REFERENCES `property_availability_type` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
ADD FOREIGN KEY (`channel_id`) REFERENCES `property_channel` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT;');


    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        //
    }
}
