<?php

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

class CreateTableWebLanguageMappingWebColorMappingMenuSorting extends Migration
{

    public function up()
    {
        DB::statement("
           CREATE TABLE `property_web_language_mapping` (
          `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
          `property_id` int(10) unsigned NOT NULL,
          `property_web_id` bigint(20) unsigned NOT NULL,
          `language_code` varchar(10) COLLATE utf8mb4_unicode_ci 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`),
          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 ( `language_code` ) REFERENCES `language` ( `code` ) 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_web_color_mapping` (
          `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
          `property_id` int(10) unsigned NOT NULL,
          `property_web_id` bigint(20) unsigned NOT NULL,
          `color_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci 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 ( `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('UPDATE `property_web_menu` SET `order_number` = 0, `status` = 0  WHERE id = 5;');
        DB::statement('UPDATE `property_web_menu` SET `order_number` = 5 WHERE id = 6;');

    }


    public function down()
    {

    }
}
