<?php
use Phalcon\Mvc\Model\Migration;

class CreateBudgetTargetBmdMigration_531 extends Migration {
    public function up()
    {
        self::$connection->execute("
            ALTER TABLE jaga.aset_sertifikasi
            DROP COLUMN IF EXISTS target,
            DROP COLUMN IF EXISTS anggaran
        ");

        self::$connection->execute('
            CREATE TABLE IF NOT EXISTS "jaga"."aset_sertifikasi_target" (
                id SERIAL PRIMARY KEY,
                instansi_id INTEGER,
                tahun INTEGER,
                target NUMERIC,
                anggaran NUMERIC,
                keterangan TEXT,
                created_by INTEGER,
                created_at TIMESTAMP(6) DEFAULT NOW(),
                updated_by INTEGER,
                updated_at TIMESTAMP(6),
                deleted_by INTEGER,
                deleted_at TIMESTAMP(6),
                attachment_uuid TEXT
            );
        ');
}

    public function down()
    {
        self::$connection->execute("
            ALTER TABLE jaga.aset_sertifikasi
            ADD COLUMN IF NOT EXISTS target numeric(18,2),
            ADD COLUMN IF NOT EXISTS anggaran numeric(18,2)
        ");

        self::$connection->execute("
            DROP TABLE IF EXISTS jaga.aset_sertifikasi_target;
        ");
    
    }
    
}
