init commit
All checks were successful
build-api-image / build (push) Successful in 51s

This commit is contained in:
Antonio Lopes dos Santos
2026-08-04 16:52:02 -03:00
commit afec302c3e
11594 changed files with 1636728 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCadastroMaterialBndasafTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cadastro_material_bndasaf', function (Blueprint $table) {
MigrationUtil::idWithoutIncrements($table);
$table->string('codigo', 15);
$table->string('descricao', 200);
$table->char('tipo', 1);
MigrationUtil::addCommonFields($table, ['staticData' => true]);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cadastro_material_bndasaf');
}
}

View File

@@ -0,0 +1,38 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCadastroVacinaTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cadastro_vacina', function (Blueprint $table) {
$table->id();
$table->integer('codigo')->nullable()->unique();
$table->string('nome', 300)->unique();
$table->string('abreviacao', 100);
$table->string('sigla', 100);
$table->boolean('calendario')->default(false);
MigrationUtil::addCommonFields($table);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cadastro_vacina');
}
}

View File

@@ -0,0 +1,27 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\Schema;
class RenameCadastroMaterialBndasaf extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::rename('cadastro_material_bndasaf', 'cadastro_material_bnafar');
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::rename('cadastro_material_bnafar', 'cadastro_material_bndasaf');
}
}

View File

@@ -0,0 +1,50 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCadastroEspecialidadeTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cadastro_especialidade', function (Blueprint $table) {
$table->id();
$table->string('nome', 100)->unique();
$table->foreignId('ocupacao_id')->constrained('sigtap.ocupacao');
$table->foreignId('sexo_id')->nullable()->constrained('cadastro_sexo');
$table->unsignedTinyInteger('idade_minima')->nullable();
$table->unsignedTinyInteger('idade_maxima')->nullable();
$table->boolean('tratamento')->default(false);
$table->boolean('encaminhamento')->default(false);
$table->boolean('permite_agendamento_mesmo_dia')->default(false);
$table->boolean('permite_agendamento_gestante')->default(false);
$table->boolean('permite_fechamento_sem_procedimento')->default(false);
$table->boolean('permite_agendamento_nao_municipe')->default(false);
$table->boolean('precisa_informar_conclusao_tratamento')->default(false);
$table->unsignedSmallInteger('limite_consulta')->nullable();
$table->unsignedSmallInteger('limite_consulta_mes')->nullable();
$table->string('procedimento_grupo_codigo', 10)->nullable();
$table->string('mensagem_protocolo_agendamento', 500)->nullable();
$table->boolean('ativo')->default(true);
MigrationUtil::addCommonFields($table);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cadastro_especialidade');
}
}

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class DropFieldsUniqueNumeroDeletedCadastroTituloEleitorTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('cadastro_titulo_eleitor', function (Blueprint $table) {
$table->dropUnique(['numero', 'deleted_at']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('cadastro_titulo_eleitor', function (Blueprint $table) {
$table->unique(['numero', 'deleted_at']);
});
}
}

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddCodigoRiaToCadastroVacinaTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('cadastro_vacina', function (Blueprint $table) {
$table->integer('codigo_ria')->nullable()->after('codigo');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('cadastro_vacina', function (Blueprint $table) {
$table->dropColumn('codigo_ria');
});
}
}

View File

@@ -0,0 +1,41 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCadastroUnidadeExecutanteManutencao extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cadastro_unidade_executante_manutencao', function (Blueprint $table) {
$table->id();
$table->foreignId('infraestrutura_id')->nullable()->constrained('cadastro_infraestrutura');
$table->foreignId('fornecedor_id')->nullable()->constrained('cadastro_fornecedor');
$table->foreignId('usuario_id')->nullable()->constrained('cadastro_usuario');
$table->boolean('status')->default(true);
$table->boolean('is_prestador')->default(false);
MigrationUtil::addCommonFields($table);
$table->unique('infraestrutura_id');
$table->unique('fornecedor_id');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cadastro_unidade_executante_manutencao');
}
}

View File

@@ -0,0 +1,41 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCadastroServicoManutencaoTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cadastro_servico_manutencao', function (Blueprint $table) {
$table->id();
$table->string('nome', 100)->unique();
$table->foreignId('grupo_id')->constrained('cadastro_grupo');
$table->foreignId('sub_grupo_id')->nullable()->constrained('cadastro_subgrupo');
$table->foreignId('prioridade_id')->nullable()->constrained('manutencao_parametrizacao_prioridade');
$table->boolean('is_agendamento_programado')->default(false);
$table->boolean('is_custo')->default(false);
$table->boolean('is_identifica_os_prestador')->default(false);
MigrationUtil::addCommonFields($table);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cadastro_servico_manutencao');
}
}

View File

@@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCadastroServicoManutencaoPrestadorFornecedorTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cadastro_servico_manutencao_prestador_fornecedor', function (Blueprint $table) {
$table->id();
$table->foreignId('servico_manutencao_id')->constrained('cadastro_servico_manutencao');
$table->foreignId('unidade_executante_manutencao_id')->constrained('cadastro_unidade_executante_manutencao');
MigrationUtil::addCommonFields($table);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cadastro_servico_manutencao_prestador_fornecedor');
}
}

View File

@@ -0,0 +1,38 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCadastroServicoManutencaoCausasProvaveis extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cadastro_servico_manutencao_causas_provaveis', function (Blueprint $table) {
$table->id();
$table->string('nome', 100);
$table->foreignId('servico_manutencao_id')->constrained('cadastro_servico_manutencao');
$table->string('observacao', 100)->nullable();
$table->unique(['nome', 'servico_manutencao_id']);
MigrationUtil::addCommonFields($table);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cadastro_servico_manutencao_causas_provaveis');
}
}

View File

@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddPpiFieldsToCadastroEspecialidadeTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('cadastro_especialidade', function (Blueprint $table) {
$table->boolean('is_ppi')->nullable()->afeter('atencao_basica_odontologico_conduta_id');
$table->decimal('valor_ppi', 8, 2)->nullable()->afeter('is_ppi');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('cadastro_especialidade', function (Blueprint $table) {
$table->dropColumn([
'is_ppi',
'valor_ppi',
]);
});
}
}

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddIdentificaItensAlmoxarifadoInCadastroServicoManutencaoTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('cadastro_servico_manutencao', function (Blueprint $table) {
$table->boolean('is_identifica_itens_almoxarifado')->default(false)->after('is_identifica_os_prestador');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('cadastro_servico_manutencao', function (Blueprint $table) {
$table->dropColumn('is_identifica_itens_almoxarifado');
});
}
}

