<?php

use Phalcon\Mvc\Model\Migration;

class CreateLogAttachmentsMigration_535 extends Migration {
    public function up()
    {
        self::$connection->execute("
            CREATE TABLE IF NOT EXISTS jaga.log_attachments (
                source_name character varying (10) not null,
                bucket_name character varying (100) not null,
                key_path character varying (255) not null,
                status character varying (10) not null,
                modul_name character varying (100),
                created_at timestamp without time zone not null default now()
            );
            CREATE INDEX IF NOT EXISTS log_attachments_status_idx ON log_attachments USING btree (status);
            CREATE INDEX IF NOT EXISTS log_attachments_modul_name_idx ON log_attachments USING btree (modul_name);
            CREATE INDEX IF NOT EXISTS log_attachments_created_at_idx ON log_attachments USING btree (created_at);
        ");
    }

    public function down()
    {
        self::$connection->execute("
            DROP INDEX IF EXISTS log_attachments_status_idx;
            DROP INDEX IF EXISTS log_attachments_modul_name_idx;
            DROP INDEX IF EXISTS log_attachments_created_at_idx;
            DROP TABLE IF EXISTS jaga.log_attachments;
        ");
    }
}
