<?php

use Phalcon\Mvc\Model\Migration;

class ProfilDaerahMigration_321 extends Migration
{
    public function up()
    {
        $this->down();

        $sql1 = file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'profil_daerah_audit_bpk.sql');
        self::$connection->execute($sql1);

        $sql2 = file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'profil_daerah_nilai_lakip.sql');
        self::$connection->execute($sql2);

        self::$connection->execute("
            CREATE TABLE IF NOT EXISTS jaga.kepala_daerah
            (
                id serial NOT NULL,
                tahun integer NOT NULL,
                nama_instansi character varying(100) NOT NULL,
                provinsi character varying(100),
                kabupaten character varying(100),
                nama character varying(100),
                jabatan character varying(100),
                PRIMARY KEY (id)
                )
                WITH (OIDS = FALSE);
        ");
    }

    public function down()
    {
        self::$connection->execute('
            DROP TABLE IF EXISTS "jaga"."profil_daerah_audit_bpk";
        ');

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

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