View File

@@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCadastroSupervisorTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cadastro_supervisor', function (Blueprint $table) {
$table->id();
$table->foreignId('infraestrutura_id')->constrained('cadastro_infraestrutura');
$table->foreignId('usuario_id')->constrained('cadastro_usuario');
$table->unique(['infraestrutura_id', 'usuario_id']);
MigrationUtil::addCommonFields($table);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cadastro_supervisor');
}
}

View File

@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCadastroMaterialIntegracaoBnafarMedicamentoTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cadastro_material_integracao_bnafar_medicamento', function (Blueprint $table) {
$table->foreignId('material_id')->constrained('cadastro_material')->onDelete('cascade');
$table->foreignId('medicamento_id')->constrained('integracao_bnafar_medicamento')->onDelete('cascade');
$table->primary(['material_id', 'medicamento_id']);
MigrationUtil::addCommonFields($table);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cadastro_material_integracao_bnafar_medicamento');
}
}

View File

@@ -0,0 +1,45 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
class AddPrimaryKeyOnCadastroMaterialBnafarTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('cadastro_material', function (Blueprint $table) {
$table->dropForeign(['material_bnafar_id']);
});
DB::statement('ALTER TABLE cadastro_material_bnafar MODIFY id BIGINT UNSIGNED AUTO_INCREMENT');
Schema::table('cadastro_material', function (Blueprint $table) {
$table->foreign('material_bnafar_id')->references('id')->on('cadastro_material_bnafar');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('cadastro_material', function (Blueprint $table) {
$table->dropForeign(['material_bnafar_id']);
});
DB::statement('ALTER TABLE cadastro_material_bnafar MODIFY id BIGINT UNSIGNED');
Schema::table('cadastro_material', function (Blueprint $table) {
$table->foreign('material_bnafar_id')->references('id')->on('cadastro_material_bnafar');
});
}
}

View File

@@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
class AlterSizeOfCodigoOnCadastroMaterialBnafarTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('cadastro_material_bnafar', function (Blueprint $table) {
$table->string('codigo', 20)->change();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('cadastro_material_bnafar', function (Blueprint $table) {
$table->string('codigo', 15)->change();
});
}
}

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class DropUniqueNumeroDeletedAtOnCadastroCarteiraIdentidadeTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('cadastro_carteira_identidade', function (Blueprint $table) {
$table->dropUnique(['numero', 'deleted_at']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('cadastro_carteira_identidade', function (Blueprint $table) {
$table->unique(['numero', 'deleted_at']);
});
}
}

View File

@@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CadastroOrigemProgramaticaProgramaTipoTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cadastro_origem_programatica_programa_tipo', function (Blueprint $table) {
$table->id();
$table->string('nome', 100)->unique();
MigrationUtil::addCommonFields($table, ['staticData' => true]);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cadastro_origem_programatica_programa_tipo');
}
}

View File

@@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CadastroOrigemProgramaticaFornecimentoTipoTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cadastro_origem_programatica_fornecimento_tipo', function (Blueprint $table) {
$table->id();
$table->string('nome', 100)->unique();
MigrationUtil::addCommonFields($table, ['staticData' => true]);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cadastro_origem_programatica_fornecimento_tipo');
}
}

View File

@@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CadastroOrigemProgramaticaEstruturaApoioTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cadastro_origem_programatica_estrutura_apoio', function (Blueprint $table) {
$table->id();
$table->string('nome', 100)->unique();
MigrationUtil::addCommonFields($table, ['staticData' => true]);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cadastro_origem_programatica_estrutura_apoio');
}
}

View File

@@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CadastroOrigemProgramaticaTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cadastro_origem_programatica', function (Blueprint $table) {
$table->id();
$table->foreignId('programa_tipo_id')->constrained('cadastro_origem_programatica_programa_tipo');
$table->foreignId('fornecimento_tipo_id')->constrained('cadastro_origem_programatica_fornecimento_tipo');
$table->foreignId('estrutura_apoio_id')->constrained('cadastro_origem_programatica_estrutura_apoio');
$table->string('nome', 100)->unique();
$table->boolean('ativo')->default(true);
MigrationUtil::addCommonFields($table);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cadastro_origem_programatica');
}
}

View File

@@ -0,0 +1,41 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCadastroFeridaTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cadastro_ferida', function (Blueprint $table) {
$table->id();
$table->string('nome', 100);
$table->boolean('ativo')->default(true);
$table->text('observacao')->nullable();
MigrationUtil::addCommonFields($table, ['foreignNames' => [
'created_lotacao_id' => 'cadt_feri_crea_lota_id_foreign',
'updated_lotacao_id' => 'cadt_feri_upd_lota_id_foreign',
'created_centro_custo_id' => 'cadt_feri_cre_cen_cus_id_foreign',
'updated_centro_custo_id' => 'cadt_feri_upd_cen_cus_id_foreign',
]]);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cadastro_ferida');
}
}

View File

@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCadastroFeridaProcedimentoTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cadastro_ferida_procedimento', function (Blueprint $table) {
$table->id();
$table->foreignId('ferida_id')->nullable()->constrained('cadastro_ferida');
$table->foreignId('procedimento_id')->constrained('sigtap.procedimento');
MigrationUtil::addCommonFields($table);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cadastro_ferida_procedimento');
}
}

View File

@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCadastroLocalAnatomicoTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cadastro_local_anatomico', function (Blueprint $table) {
$table->id();
$table->string('descricao', 100)->unique();
MigrationUtil::addCommonFields($table, ['staticData' => true]);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cadastro_local_anatomico');
}
}

View File

@@ -0,0 +1,38 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCadastroLocalAnatomicoRegiaoTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cadastro_local_anatomico_regiao', function (Blueprint $table) {
$table->id();
$table->foreignId('local_anatomico_id')
->constrained('cadastro_local_anatomico')
->onDelete('cascade');
$table->string('key');
$table->string('descricao');
MigrationUtil::addCommonFields($table);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cadastro_local_anatomico_regiao');
}
}

View File

@@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCadastroFeridaExsudatoTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cadastro_ferida_exsudato', function (Blueprint $table) {
$table->id();
$table->string('descricao');
MigrationUtil::addCommonFields($table);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cadastro_ferida_exsudato');
}
}

View File

@@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCadastroFeridaNecroseTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cadastro_ferida_necrose', function (Blueprint $table) {
$table->id();
$table->string('descricao');
MigrationUtil::addCommonFields($table);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cadastro_ferida_necrose');
}
}

