<?php

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

class CreatePropertyBookingPaymentType extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        DB::statement("

            CREATE TABLE `property_booking_payment_type` (
              `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
              `name` varchar(250) COLLATE utf8mb4_unicode_ci NOT NULL,
              `language_key` varchar(250) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
              `code` varchar(5) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
              `status` tinyint(3) unsigned NOT NULL DEFAULT 1,
              `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 (`created_by`) REFERENCES `user` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
              FOREIGN KEY (`updated_by`) REFERENCES `user` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
            ) ;

        ") ;
        DB::statement("INSERT INTO `property_booking_payment_type` VALUES (1,'Credit Card',NULL,'CRD',1,1,1,1,1),(2,'Pay at Hotel',NULL,'HTL',1,1,1,1,1);");


        DB::statement("
              CREATE TABLE `property_booking_type` (
              `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
              `name` varchar(250) COLLATE utf8mb4_unicode_ci NOT NULL,
              `language_key` varchar(250) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
              `code` varchar(5) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
              `status` tinyint(3) unsigned NOT NULL DEFAULT 1,
              `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 (`created_by`) REFERENCES `user` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
              FOREIGN KEY (`updated_by`) REFERENCES `user` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
            );

        ") ;
        DB::statement("INSERT INTO `property_booking_type` VALUES (1,'Instant Confirmation',NULL,'INS',1,1,1,1,1),(2,'Request on Sale',NULL,'REQ',1,1,1,1,1);;");


        DB::statement("
            CREATE TABLE `property_channel_mapping_setup` (
              `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
              `property_id` int(10) unsigned NOT NULL,
              `channel_id` int(10) unsigned NOT NULL,
              `type` varchar(5) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'BKG, PYM',
              `type_id` int(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
              `setup_type` varchar(100) COLLATE utf8mb4_unicode_ci NULL COMMENT 'PLS, MIN',
              `value_type` varchar(100) COLLATE utf8mb4_unicode_ci NULL COMMENT 'FIX, PER',
              `value` double(10,2) NULL,
              `status` tinyint(3) unsigned NOT NULL DEFAULT 1,
              `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 (`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,
              FOREIGN KEY (`channel_id`) REFERENCES `property_channel` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
                );

        ") ;



    }

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