<?php

use Phalcon\Mvc\Model\Migration;

class KorwilTeamsMigration_234 extends Migration
{
    public function up()
    {
        self::$connection->execute('
            CREATE TABLE IF NOT EXISTS "jaga"."korwil_teams" (
                id serial primary key,
                name varchar(255) NOT NULL,
                description text,
                created_at timestamp(6) DEFAULT now(),
                updated_at timestamp(6) DEFAULT now(),
                deleted_at timestamp(6)
            );

            CREATE TABLE IF NOT EXISTS "jaga"."korwil_team_member_statuses" (
                id serial primary key,
                name varchar(255) NOT NULL,
                description text,
                created_at timestamp(6) DEFAULT now(),
                updated_at timestamp(6) DEFAULT now(),
                deleted_at timestamp(6)
            );

            CREATE TABLE IF NOT EXISTS "jaga"."korwil_team_user" (
                id serial primary key,
                team_id int NOT NULL,
                user_id int NOT NULL,
                team_member_status_id int NOT NULL,
                created_at timestamp(6) DEFAULT now(),
                updated_at timestamp(6) DEFAULT now(),
                deleted_at timestamp(6)
            );

            CREATE TABLE IF NOT EXISTS "jaga"."korwil_team_instansi" (
                id serial primary key,
                team_id int NOT NULL,
                instansi_id int NOT NULL,
                created_at timestamp(6) DEFAULT now(),
                updated_at timestamp(6) DEFAULT now(),
                deleted_at timestamp(6)
            );
        ');
    }
}