View File

@@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddIdentificadorExternoToCadastroFeridaTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('cadastro_ferida', function (Blueprint $table) {
$table
->string('identificador_externo', 64)
->nullable()
->after('ativo');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('cadastro_ferida', function (Blueprint $table) {
$table->dropColumn('identificador_externo');
});
}
}

View File

@@ -0,0 +1,40 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class MakeProcedimentoIdNullableInCadastroFeridaProcedimentoTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('cadastro_ferida_procedimento', function (Blueprint $table) {
$table
->unsignedBigInteger('procedimento_id')
->nullable()
->change();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('cadastro_ferida_procedimento', function (Blueprint $table) {
$table
->unsignedBigInteger('procedimento_id')
->nullable(false)
->change();
});
}
}

View File

@@ -0,0 +1,43 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddCidIdToCadastroFeridaTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('cadastro_ferida_procedimento', function (Blueprint $table) {
$table
->unsignedBigInteger('cid_id')
->nullable()
->after('procedimento_id');
$table
->foreign('cid_id')
->references('id')
->on('sigtap.cid');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('cadastro_ferida_procedimento', function (Blueprint $table) {
$table->dropForeign(['cid_id']);
$table->dropColumn('cid_id');
});
}
}

View File

@@ -0,0 +1,39 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddQuantidadeToCadastroFeridaProcedimentoTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('cadastro_ferida_procedimento', function (Blueprint $table) {
$table
->integer('quantidade')
->nullable()
->default(null)
->after('cid_id');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('cadastro_ferida_procedimento', function (Blueprint $table) {
$table
->dropColumn('quantidade');
});
}
}

View File

@@ -0,0 +1,48 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;
class AddAtivoAndNaoInformadoToLocalAnatomicoTables extends Migration
{
public function up()
{
Schema::table('cadastro_local_anatomico', function (Blueprint $table) {
$table->boolean('ativo')->default(true);
});
Schema::table('cadastro_local_anatomico_regiao', function (Blueprint $table) {
$table->boolean('ativo')->default(true);
});
$pais = DB::table('cadastro_local_anatomico')->pluck('id');
foreach ($pais as $localAnatomicoId) {
$exists = DB::table('cadastro_local_anatomico_regiao')
->where('local_anatomico_id', $localAnatomicoId)
->where('key', 'nao_informado')
->exists();
if (!$exists) {
DB::table('cadastro_local_anatomico_regiao')->insert([
'local_anatomico_id' => $localAnatomicoId,
'key' => 'nao_informado',
'descricao' => 'Não informado',
'ativo' => true,
'created_at' => now(),
'updated_at' => now(),
]);
}
}
}
public function down()
{
DB::table('cadastro_local_anatomico_regiao')
->where('key', 'nao_informado')
->delete();
Schema::table('cadastro_local_anatomico_regiao', function (Blueprint $table) {
$table->dropColumn('ativo');
});
Schema::table('cadastro_local_anatomico', function (Blueprint $table) {
$table->dropColumn('ativo');
});
}
}

View File

@@ -0,0 +1,174 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
class RestructureLocalAnatomicoTables extends Migration
{
public function up()
{
DB::statement('SET FOREIGN_KEY_CHECKS=0');
DB::table('cadastro_local_anatomico_regiao')->delete();
DB::table('cadastro_local_anatomico')->delete();
$macros = [
'Cabeça',
'Pescoço',
'Deltoide direito',
'Braço direito',
'Antebraço direito',
'Mão direita',
'Peito direito',
'Abdômen direito',
'Região Pubiana',
'Sacral',
'Coxa direita',
'Joelho direito',
'Tibial direita',
'Pé direito',
'Deltoide esquerdo',
'Braço esquerdo',
'Antebraço esquerdo',
'Mão esquerda',
'Peito esquerdo',
'Abdômen esquerdo',
'Coxa esquerda',
'Joelho esquerdo',
'Tibial esquerdo',
'Pé esquerdo',
'Trapézio direito',
'Glúteo direito',
'Poplítea direita',
'Panturrilha direita',
'Calcanhar direito',
'Trapézio esquerdo',
'Glúteo esquerdo',
'Poplítea esquerda',
'Panturrilha esquerda',
'Calcanhar esquerdo',
'Cabeça lateral',
'Pescoço lateral',
'Deltoide direito lateral',
'Braço direito lateral',
'Antebraço direito lateral',
'Mão direita lateral',
'Glúteo direito lateral',
'Coxa direita lateral',
'Tibial direita lateral',
'Pé direito lateral',
'Peito direito lateral',
'Abdômen direito lateral',
'Trocânter direito',
'Deltoide esquerdo lateral',
'Braço esquerdo lateral',
'Antebraço esquerdo lateral',
'Mão esquerda lateral',
'Glúteo esquerdo lateral',
'Coxa esquerda lateral',
'Tibial esquerda lateral',
'Pé esquerdo lateral',
'Peito esquerdo lateral',
'Abdômen esquerdo lateral',
'Trocânter esquerdo',
'Dorso direito',
'Dorso esquerdo'
];
foreach ($macros as $descricao) {
DB::table('cadastro_local_anatomico')->insert([
'descricao' => $descricao,
'ativo' => true,
'created_at' => now(),
'updated_at' => now(),
]);
}
$subparts = [
'Cabeça' => [
['key' => 'forehead', 'descricao' => 'Testa'],
['key' => 'nose', 'descricao' => 'Nariz'],
['key' => 'right_cheek', 'descricao' => 'Bochecha direita'],
['key' => 'left_cheek', 'descricao' => 'Bochecha esquerda'],
['key' => 'chin', 'descricao' => 'Queixo'],
],
'Mão direita' => [
['key' => 'pinky', 'descricao' => 'Mínimo'],
['key' => 'ring', 'descricao' => 'Anelar'],
['key' => 'middle', 'descricao' => 'Médio'],
['key' => 'index', 'descricao' => 'Indicador'],
['key' => 'thumb', 'descricao' => 'Polegar'],
['key' => 'palm', 'descricao' => 'Palma'],
],
'Mão esquerda' => [
['key' => 'pinky', 'descricao' => 'Mínimo'],
['key' => 'ring', 'descricao' => 'Anelar'],
['key' => 'middle', 'descricao' => 'Médio'],
['key' => 'index', 'descricao' => 'Indicador'],
['key' => 'thumb', 'descricao' => 'Polegar'],
['key' => 'palm', 'descricao' => 'Palma'],
],
'Pé direito' => [
['key' => 'toe_5', 'descricao' => 'Dedo 5'],
['key' => 'toe_4', 'descricao' => 'Dedo 4'],
['key' => 'toe_3', 'descricao' => 'Dedo 3'],
['key' => 'toe_2', 'descricao' => 'Dedo 2'],
['key' => 'toe_1', 'descricao' => 'Dedo 1'],
['key' => 'distal_forefoot', 'descricao' => 'Antepé Distal'],
['key' => 'distal_midfoot', 'descricao' => 'Médiope Distal'],
['key' => 'distal_hindfoot', 'descricao' => 'Retropé Distal'],
['key' => 'central_forefoot', 'descricao' => 'Antepé Central'],
['key' => 'central_midfoot', 'descricao' => 'Médiope Central'],
['key' => 'central_hindfoot', 'descricao' => 'Retropé Central'],
['key' => 'medial_forefoot', 'descricao' => 'Antepé Medial'],
['key' => 'medial_midfoot', 'descricao' => 'Médiope Medial'],
['key' => 'medial_hindfoot', 'descricao' => 'Retropé Medial'],
['key' => 'plantar_arch', 'descricao' => 'Arco Plantar'],
],
'Pé esquerdo' => [
['key' => 'toe_5', 'descricao' => 'Dedo 5'],
['key' => 'toe_4', 'descricao' => 'Dedo 4'],
['key' => 'toe_3', 'descricao' => 'Dedo 3'],
['key' => 'toe_2', 'descricao' => 'Dedo 2'],
['key' => 'toe_1', 'descricao' => 'Dedo 1'],
['key' => 'distal_forefoot', 'descricao' => 'Antepé Distal'],
['key' => 'distal_midfoot', 'descricao' => 'Médiope Distal'],
['key' => 'distal_hindfoot', 'descricao' => 'Retropé Distal'],
['key' => 'central_forefoot', 'descricao' => 'Antepé Central'],
['key' => 'central_midfoot', 'descricao' => 'Médiope Central'],
['key' => 'central_hindfoot', 'descricao' => 'Retropé Central'],
['key' => 'medial_forefoot', 'descricao' => 'Antepé Medial'],
['key' => 'medial_midfoot', 'descricao' => 'Médiope Medial'],
['key' => 'medial_hindfoot', 'descricao' => 'Retropé Medial'],
['key' => 'plantar_arch', 'descricao' => 'Arco Plantar'],
],
];
foreach ($subparts as $macroDescricao => $filhos) {
$macroId = DB::table('cadastro_local_anatomico')
->where('descricao', $macroDescricao)
->value('id');
if (!$macroId) {
continue;
}
foreach ($filhos as $filho) {
DB::table('cadastro_local_anatomico_regiao')->insert([
'local_anatomico_id' => $macroId,
'key' => $filho['key'],
'descricao' => $filho['descricao'],
'ativo' => true,
'created_at' => now(),
'updated_at' => now(),
]);
}
}
$todosMacros = DB::table('cadastro_local_anatomico')->pluck('id');
foreach ($todosMacros as $macroId) {
DB::table('cadastro_local_anatomico_regiao')->insert([
'local_anatomico_id' => $macroId,
'key' => 'nao_informado',
'descricao' => 'Não informado',
'ativo' => true,
'created_at' => now(),
'updated_at' => now(),
]);
}
DB::statement('SET FOREIGN_KEY_CHECKS=1');
}
public function down() {}
}

