<?php

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

class Update1556290634ResidentialComplexesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('residential_complexes', function (Blueprint $table) {
            if(Schema::hasColumn('residential_complexes', 'email')) {
                $table->dropColumn('email');
            }
            
        });
Schema::table('residential_complexes', function (Blueprint $table) {
            
if (!Schema::hasColumn('residential_complexes', 'code')) {
                $table->string('code')->nullable();
                }
if (!Schema::hasColumn('residential_complexes', 'enabled')) {
                $table->tinyInteger('enabled')->nullable()->default('1');
                }
if (!Schema::hasColumn('residential_complexes', 'date_putting_into_operation')) {
                $table->date('date_putting_into_operation')->nullable();
                }
if (!Schema::hasColumn('residential_complexes', 'room_count_date')) {
                $table->date('room_count_date')->nullable();
                }
if (!Schema::hasColumn('residential_complexes', 'latitude')) {
                $table->double('latitude', 19, 15)->nullable();
                }
if (!Schema::hasColumn('residential_complexes', 'longitude')) {
                $table->double('longitude', 19, 15)->nullable();
                }
if (!Schema::hasColumn('residential_complexes', 'location_address')) {
                $table->string('location_address')->nullable();
                $table->double('location_latitude')->nullable();
                $table->double('location_longitude')->nullable();
                }
        });

    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('residential_complexes', function (Blueprint $table) {
            $table->dropColumn('code');
            $table->dropColumn('enabled');
            $table->dropColumn('date_putting_into_operation');
            $table->dropColumn('room_count_date');
            $table->dropColumn('latitude');
            $table->dropColumn('longitude');
            $table->dropColumn('location_address');
            $table->dropColumn('location_latitude');
            $table->dropColumn('location_longitude');
            
        });
Schema::table('residential_complexes', function (Blueprint $table) {
                        $table->string('email')->nullable();
                
        });

    }
}
