<?php

use Phalcon\Mvc\Model\Migration;

class KorsupgahSubIndikatorMigration_187 extends Migration
{
    public function up()
    {
        self::$connection->execute("ALTER TABLE jaga.korsupgah_sub_indikator ADD COLUMN presentase_bobot INT");
        self::$connection->execute("ALTER TABLE jaga.korsupgah_sub_indikator ADD COLUMN id_tipe INT");

        $this->batchInsert('korsupgah_sub_indikator', [
            'id',
            'id_indikator',
            'nama',
            'presentase_bobot',
            'id_tipe'
        ]);

        self::$connection->execute("SELECT setval('korsupgah_sub_indikator_id_seq', (SELECT MAX(id) FROM jaga.korsupgah_sub_indikator));");
    }

    public function down()
    {
        self::$connection->execute("ALTER TABLE jaga.korsupgah_sub_indikator DROP COLUMN presentase_bobot");
        self::$connection->execute("ALTER TABLE jaga.korsupgah_sub_indikator DROP COLUMN id_tipe");
    }

}