<?php

use Phalcon\Mvc\Model\Migration;

/**
 * Class RolesMigration_211
 */
class StranasPeriodeMigration_159 extends Migration
{
    public function up()
    {
        self::$connection->execute('
        CREATE TABLE jaga.stranas_periode (
            id serial PRIMARY KEY,
            nama varchar(255),
            keterangan text,
            started_at timestamp(6) NOT NULL,
            ended_at timestamp(6) NOT NULL,
            created_at timestamp(6) DEFAULT now(),
            updated_at timestamp(6) DEFAULT now(),
            deleted_at timestamp(6),
            created_by int,
            updated_by int
        )');

        $this->batchInsert('stranas_periode', [
            'id',
            'nama',
            'started_at',
            'ended_at'
        ]);

        self::$connection->execute("SELECT setval('stranas_periode_id_seq', (SELECT MAX(id) FROM jaga.stranas_periode));");
    }

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