<?php

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

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

        DB::statement("DROP TABLE IF EXISTS `property_awards_certificate`;") ;
        DB::statement("DROP TABLE IF EXISTS `awards_certificate_category`;") ;
        DB::statement("CREATE TABLE `awards_certificate_category`  (
  `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `language_key` varchar(255) NULL DEFAULT NULL,
  `country_code` varchar(5) NOT NULL,
  `logo` varchar(255) NULL DEFAULT NULL,
  `type` varchar(3) NOT NULL COMMENT 'AWD,CRT',
  `status` tinyint(1) 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,
  INDEX `created_by`(`created_by`) USING BTREE,
  INDEX `updated_by`(`updated_by`) USING BTREE,
  INDEX `country_code`(`country_code`) USING BTREE,
  CONSTRAINT `awards_certificate_category_ibfk_1` FOREIGN KEY (`country_code`) REFERENCES `country` (`country_code`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `awards_certificate_category_ibfk_2` FOREIGN KEY (`created_by`) REFERENCES `user` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `awards_certificate_category_ibfk_3` FOREIGN KEY (`updated_by`) REFERENCES `user` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
)") ;
        DB::statement("INSERT INTO `awards_certificate_category` VALUES (1, 'ETBIS', NULL, 'tr', NULL, 'CRT', 1, 1, 1, 1, 1), (2, 'Güvenli Tatil Sertifikası Genel', NULL, 'tr', NULL, 'CRT', 1, 1, 1, 1, 1), (3, 'Booking.com', NULL, 'tr', NULL, 'CRT', 1, 1, 1, 1, 1);") ;
        DB::statement("CREATE TABLE `property_awards_certificate`  (
  `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `property_id` int(10) UNSIGNED NOT NULL,
  `category_id` int(10) UNSIGNED NOT NULL,
  `name` varchar(255) NULL DEFAULT NULL,
  `date` varchar(4) NULL DEFAULT NULL,
  `url` varchar(255) NULL DEFAULT NULL,
  `file_path` varchar(255) NULL DEFAULT NULL,
  `file_type` varchar(3) NULL DEFAULT NULL COMMENT 'IMG,PDF',
  `status` tinyint(1) 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,
  INDEX `property_id`(`property_id`) USING BTREE,
  INDEX `category_id`(`category_id`) USING BTREE,
  INDEX `created_by`(`created_by`) USING BTREE,
  INDEX `updated_by`(`updated_by`) USING BTREE,
  CONSTRAINT `property_awards_certificate_ibfk_1` FOREIGN KEY (`property_id`) REFERENCES `property` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `property_awards_certificate_ibfk_2` FOREIGN KEY (`category_id`) REFERENCES `awards_certificate_category` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `property_awards_certificate_ibfk_3` FOREIGN KEY (`created_by`) REFERENCES `user` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `property_awards_certificate_ibfk_4` FOREIGN KEY (`updated_by`) REFERENCES `user` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
)") ;



    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        //
    }
}
