<?php

use Phalcon\Mvc\Model\Migration;

class InsertRoleSpiMigration_553 extends Migration {
    public function up() {
        self::$connection->execute("
            insert into jaga.scopes (name, label, description) values ('spi.view_pemda_data', 'View data SPI Pemda', 'Hanya bisa lihat data Pemda');
            insert into jaga.roles (name, label, description) values ('spi_admin_pemda', 'Administrator SPI Pemda', 'Administrator SPI untuk data Pemda');
            insert into jaga.roles_scopes (role_id, scope_id) values ((select id from jaga.roles where name = 'spi_admin_pemda' limit 1), (select id from jaga.scopes where name = 'spi.view_pemda_data' limit 1));
        ");
    }

    public function down() {
        self::$connection->execute("
            delete from jaga.roles_scopes where role_id = (select id from jaga.roles where name = 'spi_admin_pemda' limit 1) and scope_id = (select id from jaga.scopes where name = 'spi.view_pemda_data' limit 1);
            delete from jaga.scopes where name = 'spi.view_pemda_data';
            delete from jaga.roles where name = 'spi_admin_pemda';
        ");
    }
}