<?php
declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

final class TaskInc44617V3 extends AbstractMigration
{
    public function up(): void
    {
        $row = $this->fetchRow('SELECT id FROM seguro.propostas WHERE id = 921327');
        if ($row['id']) {
            $table = $this->table('seguro.propostas_questionario');
            $singleRow = [
                           'id_usuario_criacao' => 2068
                         , 'dt_criacao' => 'NOW()'
                         , 'id_proposta' => 921327
                         , 'id_atributo_rn' => 177
                         , 'ds_resposta' => '95456248-40'
            ];
            $table->insert($singleRow)
                  ->saveData();
        }
    }

    public function down(): void
    {
        $row = $this->fetchRow('SELECT id FROM seguro.propostas WHERE id = 921327');
        if ($row['id']) {
            $delete = $this->getQueryBuilder();
            $delete->delete('seguro.propostas_questionario')
                   ->where([ 'id_usuario_criacao' => 2068
                            , 'id_proposta' => 921327
                            , 'id_atributo_rn' => 177
                            , 'ds_resposta' => '95456248-40'
                          ])
                   ->execute();
        }
    }
}
