<?php

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

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



        DB::statement('ALTER TABLE `property_channel_mapping`
            ADD COLUMN `property_booking_type_id` int(10) UNSIGNED NOT NULL AFTER `currency_code`,
            ADD COLUMN `property_availability_type_id` int(10) UNSIGNED NOT NULL AFTER `property_booking_type_id`,
            ADD COLUMN `property_room_pricing_type_id` int(10) UNSIGNED NOT NULL AFTER `property_availability_type_id`
        ;') ;

        DB::statement('UPDATE `property_channel_mapping` SET `property_booking_type_id` = 1;') ;
        DB::statement('UPDATE `property_channel_mapping` SET `property_availability_type_id` = 1;') ;
        DB::statement('UPDATE `property_channel_mapping` SET `property_room_pricing_type_id` = 1;') ;

        DB::statement('ALTER TABLE `property_channel_mapping`
            ADD FOREIGN KEY (`property_booking_type_id`) REFERENCES `property_booking_type` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
            ADD FOREIGN KEY (`property_availability_type_id`) REFERENCES `property_availability_type` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
            ADD FOREIGN KEY (`property_room_pricing_type_id`) REFERENCES `property_room_pricing_type` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
        ;') ;
    }

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