<?php

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

class CreateRegionsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('regions', function (Blueprint $table) {
            $table->id();

            $table->foreignId('city_id')
                ->nullable()
                ->constrained('cities','id')
                ->onDelete('SET NULL');

            $table->string('name',255);
            $table->string('slug',255)->unique();
            $table->enum('status',\Mehrab\Region\Models\Region::$status)->default(\Mehrab\Region\Models\Region::ACTIVE);
            $table->float('priority')->nullable();
            $table->timestamps();

            $table->engine == 'InnoDB';
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('regions');
    }
}
