<?php
declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

final class TaskSr49617 extends AbstractMigration
{
    public function up(): void
    {
        $this->execute(<<<SQL
        INSERT INTO atendimento.tipo_cancelamento (dt_criacao, id_usuario_criacao, id, ds_chave, ds_tipo_cancelamento) 
            VALUES (now(), 2068, 47, 'CANCELAMENTO_PROPOSTA_CORRETOR', 'Segurado desistiu do Seguro'),
                   (now(), 2068, 48, 'CANCELAMENTO_PROPOSTA_CORRETOR', 'Será refeita com correção/alteração'),
                   (now(), 2068, 49, 'CANCELAMENTO_PROPOSTA_CORRETOR', 'Seguro indevido'),
                   (now(), 2068, 50, 'CANCELAMENTO_PROPOSTA_CORRETOR', 'Seguro duplicado'),
                   (now(), 2068, 51, 'CANCELAMENTO_PROPOSTA_CORRETOR', 'Erro de transmissão'),
                   (now(), 2068, 52, 'CANCELAMENTO_PROPOSTA_CORRETOR', 'Falta de pagamento da 1ª parcela'),
                   (now(), 2068, 53, 'CANCELAMENTO_PROPOSTA_CORRETOR', 'Outro');
        SELECT setval('atendimento.tipo_cancelamento_id_seq', (select max(id) from atendimento.tipo_cancelamento), true);

        ALTER TABLE seguro.propostas_cancelamento ADD COLUMN ds_descricao VARCHAR(255);
SQL
        );
    }

    public function down(): void
    {
        $this->execute(<<<SQL
            ALTER TABLE seguro.propostas_cancelamento DROP COLUMN ds_descricao;
            DELETE FROM atendimento.tipo_cancelamento WHERE id IN (47, 48, 49, 50, 51, 52, 53);
            SELECT setval('atendimento.tipo_cancelamento_id_seq', (select max(id) from atendimento.tipo_cancelamento), true);
SQL
        );
    }
}
