<?php

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

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

        DB::statement("

        CREATE TABLE `property_place_photo_mapping`  (
  `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
  `property_id` int(10) UNSIGNED NOT NULL,
  `place_id` bigint(20) UNSIGNED NOT NULL,
  `photo_id` bigint(20) UNSIGNED 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,
  UNIQUE INDEX `ppr_unique`(`property_id`, `photo_id`, `place_id`) USING BTREE,
  INDEX `property_place_photo_mapping_place_id_foreign`(`place_id`) USING BTREE,
  INDEX `property_place_photo_mapping_photo_id_foreign`(`photo_id`) USING BTREE,
  CONSTRAINT `property_place_photo_mapping_photo_id_foreign` FOREIGN KEY (`photo_id`) REFERENCES `property_photo` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `property_place_photo_mapping_property_id_foreign` FOREIGN KEY (`property_id`) REFERENCES `property` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `property_place_photo_mapping_place_id_foreign` FOREIGN KEY (`place_id`) REFERENCES `property_place` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ;


        ") ;


    }
}