View File

@@ -0,0 +1,39 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddFieldPermiteIntegracaoConectasusCidadao extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('cadastro_especialidade', function (Blueprint $table) {
$table
->boolean('permite_integracao_conectasus_cidadao')
->nullable()
->default(false)
->after('precisa_informar_conclusao_tratamento');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('cadastro_especialidade', function (Blueprint $table) {
$table
->dropColumn('permite_integracao_conectasus_cidadao');
});
}
}

View File

@@ -0,0 +1,51 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddOcorrenciaFieldsToCadastroEspecialidadeTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('cadastro_especialidade', function (Blueprint $table) {
$table
->integer('limite_ocorrencias_paciente')
->nullable()
->after('valor_ppi');
$table
->integer('periodo_monitoramento')
->nullable()
->after('limite_ocorrencias_paciente');
$table
->integer('tempo_liberacao')
->nullable()
->after('periodo_monitoramento');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('cadastro_especialidade', function (Blueprint $table) {
$table->dropColumn([
'limite_ocorrencias_paciente',
'periodo_monitoramento',
'tempo_liberacao',
]);
});
}
}

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddTempoMedioPrevistoAtendimentoDiasToCadastroEspecialidadeTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('cadastro_especialidade', function (Blueprint $table) {
$table->integer('tempo_medio_previsto_atendimento_dias')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('cadastro_especialidade', function (Blueprint $table) {
$table->dropColumn('tempo_medio_previsto_atendimento_dias');
});
}
}

View File

@@ -0,0 +1,39 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddFieldPermiteIntegracaoAplicativoFeridas extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('cadastro_especialidade', function (Blueprint $table) {
$table
->boolean('permite_integracao_aplicativo_feridas')
->nullable()
->default(false)
->after('permite_integracao_conectasus_cidadao');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('cadastro_especialidade', function (Blueprint $table) {
$table
->dropColumn('permite_integracao_aplicativo_feridas');
});
}
}

View File

@@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateLogCadastroUnificacaoUsuarioPacienteTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('log_cadastro_unificacao_usuario_paciente', function (Blueprint $table) {
$table->id();
$table->json('dados');
\MigrationUtil::addCommonFields($table);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('log_cadastro_unificacao_usuario_paciente');
}
}

View File

@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCadastroUnidadeTipoTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cadastro_unidade_tipo', function (Blueprint $table) {
MigrationUtil::idWithoutIncrements($table);
$table->string('descricao');
$table->char('codigo', 2)->unique();
MigrationUtil::addCommonFields($table, ['staticData' => true]);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cadastro_unidade_tipo');
}
}

View File

@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCadastroEsferaAdministrativaTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cadastro_esfera_administrativa', function (Blueprint $table) {
MigrationUtil::idWithoutIncrements($table);
$table->string('descricao');
$table->char('codigo', 2)->unique();
MigrationUtil::addCommonFields($table, ['staticData' => true]);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cadastro_esfera_administrativa');
}
}

View File

