<?php
declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

final class TaskVsdV5 extends AbstractMigration
{
    public function up(): void
    {
        $table = $this->table('sistema.configuracao_sistema');
        $table->addColumn('ds_tipagem', 'string', ['limit' => 20, 'null' => true])
              ->save();

        $table = $this->table('sistema.configuracao_sistema');
        $singleRow = [
                       'id_usuario_criacao' => 2068
                     , 'dt_criacao' => 'NOW()'
                     , 'ds_nome' => 'VSD_ENCERRAMENTO_VISTORIA_AUTOMATICO'
                     , 'ds_valor' => '48'
                     , 'ds_tipagem' => 'INTEGER'
        ];
        $table->insert($singleRow)
              ->saveData();
    }

    public function down(): void
    {
        
        $delete = $this->getQueryBuilder();
        $delete->delete('sistema.configuracao_sistema')
               ->where(['ds_nome' => 'VSD_ENCERRAMENTO_VISTORIA_AUTOMATICO'])
               ->execute();

        $table = $this->table('sistema.configuracao_sistema');
        $table->removeColumn('ds_tipagem')
              ->save();
    }
}