<?php

namespace OtomaticAi\Database\Migrations;

class AddCustomInstructionsToPersonaTableMigration extends Migration
{
    /**
     * Run a new migration
     *
     * @return void
     */
    public function run()
    {
        global $wpdb;

        if (!$this->canRun()) {
            return;
        }

        require_once(ABSPATH . 'wp-admin/includes/upgrade.php');

        $personas_table_name = $wpdb->prefix . "otomatic_ai_personas";

        $sql = "ALTER TABLE `{$personas_table_name}` ADD COLUMN `custom_instructions` longtext DEFAULT NULL AFTER `age`;";

        $wpdb->query($sql);
    }
}