@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCadastroSetorTipoTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cadastro_setor_tipo', function (Blueprint $table) {
MigrationUtil::idWithoutIncrements($table);
$table->string('nome', 180)->unique();
MigrationUtil::addCommonFields($table, ['staticData' => true]);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cadastro_setor_tipo');
}
}

View File

@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCadastroNaturezaJuridicaTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cadastro_natureza_juridica', function (Blueprint $table) {
MigrationUtil::idWithoutIncrements($table);
$table->string('descricao');
$table->char('codigo', 4)->unique();
MigrationUtil::addCommonFields($table, ['staticData' => true]);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cadastro_natureza_juridica');
}
}

View File

@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCadastroServicoTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cadastro_servico', function (Blueprint $table) {
MigrationUtil::idWithoutIncrements($table);
$table->string('nome', 100)->unique();
MigrationUtil::addCommonFields($table, ['staticData' => true]);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cadastro_servico');
}
}

View File

@@ -0,0 +1,39 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCadastroSetorTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cadastro_setor', function (Blueprint $table) {
$table->id();
$table->foreignId('tipo_id')->constrained('cadastro_setor_tipo');
$table->foreignId('servico_id')->nullable()->constrained('cadastro_servico');
$table->string('nome', 180);
MigrationUtil::addCommonFieldsWithSoftDeletes($table);
$table->unique(['servico_id', 'nome', 'deleted_at']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cadastro_setor');
}
}

View File

@@ -0,0 +1,47 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCadastroUnidadeTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cadastro_unidade', function (Blueprint $table) {
$table->id();
$table->string('nome_fantasia', 255);
$table->string('razao_social', 255);
$table->string('cnpj', 14);
$table->string('email', 180)->nullable();
$table->string('site', 180)->nullable();
$table->foreignId('tipo_id')->constrained('cadastro_unidade_tipo');
$table->foreignId('esfera_administrativa_id')->constrained('cadastro_esfera_administrativa');
$table->foreignId('natureza_juridica_id')->constrained('cadastro_natureza_juridica');
$table->foreignId('gestor_id')->constrained('cadastro_usuario');
$table->char('cnes', 7);
$table->boolean('pertence_sus')->default(true);
$table->boolean('unidade_referencia')->default(false);
MigrationUtil::addCommonFieldsWithSoftDeletes($table);
$table->unique(['cnes', 'deleted_at']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cadastro_unidade');
}
}

View File

@@ -0,0 +1,39 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCadastroInfraestruturaTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cadastro_infraestrutura', function (Blueprint $table) {
$table->id();
$table->foreignId('unidade_id')->constrained('cadastro_unidade');
$table->foreignId('endereco_id')->constrained('cadastro_endereco');
$table->string('nome', 255)->nullable();
$table->string('telefone', 11);
$table->boolean('principal');
$table->boolean('ativo')->default(true);
MigrationUtil::addCommonFieldsWithSoftDeletes($table);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cadastro_infraestrutura');
}
}

View File

@@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCadastroCentroCustoTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cadastro_centro_custo', function (Blueprint $table) {
$table->id();
$table->foreignId('infraestrutura_id')->constrained('cadastro_infraestrutura');
$table->foreignId('setor_id')->constrained('cadastro_setor');
MigrationUtil::addCommonFieldsWithSoftDeletes($table);
$table->unique(['infraestrutura_id', 'setor_id', 'deleted_at']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cadastro_centro_custo');
}
}

View File

@@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCadastroSalaTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cadastro_sala', function (Blueprint $table) {
$table->id();
$table->foreignId('centro_custo_id')->constrained('cadastro_centro_custo');
$table->string('nome', 30);
MigrationUtil::addCommonFieldsWithSoftDeletes($table);
$table->unique(['centro_custo_id', 'nome', 'deleted_at']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cadastro_sala');
}
}

View File

@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCadastroUnidadeExternaTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cadastro_unidade_externa', function (Blueprint $table) {
$table->id();
$table->string('nome_fantasia', 255);
$table->foreignId('municipio_id')->constrained('intranet.cadastro_municipio');
MigrationUtil::addCommonFieldsWithSoftDeletes($table);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cadastro_unidade_externa');
}
}

View File

@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AlterCnpjToNullableOnCadastroUnidadeTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('cadastro_unidade', function (Blueprint $table) {
$table->string('cnpj', 14)->nullable(true)->change();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('cadastro_unidade', function (Blueprint $table) {
$table->string('cnpj', 14)->nullable(false)->change();
});
}
}

View File

@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class SetServicoIdToNotNullOnCadastroSetor extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('cadastro_setor', function (Blueprint $table) {
$table->foreignId('servico_id')->nullable(false)->change();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('cadastro_setor', function (Blueprint $table) {
$table->foreignId('servico_id')->nullable(true)->change();
});
}
}

View File

@@ -0,0 +1,43 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
class SetCnesToNullableAndRemoveUniqueAtCadastroUnidade extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('cadastro_unidade', function (Blueprint $table) {
$table->string('cnes', 7)->nullable()->change();
$table->dropUnique(['cnes', 'deleted_at']);
$table->foreignId('gestor_id')->nullable()->change();
$table->boolean('unidade_prestadora')->default(false)->after('unidade_referencia');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
DB::table('cadastro_unidade')->whereNull('cnes')->update(['cnes' => '']);
Schema::table('cadastro_unidade', function (Blueprint $table) {
$table->string('cnes', 7)->default('')->change();
$table->unique(['cnes', 'deleted_at']);
$table->string('cnes', 7)->nullable(false)->change();
$table->dropForeign(['gestor_id']);
$table->foreignId('gestor_id')->nullable(false)->change()->constrained('cadastro_usuario');
$table->dropColumn('unidade_prestadora');
});
}
}

View File

@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddInfraestruturaIdToCadastroInfraestruturaTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('cadastro_infraestrutura', function (Blueprint $table) {
$table->foreignId('infraestrutura_id')->nullable()->after('id')->constrained('cadastro_infraestrutura');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('cadastro_infraestrutura', function (Blueprint $table) {
$table->dropConstrainedForeignId('infraestrutura_id');
});
}
}

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddAtivoToCadastroLotacaoTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('cadastro_lotacao', function (Blueprint $table) {
$table->boolean('ativo')->nullable()->after('realiza_atendimento')->default(true);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('cadastro_lotacao', function (Blueprint $table) {
$table->dropColumn('ativo');
});
}
}

View File

@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCadastroFabricanteTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cadastro_fabricante', function (Blueprint $table) {
$table->id();
$table->string('nome', 180);
$table->string('cnpj', 14);
MigrationUtil::addCommonFields($table);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cadastro_fabricante');
}
}

