<?php

use Phalcon\Mvc\Model\Migration;

class RolesScopesMigration_172 extends Migration
{
    /**
     * Define the table structure
     *
     * @return void
     */
    public function morph()
    { }

    /**
     * Run the migrations
     *
     * @return void
     */
    public function up()
    {

        $this->batchInsert('roles', [
            'id',
            'name',
            'label',
            'description'
        ]);

        $this->batchInsert('scopes', [
            'id',
            'name',
            'label',
            'description'
        ]);

        $this->batchInsert('roles_scopes', [
            'role_id',
            'scope_id'
        ]);

        self::$connection->execute("SELECT setval('roles_id_seq', (SELECT MAX(id) FROM roles));");
        self::$connection->execute("SELECT setval('scopes_id_seq', (SELECT MAX(id) FROM scopes));");
        self::$connection->execute("SELECT setval('roles_scopes_id_seq', (SELECT MAX(id) FROM roles_scopes));");
    }

    /**
     * Reverse the migrations
     *
     * @return void
     */
    public function down()
    { }
}
