<?php

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

class CreateSigelotesTable extends Migration {

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::create('sige.lotes', function(Blueprint $table)
		{
			$table->bigInteger('id', true);
			$table->decimal('area', 19, 4)->nullable();
			$table->boolean('ativo');
			$table->bigInteger('criado_por_id');
			$table->dateTime('dhc')->default('now()');
			$table->dateTime('dhm')->default('now()');
			$table->bigInteger('modificado_por_id');
			$table->bigInteger('municipio_id');
			$table->string('nome')->nullable();
			$table->string('numero', 25);
			$table->float('perimetro', 10, 0)->nullable();
			$table->string('proprietario')->nullable();
			$table->bigInteger('situacao_juridica_id');
			$table->string('titulo', 25)->nullable();
			$table->string('sncr')->nullable()->default('');
			$table->string('cpf')->nullable();
			$table->integer('protocolo')->nullable();
			$table->boolean('is_aprovado')->nullable();
			$table->string('data_termino_periodo_de_uso')->nullable();
			$table->string('status_estrutura')->nullable();
			$table->string('status_pessoa')->nullable();
			$table->string('status_uso')->nullable();
			$table->string('comunidade')->nullable();
			$table->string('localidade')->nullable();
			$table->boolean('projeto_especial')->nullable();
			$table->string('cnpj')->nullable();
			$table->string('status_titulo', 5)->nullable();
			$table->boolean('migrado_para_access')->nullable()->default(0);
			$table->integer('cod_imo_rur')->nullable();
			$table->unique(['municipio_id','numero'], 'lotes_municipio_id_numero_key');
		});
	}


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

}