View File

@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCadastroFabricanteTipoTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cadastro_fabricante_tipo', function (Blueprint $table) {
MigrationUtil::idWithoutIncrements($table);
$table->string('nome', 20)->unique();
MigrationUtil::addCommonFields($table, ['staticData' => true]);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cadastro_fabricante_tipo');
}
}

View File

@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddTipoIdToCadastroFabricanteTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('cadastro_fabricante', function (Blueprint $table) {
$table->foreignId('tipo_id')->after('id')->constrained('cadastro_fabricante_tipo');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('cadastro_fabricante', function (Blueprint $table) {
MigrationUtil::dropColumnWithForeign($table, 'tipo_id');
});
}
}

View File

@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class SetCnpjToNullableAtCadastroFabricante extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('cadastro_fabricante', function (Blueprint $table) {
$table->string('cnpj', 14)->nullable()->change();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('cadastro_fabricante', function (Blueprint $table) {
$table->string('cnpj', 14)->nullable(false)->change();
});
}
}

View File

@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCadastroFeriadoTipoTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cadastro_feriado_tipo', function (Blueprint $table) {
MigrationUtil::idWithoutIncrements($table);
$table->string('descricao', 100);
MigrationUtil::addCommonFields($table, ['staticData' => true]);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cadastro_feriado_tipo');
}
}

View File

@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCadastroFeriadoTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cadastro_feriado', function (Blueprint $table) {
$table->id();
$table->foreignId('tipo_id')->constrained('cadastro_feriado_tipo');
$table->date('inicio')->nullable();
$table->text('observacao', 500)->nullable();
MigrationUtil::addCommonFieldsWithSoftDeletes($table);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cadastro_feriado');
}
}

View File

@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCadastroFeriadoModuloTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cadastro_feriado_modulo', function (Blueprint $table) {
$table->foreignId('feriado_id')->constrained('cadastro_feriado');
$table->foreignId('modulo_id')->constrained('administracao_modulo');
MigrationUtil::addCommonFieldsWithSoftDeletes($table);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cadastro_feriado_modulo');
}
}

View File

@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AlterDataOnCadastroFeriadoTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('cadastro_feriado', function (Blueprint $table) {
$table->renameColumn('inicio', 'data');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('cadastro_feriado', function (Blueprint $table) {
$table->renameColumn('data', 'inicio');
});
}
}

View File

@@ -0,0 +1,42 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddFieldsDiaMesAnoToCadastroFeriadoTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('cadastro_feriado', function (Blueprint $table) {
$table->dropColumn('data');
$table->string('ano', 10)->after('tipo_id')->nullable();
$table->integer('mes')->after('ano')->nullable();
$table->integer('dia')->after('mes')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('cadastro_feriado', function (Blueprint $table) {
$table->date('data')->nullable();
$table->dropColumn('ano');
$table->dropColumn('mes');
$table->dropColumn('dia');
});
}
}

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddDataToCadastroFeriadoTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('cadastro_feriado', function (Blueprint $table) {
$table->date('data')->after('tipo_id')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('cadastro_feriado', function (Blueprint $table) {
$table->dropColumn('data');
});
}
}

View File

@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
class UpdateDataToCadastroFeriadoTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
DB::table('cadastro_feriado')
->update([
'data' => DB::raw('CONCAT(ano, "-", mes, "-", dia)')
]);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
DB::table('cadastro_feriado')
->update([
'data' => null
]);
}
}

View File

@@ -0,0 +1,95 @@
<?php
use Carbon\Carbon;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
class UpdateAnoToCadastroFeriadoTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
$currentYear = Carbon::now()->year;
$feriadosSemAno = DB::table('cadastro_feriado')
->whereNull('ano')
->whereNotNull('mes')
->whereNotNull('dia')
->get();
foreach ($feriadosSemAno as $feriado) {
DB::table('cadastro_feriado')
->where('id', $feriado->id)
->update([
'ano' => $currentYear,
'data' => DB::raw('CONCAT(ano, "-", mes, "-", dia)')
]);
for ($i = 1; $i <= 10; $i++) {
$nextYear = $currentYear + $i;
$existingRecord = DB::table('cadastro_feriado')
->where('ano', $nextYear)
->where('mes', $feriado->mes)
->where('dia', $feriado->dia)
->exists();
if (!$existingRecord) {
$newFeriadoId = DB::table('cadastro_feriado')->insertGetId([
'ano' => $nextYear,
'mes' => $feriado->mes,
'dia' => $feriado->dia,
'tipo_id' => $feriado->tipo_id,
'observacao' => $feriado->observacao,
'data' => DB::raw("CONCAT($nextYear, '-', $feriado->mes, '-', $feriado->dia)")
]);
$modulosAssociados = DB::table('cadastro_feriado_modulo')
->where('feriado_id', $feriado->id)
->get();
foreach ($modulosAssociados as $modulo) {
DB::table('cadastro_feriado_modulo')->insert([
'feriado_id' => $newFeriadoId,
'modulo_id' => $modulo->modulo_id,
]);
}
}
}
}
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
$feriados = DB::table('cadastro_feriado')
->whereNull('created_at')
->get();
foreach ($feriados as $feriado) {
DB::table('cadastro_feriado_modulo')
->where('feriado_id', $feriado->id)
->delete();
}
DB::table('cadastro_feriado')
->whereNull('created_at')
->delete();
DB::table('cadastro_feriado')
->update([
'data' => null
]);
}
}

View File

@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCadastroFornecedorCategoriaTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cadastro_fornecedor_categoria', function (Blueprint $table) {
MigrationUtil::idWithoutIncrements($table);
$table->string('nome', 50)->unique();
MigrationUtil::addCommonFields($table, ['staticData' => true]);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cadastro_fornecedor_categoria');
}
}

View File

@@ -0,0 +1,40 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCadastroFornecedorTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cadastro_fornecedor', function (Blueprint $table) {
$table->id();
$table->string('cnpj', 14)->unique();
$table->string('inscricao_estadual', 14)->nullable()->unique();
$table->string('nome_fantasia', 255)->unique();
$table->string('razao_social', 255)->unique();
$table->foreignId('categoria_id')->nullable()->constrained('cadastro_fornecedor_categoria');
$table->string('site', 180)->nullable();
$table->foreignId('endereco_id')->nullable()->constrained('cadastro_endereco');
MigrationUtil::addCommonFields($table);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cadastro_fornecedor');
}
}

View File

