<?php

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

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

        DB::statement("
                CREATE TABLE `property_place_fact_mapping`  (
                  `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
                  `property_id` int(10) UNSIGNED NOT NULL,
                  `property_place_id` bigint(20) UNSIGNED NOT NULL,
                  `place_fact_title_fact_mapping_id` bigint(20) UNSIGNED NOT 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`) USING BTREE,
                  UNIQUE INDEX `property_id_2`(`property_id`, `property_place_id`, `place_fact_title_fact_mapping_id`) USING BTREE,
                  INDEX `property_id`(`property_id`) USING BTREE,
                  INDEX `property_place_id`(`property_place_id`) USING BTREE,
                  INDEX `place_fact_title_fact_mapping_id`(`place_fact_title_fact_mapping_id`) USING BTREE,
                  INDEX `created_by`(`created_by`) USING BTREE,
                  INDEX `updated_by`(`updated_by`) USING BTREE,
                  CONSTRAINT `property_place_fact_mapping_ibfk_1` FOREIGN KEY (`property_id`) REFERENCES `property` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
                  CONSTRAINT `property_place_fact_mapping_ibfk_2` FOREIGN KEY (`property_place_id`) REFERENCES `property_place` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
                  CONSTRAINT `property_place_fact_mapping_ibfk_3` FOREIGN KEY (`place_fact_title_fact_mapping_id`) REFERENCES `property_place_fact_title_fact_mapping` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
                  CONSTRAINT `property_place_fact_mapping_ibfk_4` FOREIGN KEY (`created_by`) REFERENCES `user` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
                  CONSTRAINT `property_place_fact_mapping_ibfk_5` FOREIGN KEY (`updated_by`) REFERENCES `user` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
                ) ;


        ") ;


    }


}
