<?php

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

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

        DB::statement("
CREATE TABLE `property_pricing_policy_adult` (
`id` BIGINT ( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT,
`property_id` INT ( 10 ) UNSIGNED NOT NULL,
`name` VARCHAR ( 250 )  NOT NULL,
`single_extra_type` VARCHAR ( 10 ) DEFAULT NULL COMMENT 'PER,FIX',
`single_extra_value` DOUBLE ( 10, 2 ) DEFAULT NULL,
`single_discount_type` VARCHAR ( 10 ) DEFAULT NULL COMMENT 'PER,FIX',
`single_discount_value` DOUBLE ( 10, 2 ) 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`) USING BTREE,
FOREIGN KEY (`property_id`) REFERENCES `property` (`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
) ;
        ");



        DB::statement("
CREATE TABLE `property_channel_room_rate_pricing_policy_adult_mapping` (
`id` BIGINT ( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT,
`property_id` INT ( 10 ) UNSIGNED NOT NULL,
`room_rate_channel_mapping_id` BIGINT ( 20 ) UNSIGNED NOT NULL,
`pricing_policy_adult_id` BIGINT ( 20 ) UNSIGNED NOT 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`) USING BTREE,
FOREIGN KEY (`property_id`) REFERENCES `property` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
FOREIGN KEY (`room_rate_channel_mapping_id`) REFERENCES `property_room_rate_channel_mapping` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
FOREIGN KEY (`pricing_policy_adult_id`) REFERENCES `property_pricing_policy_adult` (`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
) ;
        ");



        DB::statement("
CREATE TABLE `property_pricing_policy_child` (
`id` BIGINT ( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT,
`property_id` INT ( 10 ) UNSIGNED NOT NULL,
`name` VARCHAR ( 250 ) NOT NULL,
`adult` TINYINT ( 5 ) NOT NULL,
`child_order` TINYINT ( 5 ) NOT NULL,
`child_age_start` INT ( 10 ) NOT NULL,
`child_age_end` INT ( 10 ) NOT NULL,
`type` VARCHAR ( 10 )  DEFAULT NULL COMMENT 'PER,FIX',
`value` DOUBLE ( 10, 2 ) 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`) USING BTREE,
FOREIGN KEY (`property_id`) REFERENCES `property` (`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
) ;
        ");



        DB::statement("
CREATE TABLE `property_channel_room_rate_pricing_policy_child_mapping` (
`id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
`property_id` int(10) unsigned NOT NULL,
`room_rate_channel_mapping_id` bigint(20) unsigned NOT NULL,
`pricing_policy_child_id` bigint(20) unsigned NOT 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`) USING BTREE,
FOREIGN KEY (`property_id`) REFERENCES `property` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
FOREIGN KEY (`room_rate_channel_mapping_id`) REFERENCES `property_room_rate_channel_mapping` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
FOREIGN KEY (`pricing_policy_child_id`) REFERENCES `property_pricing_policy_child` (`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
) ;
        ");




    }


}
