<?php
namespace nur\m\pdo\mysql;

use nur\m\cli\UpdateMigrationsApp;

class MysqlUpdateMigrationsApp extends UpdateMigrationsApp {
  protected function migrate(array $params) {
    $class = $params["class"];
    $overwrite = $params["overwrite"];
    $verbose = $params["verbose"];
    $basedir = $params["basedir"];
    if ($params["do_sql"]) {
      MysqlMigrations::gensql($class, [
        "overwrite" => $overwrite,
        "verbose" => $verbose,
        "destdir" => "$basedir/$params[sql_dir]",
        "prefix" => $params["sql_prefix"],
        "trace" => [$this, "trace"],
      ]);
    }
    if ($params["do_class"]) {
      MysqlMigrations::genclass($class, [
        "overwrite" => $overwrite,
        "verbose" => $verbose,
        "destdir" => "$basedir/$params[class_dir]",
        "package" => $params["class_package"],
        "baserow" => $params["class_baserow"],
        "trace" => [$this, "trace"],
      ]);
    }
    if ($params["do_doc"]) {
      MysqlMigrations::gendoc($class, [
        "overwrite" => $overwrite,
        "verbose" => $verbose,
        "destdir" => "$basedir/$params[doc_dir]",
        "trace" => [$this, "trace"],
      ]);
    }
  }
}
