<?php

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

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

        DB::statement("

        CREATE TABLE `property_cancellation_policy_setup`  (
  `id` int(0) NOT NULL AUTO_INCREMENT,
  `property_id` int(10) UNSIGNED NOT NULL,
  `cancellation_policy_id` bigint(10) UNSIGNED NOT NULL,
  `before_arrival` int(10) UNSIGNED NOT NULL,
  `is_full_refund` tinyint(4) NOT NULL,
  `type` varchar(10)  NULL DEFAULT NULL COMMENT 'PER,FIX,NGT',
  `value` double(10, 2) NULL DEFAULT NULL,
  `status` tinyint(4) NOT NULL,
  `created_by` int(10) UNSIGNED NOT NULL,
  `updated_by` int(10) UNSIGNED NOT NULL,
  `created_at` int(11) NOT NULL,
  `updated_at` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  FOREIGN KEY (`cancellation_policy_id`) REFERENCES `property_cancellation_policy` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  FOREIGN KEY (`created_by`) REFERENCES `user` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  FOREIGN KEY (`updated_by`) REFERENCES `user` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  FOREIGN KEY (`property_id`) REFERENCES `property` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
);
        ");


        DB::statement("

 ALTER TABLE `property_cancellation_policy`
DROP COLUMN `before_arrival`;

        ");

        DB::statement("

ALTER TABLE `property_channel_room_rate_cancellation_policy_mapping`
DROP COLUMN `is_full_refund`,
DROP COLUMN `night_count`,
DROP COLUMN `type`,
DROP COLUMN `value`;

        ");

    }


}
