<?php

if (!defined('BASEPATH')) {
    exit('No direct script access allowed');
}

/**
 * Upgrade ciext module to version 3.1.1
 *
 * @author Igor Ratsun
 */
class Ciext_upgrade_3_1_0 extends Abstract_upgrade
{

    protected $db;

    public function __construct()
    {
        $this->db = get_instance()->db;
    }

    public function up()
    {
        $check = $this->db->select('id_admin_menu, parent_id')->where([
                    'acl_resource' => 'system',
                    'acl_action'   => 'translate_manager',
                ])->get('admin_menu')->row_array();
        if (isset($check['parent_id']) && empty($check['parent_id'])) {
            $this->db->where('id_admin_menu', $check['id_admin_menu'])->update('admin_menu', ['parent_id' => 5]);
        }

        return '3.1.1';
    }

    public function down()
    {
        return '3.1.0';
    }

}
