<?php

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

class EditPropertyChannel extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        DB::statement("

        ALTER TABLE `property_channel`
DROP COLUMN `type`,
CHANGE COLUMN `image` `logo` varchar(255) NULL DEFAULT NULL AFTER `currency_code`,
ADD COLUMN `official_name` varchar(255) NULL AFTER `name`,
MODIFY COLUMN `description` mediumtext  NULL AFTER `official_name`,
MODIFY COLUMN `country_code` varchar(5) NOT NULL AFTER `channel_category_id`,
ADD COLUMN `address` varchar(255) NULL AFTER `logo`,
ADD COLUMN `zip_code` varchar(255) NULL AFTER `address`,
ADD COLUMN `email` varchar(255) NOT NULL AFTER `zip_code`,
ADD COLUMN `phone` varchar(32) NOT NULL AFTER `email`,
ADD COLUMN `phone2` varchar(32) NULL AFTER `phone`,
ADD COLUMN `fax` varchar(32) NULL AFTER `phone2`,
ADD COLUMN `score` double(10, 2) NULL AFTER `fax`,
ADD FOREIGN KEY (`channel_category_id`) REFERENCES `property_channel_category` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
ADD FOREIGN KEY (`currency_code`) REFERENCES `currency` (`code`) ON DELETE RESTRICT ON UPDATE RESTRICT,
ADD FOREIGN KEY (`country_code`) REFERENCES `country` (`country_code`) ON DELETE RESTRICT ON UPDATE RESTRICT,
ADD FOREIGN KEY (`created_by`) REFERENCES `user` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
ADD FOREIGN KEY (`updated_by`) REFERENCES `user` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT;

        ");
    }

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