<?php

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

class CreateTablePropertyWebMenu extends Migration
{

    public function up()
    {
       DB::statement("
           CREATE TABLE `property_web_menu` (
          `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
          `parent_id` int(10) unsigned DEFAULT NULL,
          `name` varchar(250) COLLATE utf8mb4_unicode_ci NOT NULL,
          `language_key` varchar(250) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
          `route` varchar(250) COLLATE utf8mb4_unicode_ci NOT NULL,
          `type` tinyint(3) NOT NULL DEFAULT '1',
          `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`),
          KEY `property_web_menu_parent_id_foreign` (`parent_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("
           CREATE TABLE `property_web_menu_mapping` (
          `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
          `property_id` int(10) unsigned NOT NULL,
          `property_web_id` bigint(20) unsigned NOT NULL,
          `property_web_menu_id` int(10) unsigned NOT NULL,
          `order_number` tinyint(4) NOT NULL DEFAULT '0',
          `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 ( `property_id` ) REFERENCES `property` ( `id` ) ON DELETE RESTRICT ON UPDATE RESTRICT,
          FOREIGN KEY ( `property_web_id` ) REFERENCES `property_web` ( `id` ) ON DELETE RESTRICT ON UPDATE RESTRICT,
          FOREIGN KEY ( `property_web_menu_id` ) REFERENCES `property_web_menu` ( `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
          )
       ");
    }


    public function down()
    {

    }
}
