<?php
declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

final class TaskSr47029 extends AbstractMigration
{
    public function up(): void
    {
        $row = $this->fetchRow('SELECT id FROM seguro.propostas WHERE id = 952416');
        if ($row['id']) {
            $table = $this->table('seguro.propostas_parcelas');
            $singleRow = [
                           'id_usuario_criacao'    => 2068
                         , 'dt_criacao'            => 'NOW()'
                         , 'id_proposta'           => 952416
                         , 'nr_parcela'            => 2
                         , 'vl_total'              => 382.59
                         , 'vl_segurado'           => 0.00
                         , 'vl_subvencao_federal'  => 382.59
                         , 'vl_subvencao_estadual' => 0.00
                         , 'dt_vencimento'         => '2024-07-29'
                         , 'fl_pago'               => 'FALSE'
                         , 'id_endosso'            => 754280
            ];
            $table->insert($singleRow)
                  ->saveData();
        }
    }

    public function down(): void
    {
        $row = $this->fetchRow('SELECT id FROM seguro.propostas WHERE id = 952416');
        if ($row['id']) {
            $delete = $this->getQueryBuilder();
            $delete->delete('seguro.propostas_parcelas')
               ->where([ 'id_proposta' => 952416
                       , 'nr_parcela'  => 2
                      ])
               ->execute();
        }
    }
}
