<?php

use Phalcon\Mvc\Model\Migration;
class LogModerationMigration_407 extends Migration
{
    public function up()
    {
        self::$connection->execute("
            DROP TABLE IF EXISTS jaga.log_moderation;
            CREATE TABLE jaga.log_moderation (
                id bigserial primary key,
                action character varying(100) NOT NULL,
                action_menu character varying(100) NOT NULL,
                ref_table character varying(100) NOT NULL,
                ref_id bigint NOT NULL,
                data_from text NOT NULL,
                data_to text NOT NULL,
                moderated_by integer NOT NULL,
                moderated_at timestamp(6) DEFAULT now()
            );
        ");

        self::$connection->execute("
            CREATE INDEX IF NOT EXISTS log_moderation_ref_id ON log_moderation USING btree (ref_id);
            CREATE INDEX IF NOT EXISTS log_moderation_moderated_by ON log_moderation USING btree (moderated_by);
            CREATE INDEX IF NOT EXISTS log_moderation_moderated_at ON log_moderation USING btree (moderated_at);
        ");
    }

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