<?php
declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

final class TaskSr53687 extends AbstractMigration
{
    public function up(): void
    {
        
        $row = $this->fetchRow("SELECT id FROM sistema.acao WHERE ds_module = 'relatorio' and ds_controller = 'tecnica' and ds_action = 'endossosparcelas'");
        if ($row['id']) {
            $builder = $this->getQueryBuilder();
            $builder->update('sistema.acao')
                    ->set('ds_param', 'formsaframultiselect')
                    ->where(['id' => $row['id']])
                    ->execute();
        }

        $row = $this->fetchRow("SELECT id FROM sistema.acao WHERE ds_module = 'relatorio' and ds_controller = 'tecnica' and ds_action = 'historicostatus'");
        if ($row['id']) {
            $builder = $this->getQueryBuilder();
            $builder->update('sistema.acao')
                    ->set('ds_param', 'formsaframultiselect')
                    ->where(['id' => $row['id']])
                    ->execute();
        }

        $row = $this->fetchRow("SELECT id FROM sistema.acao WHERE ds_module = 'relatorio' and ds_controller = 'tecnica' and ds_action = 'prorrogacaoboletos'");
        if ($row['id']) {
            $builder = $this->getQueryBuilder();
            $builder->update('sistema.acao')
                    ->set('ds_param', 'formsaframultiselect')
                    ->where(['id' => $row['id']])
                    ->execute();
        }
    }

    public function down(): void
    {
        $row = $this->fetchRow("SELECT id FROM sistema.acao WHERE ds_module = 'relatorio' and ds_controller = 'tecnica' and ds_action = 'endossosparcelas'");
        if ($row['id']) {
            $builder = $this->getQueryBuilder();
            $builder->update('sistema.acao')
                    ->set('ds_param', 'formsafra')
                    ->where(['id' => $row['id']])
                    ->execute();
        }

        $row = $this->fetchRow("SELECT id FROM sistema.acao WHERE ds_module = 'relatorio' and ds_controller = 'tecnica' and ds_action = 'historicostatus'");
        if ($row['id']) {
            $builder = $this->getQueryBuilder();
            $builder->update('sistema.acao')
                    ->set('ds_param', 'formsafra')
                    ->where(['id' => $row['id']])
                    ->execute();
        }

        $row = $this->fetchRow("SELECT id FROM sistema.acao WHERE ds_module = 'relatorio' and ds_controller = 'tecnica' and ds_action = 'prorrogacaoboletos'");
        if ($row['id']) {
            $builder = $this->getQueryBuilder();
            $builder->update('sistema.acao')
                    ->set('ds_param', 'formsafra')
                    ->where(['id' => $row['id']])
                    ->execute();
        }
    }
}
