<?php
declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

final class Task2112021221 extends AbstractMigration
{
    public function up(): void
    {
        $this->execute("CREATE TABLE manutencao.ajuste_recadastro_corretores(
                            id_corretor     INTEGER,
                            id_status       INTEGER,
                            dt_manutencao   TIMESTAMP
                        )
                      ");
        
        $this->execute("INSERT
                          INTO manutencao.ajuste_recadastro_corretores
                             ( id_corretor
                             , id_status
                             , dt_manutencao
                             )
                        SELECT id
                             , id_status
                             , NOW() AS dt_manutencao
                          FROM sistema.corretores
                         WHERE id IN (
                                     272, 414, 327, 334, 452, 196, 394, 474, 363, 426, 412,  10, 556, 513,   4,  13, 510, 444,   5,  15,
                                     476, 301, 493,  17, 565, 494, 563, 427, 229, 447, 345, 390, 330, 439, 367, 403, 212, 528, 415, 365,
                                     446,  23, 375, 500, 509, 545, 320, 450, 475, 354, 548,  45, 470, 306, 473, 319, 407, 429, 377, 425,
                                     496, 537, 523, 443,  50, 466, 353, 404, 406, 454,  51, 364, 423,  38, 204, 566, 218, 489, 179, 264, 573,
                                     374, 275, 547, 239, 456, 497, 419, 391, 325, 484, 518,  62, 507, 366, 441,  65, 442, 482, 431, 553, 328,
                                     438, 402, 255, 544, 302, 486, 561, 525, 570,  72, 529, 464, 465, 197, 265, 347, 433, 451,  67, 240, 251,
                                     397,  75, 554,  82, 459, 413, 564, 567, 533, 543, 313, 368, 546,  80, 186, 242, 531, 379, 549, 409, 392,
                                     498, 448,  92, 532,  94, 235,  96, 422, 514, 485, 572,  66, 101, 271, 393, 104, 436, 505, 103, 351, 114,
                                     488, 504, 538, 108, 521, 109, 217, 118, 256, 184, 400, 194, 113, 449, 511, 568, 307, 369, 534,  56,
                                     562, 321, 356, 282, 571, 569, 123, 288, 221, 124, 495, 408, 130, 244, 266, 424, 455, 126, 191, 516, 462,
                                     135, 224, 432, 517, 141, 298, 559, 267, 437, 457, 343, 287, 520, 252, 499, 501, 355, 276, 526, 399, 246,
                                     257, 541, 472, 230, 228, 269, 290, 428, 285, 348, 340, 155, 145, 435, 362, 458, 281, 551, 303, 147, 148,
                                     519, 542, 157, 467, 411, 159, 361, 161, 445, 164, 165, 506, 522, 190, 258, 508, 214, 166, 167, 555, 380,
                                     357, 552, 420, 421, 410, 335, 344, 173, 430, 416, 263, 398, 309, 524, 395, 463, 560, 461, 175, 478, 440,
                                     231, 515, 527, 453, 502, 178
                                     );
                      ");
        
        $this->execute("UPDATE sistema.corretores
                           SET id_status = 267
                         WHERE id_status IN (264, 265, 266, 268)
                           AND id IN (
                                     272, 414, 327, 334, 452, 196, 394, 474, 363, 426, 412,  10, 556, 513,   4,  13, 510, 444,   5,  15,
                                     476, 301, 493,  17, 565, 494, 563, 427, 229, 447, 345, 390, 330, 439, 367, 403, 212, 528, 415, 365,
                                     446,  23, 375, 500, 509, 545, 320, 450, 475, 354, 548,  45, 470, 306, 473, 319, 407, 429, 377, 425,
                                     496, 537, 523, 443,  50, 466, 353, 404, 406, 454,  51, 364, 423,  38, 204, 566, 218, 489, 179, 264, 573,
                                     374, 275, 547, 239, 456, 497, 419, 391, 325, 484, 518,  62, 507, 366, 441,  65, 442, 482, 431, 553, 328,
                                     438, 402, 255, 544, 302, 486, 561, 525, 570,  72, 529, 464, 465, 197, 265, 347, 433, 451,  67, 240, 251,
                                     397,  75, 554,  82, 459, 413, 564, 567, 533, 543, 313, 368, 546,  80, 186, 242, 531, 379, 549, 409, 392,
                                     498, 448,  92, 532,  94, 235,  96, 422, 514, 485, 572,  66, 101, 271, 393, 104, 436, 505, 103, 351, 114,
                                     488, 504, 538, 108, 521, 109, 217, 118, 256, 184, 400, 194, 113, 449, 511, 568, 307, 369, 534,  56,
                                     562, 321, 356, 282, 571, 569, 123, 288, 221, 124, 495, 408, 130, 244, 266, 424, 455, 126, 191, 516, 462,
                                     135, 224, 432, 517, 141, 298, 559, 267, 437, 457, 343, 287, 520, 252, 499, 501, 355, 276, 526, 399, 246,
                                     257, 541, 472, 230, 228, 269, 290, 428, 285, 348, 340, 155, 145, 435, 362, 458, 281, 551, 303, 147, 148,
                                     519, 542, 157, 467, 411, 159, 361, 161, 445, 164, 165, 506, 522, 190, 258, 508, 214, 166, 167, 555, 380,
                                     357, 552, 420, 421, 410, 335, 344, 173, 430, 416, 263, 398, 309, 524, 395, 463, 560, 461, 175, 478, 440,
                                     231, 515, 527, 453, 502, 178
                                     );
                     ");
    }

    public function down(): void
    {

    }
}
