<?php

use Phalcon\Mvc\Model\Migration;

class StranasSnapshotNotificationMigration_401 extends Migration {
    public function up() {
        self::$connection->execute("
            DROP TABLE IF EXISTS jaga.str_snapshot_notification;
            CREATE TABLE IF NOT EXISTS jaga.str_notification
            (
                id SERIAL primary key,
                id_periode integer NOT NULL,
                id_triwulan integer NOT NULL,
                created_by integer,
                created_at timestamp without time zone
            );

            CREATE TABLE IF NOT EXISTS jaga.str_notification_detail
            (
                id SERIAL primary key,
                id_notification integer NOT NULL,
                id_instansi integer NOT NULL,
                email character varying,
                success boolean,
                message character varying,
                CONSTRAINT str_notification_id_fkey
                    FOREIGN KEY (id_notification)
                        REFERENCES jaga.str_notification(id)
            )
        ");
    }

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