@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCadastroFornecedorTelefoneTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cadastro_fornecedor_telefone', function (Blueprint $table) {
$table->id();
$table->foreignId('fornecedor_id')->constrained('cadastro_fornecedor')->onDelete('cascade');
$table->string('numero', 11);
$table->string('observacao', 50)->nullable();
MigrationUtil::addCommonFields($table);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cadastro_fornecedor_telefone');
}
}

View File

@@ -0,0 +1,39 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCadastroFornecedorContatoTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cadastro_fornecedor_contato', function (Blueprint $table) {
$table->id();
$table->foreignId('fornecedor_id')->constrained('cadastro_fornecedor')->onDelete('cascade');
$table->string('nome', 150);
$table->string('departamento', 50)->nullable();
$table->string('cargo', 50)->nullable();
$table->string('telefone', 11)->nullable();
$table->string('email', 180)->nullable();
MigrationUtil::addCommonFields($table);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cadastro_fornecedor_contato');
}
}

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class SetCnpjToNullableAtCadastroFornecedorTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('cadastro_fornecedor', function (Blueprint $table) {
$table->string('cnpj', 14)->nullable()->change();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('cadastro_fornecedor', function (Blueprint $table) {
$table->string('cnpj', 14)->nullable(false)->change();
});
}
}

View File

@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCadastroGrupoTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cadastro_grupo', function (Blueprint $table) {
$table->id();
$table->string('nome', 50);
MigrationUtil::addCommonFieldsWithSoftDeletes($table);
$table->unique(['nome', 'deleted_at']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cadastro_grupo');
}
}

View File

@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AlterLengthNomeFromCadastroGrupoTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('cadastro_grupo', function (Blueprint $table) {
$table->string('nome', 100)->change();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('cadastro_grupo', function (Blueprint $table) {
$table->string('nome', 50)->change();
});
}
}

View File

@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCadastroGrupoTipoTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cadastro_grupo_tipo', function (Blueprint $table) {
MigrationUtil::idWithoutIncrements($table);
$table->string('nome', 100);
MigrationUtil::addCommonFields($table, ['staticData' => true]);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cadastro_grupo_tipo');
}
}

View File

@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddGrupoTipoIdIntoCadastroGrupoTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('cadastro_grupo', function (Blueprint $table) {
$table->foreignId('grupo_tipo_id')->nullable()->constrained('cadastro_grupo_tipo');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('cadastro_grupo', function (Blueprint $table) {
MigrationUtil::dropColumnWithForeign($table, 'grupo_tipo_id');
});
}
}

View File

@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddImpressaoMapaProducaoToCadastroGrupoTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('cadastro_grupo', function (Blueprint $table) {
$table->boolean('impressao_mapa_producao')->default(false);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('cadastro_grupo', function (Blueprint $table) {
$table->dropColumn('impressao_mapa_producao');
});
}
}

View File

@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddRegulacaoTipoIdToCadastroGrupoTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('cadastro_grupo', function (Blueprint $table) {
$table->foreignId('regulacao_tipo_id')->nullable()->constrained('regulacao_tipo');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('cadastro_grupo', function (Blueprint $table) {
$table->dropConstrainedForeignId('regulacao_tipo_id');
});
}
}

View File

@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCadastroLogradouroTipoTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cadastro_logradouro_tipo', function (Blueprint $table) {
MigrationUtil::idWithoutIncrements($table);
$table->string('descricao', 25);
$table->char('codigo', 3)->unique();
MigrationUtil::addCommonFields($table, ['staticData' => true]);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cadastro_logradouro_tipo');
}
}

View File

@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCadastroBairroTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cadastro_bairro', function (Blueprint $table) {
$table->id();
$table->string('nome', 180);
MigrationUtil::addCommonFieldsWithSoftDeletes($table);
$table->unique(['nome', 'deleted_at']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cadastro_bairro');
}
}

View File

@@ -0,0 +1,40 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCadastroLogradouroTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cadastro_logradouro', function (Blueprint $table) {
$table->id();
$table->foreignId('municipio_id')->constrained('intranet.cadastro_municipio');
$table->foreignId('bairro_id')->constrained('cadastro_bairro');
$table->foreignId('tipo_id')->constrained('cadastro_logradouro_tipo');
$table->string('nome', 255);
$table->char('cep', 8)->nullable();
MigrationUtil::addCommonFieldsWithSoftDeletes($table);
$table->unique(['municipio_id', 'bairro_id', 'tipo_id', 'nome', 'deleted_at']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cadastro_logradouro');
}
}

View File

@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCadastroLoteamentoTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cadastro_loteamento', function (Blueprint $table) {
$table->id();
$table->string('nome', 80);
MigrationUtil::addCommonFieldsWithSoftDeletes($table);
$table->unique(['nome', 'deleted_at']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cadastro_loteamento');
}
}

View File

@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCadastroZonaTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cadastro_zona', function (Blueprint $table) {
MigrationUtil::idWithoutIncrements($table);
$table->string('descricao', 10);
MigrationUtil::addCommonFields($table, ['staticData' => true]);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cadastro_zona');
}
}

View File

@@ -0,0 +1,43 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCadastroEnderecoTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cadastro_endereco', function (Blueprint $table) {
$table->id();
$table->foreignId('logradouro_id')->constrained('cadastro_logradouro');
$table->unsignedInteger('numero')->nullable();
$table->string('complemento', 180)->nullable();
$table->string('latitude', 10)->nullable();
$table->string('longitude', 10)->nullable();
$table->string('referencia', 150)->nullable();
$table->foreignId('zona_id')->nullable()->constrained('cadastro_zona');
$table->foreignId('loteamento_id')->nullable()->constrained('cadastro_loteamento');
MigrationUtil::addCommonFieldsWithSoftDeletes($table);
$table->unique(['logradouro_id', 'numero', 'complemento', 'deleted_at']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cadastro_endereco');
}
}

View File

@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCadastroDomicilioTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cadastro_domicilio', function (Blueprint $table) {
$table->id();
$table->foreignId('endereco_id')->constrained('cadastro_endereco');
MigrationUtil::addCommonFieldsWithSoftDeletes($table);
$table->unique(['endereco_id', 'deleted_at']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cadastro_domicilio');
}
}

View File

@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AlterZonaIdToNotNullOnCadastroEndereco extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('cadastro_endereco', function (Blueprint $table) {
$table->foreignId('zona_id')->nullable(false)->change();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('cadastro_endereco', function (Blueprint $table) {
$table->foreignId('zona_id')->nullable(true)->change();
});
}
}

View File

