<?php

use Phalcon\Mvc\Model\Migration;

class ScopeKorsupgahViewMigration_361 extends Migration
{
    public function up()
    {
        $this->down();

        self::$connection->execute("
            INSERT INTO jaga.scopes(name, label, description) VALUES ('korsupgah.view', 'Melihat MCP dan SPI', 'Melihat MCP dan SPI pada menu Korsupgah');
        ");

        self::$connection->execute("
            INSERT INTO jaga.roles_scopes(role_id, scope_id) values(
				(select id from jaga.roles where name = 'admin_klop_korsupgah'), (select id from jaga.scopes where name = 'korsupgah.view') 
				);
        ");
    }

    public function down()
    {
        self::$connection->execute("
            DELETE FROM jaga.roles_scopes WHERE 
            role_id = (select id from jaga.roles where name = 'admin_klop_korsupgah') 
            AND scope_id = (select id from jaga.scopes where name = 'korsupgah.view') 
				;
        ");

        self::$connection->execute("
            DELETE FROM jaga.scopes WHERE name = 'korsupgah.view';
        ");
    }
}