<?php

namespace ZenoChatbot\Hooks\Handler\Plugin;

use ZenoChatbot\Framework\Database\Migration\Migrator;
use ZenoChatbot\Hooks\Handler\BaseHandler;

class UpgradeHandler extends BaseHandler
{
    public function handle(...$args)
    {

        $installedVersion = get_option( 'zeno_chatbot_database_version', '1.0.0');

        if ( version_compare( $installedVersion, '1.1.0', '<' ) ) {
            try {
                Migrator::migrate($this->app->basePath('database/migrations'));
                update_option( 'zeno_chatbot_database_version', '1.1.0' );
            } catch (\Exception $e) {
                return;
            }

        }
    }
}