@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class SetZonaIdToNullableOnCadastroEndereco extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('cadastro_endereco', function (Blueprint $table) {
$table->unsignedBigInteger('zona_id')->nullable()->change();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('cadastro_endereco', function (Blueprint $table) {
$table->unsignedBigInteger('zona_id')->nullable(false)->change();
});
}
}

View File

@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AlterSizeNomeOnCadastroLogradouro extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('cadastro_logradouro', function (Blueprint $table) {
$table->string('nome', 250)->change();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('cadastro_logradouro', function (Blueprint $table) {
$table->string('nome', 255)->change();
});
}
}

View File

@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AlterSizeNomeOnCadastroLoteamentoTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('cadastro_loteamento', function (Blueprint $table) {
$table->string('nome', 100)->change();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('cadastro_loteamento', function (Blueprint $table) {
$table->string('nome', 80)->change();
});
}
}

View File

@@ -0,0 +1,46 @@
<?php
use Doctrine\DBAL\Types\StringType;
use Doctrine\DBAL\Types\Type;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class SetCodigoToNullableOnCadastroLogradouroTipo extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('cadastro_logradouro_tipo', function (Blueprint $table) {
if (!Type::hasType('char')) {
Type::addType('char', StringType::class);
}
$table->char('codigo', 3)->nullable()->change();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('cadastro_logradouro_tipo', function (Blueprint $table) {
if (!Type::hasType('char')) {
Type::addType('char', StringType::class);
}
$table->char('codigo', 3)->nullable(false)->change();
});
}
}

View File

@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AlterSizeDescricaoOnCadastroLogradouroTipo extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('cadastro_logradouro_tipo', function (Blueprint $table) {
$table->string('descricao', 30)->change();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('cadastro_logradouro_tipo', function (Blueprint $table) {
$table->string('descricao', 25)->change();
});
}
}

View File

@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddCodigoEsusToCadastroZonaTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('cadastro_zona', function (Blueprint $table) {
$table->smallInteger('codigo_esus')->nullable()->after('descricao')->unique();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('cadastro_zona', function (Blueprint $table) {
$table->dropColumn(['codigo_esus']);
});
}
}

View File

@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCadastroLivroRegistroTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cadastro_livro_registro', function (Blueprint $table) {
MigrationUtil::idWithoutIncrements($table);
$table->string('nome', 100);
MigrationUtil::addCommonFields($table, ['staticData' => true]);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cadastro_livro_registro');
}
}

View File

@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCadastroLivroRegistroTipoTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cadastro_livro_registro_tipo', function (Blueprint $table) {
MigrationUtil::idWithoutIncrements($table);
$table->string('nome', 100);
MigrationUtil::addCommonFields($table, ['staticData' => true]);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cadastro_livro_registro_tipo');
}
}

View File

@@ -0,0 +1,54 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCadastroMaterialTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cadastro_material', function (Blueprint $table) {
$table->id();
$table->string('descricao', 100);
$table->string('codigo_material', 10)->nullable();
$table->foreignId('unidade_medida_id')->constrained('cadastro_unidade_medida');
$table->decimal('volume_unidade_medida')->nullable();
$table->foreignId('grupo_id')->constrained('cadastro_grupo');
$table->foreignId('subgrupo_id')->nullable()->constrained('cadastro_subgrupo');
$table->boolean('is_ativo')->default(true);
//Medicamento
$table->foreignId('receita_tipo_id')->nullable()->constrained('cadastro_receita_tipo');
$table->foreignId('livro_registro_id')->nullable()->constrained('cadastro_livro_registro');
$table->foreignId('livro_registro_tipo_id')->nullable()->constrained('cadastro_livro_registro_tipo');
$table->foreignId('forma_farmaceutica_id')->nullable()->constrained('cadastro_forma_farmaceutica');
$table->foreignId('via_administracao_id')->nullable()->constrained('cadastro_via_administracao');
$table->foreignId('material_bndasaf_id')->nullable()->constrained('cadastro_material_bndasaf');
$table->boolean('is_exibir_receita')->default(false);
$table->boolean('is_exibir_prescricao_interna')->default(false);
$table->boolean('is_alto_custo')->default(false);
$table->boolean('is_programa_remedio_em_casa')->default(false);
$table->boolean('is_acao_judicial')->default(false);
$table->boolean('is_remume')->default(false);
MigrationUtil::addCommonFieldsWithSoftDeletes($table);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cadastro_material');
}
}

View File

@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCadastroUnidadeApresentacaoTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cadastro_unidade_apresentacao', function (Blueprint $table) {
MigrationUtil::idWithoutIncrements($table);
$table->string('nome', 100)->unique();
$table->string('sigla', 10);
MigrationUtil::addCommonFields($table, ['staticData' => true]);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cadastro_unidade_apresentacao');
}
}

View File

@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddFieldUnidadeApresentacaoIdIntoCadastroMaterial extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('cadastro_material', function (Blueprint $table) {
$table->foreignId('unidade_apresentacao_id')
->after('codigo_material')
->constrained('cadastro_unidade_apresentacao');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('cadastro_material', function (Blueprint $table) {
MigrationUtil::dropColumnWithForeign($table, 'unidade_apresentacao_id');
});
}
}

View File

@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AlterFieldNameFromVolumeUnidadeMedidaToQuantidade extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('cadastro_material', function (Blueprint $table) {
$table->renameColumn('volume_unidade_medida', 'quantidade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('cadastro_material', function (Blueprint $table) {
$table->renameColumn('quantidade', 'volume_unidade_medida');
});
}
}

View File

@@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AlterTableNameFromCadastroUnidadeApresentacaoToCadastroApresentacao extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::rename('cadastro_unidade_apresentacao', 'cadastro_apresentacao');
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::rename('cadastro_apresentacao', 'cadastro_unidade_apresentacao');
}
}

View File

@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AlterFieldUnidadeApresentacaoIdFromCadastroMaterial extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('cadastro_material', function (Blueprint $table) {
$table->renameColumn('unidade_apresentacao_id', 'apresentacao_id');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('cadastro_material', function (Blueprint $table) {
$table->renameColumn('apresentacao_id', 'unidade_apresentacao_id');
});
}
}

View File

@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddPossuiLoteIntoCadastroMaterial extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('cadastro_material', function (Blueprint $table) {
$table->boolean('possui_lote')->default(false);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('cadastro_material', function (Blueprint $table) {
$table->dropColumn('possui_lote');
});
}
}

Some files were not shown because too many files have changed in this diff Show More