public function run() { if (count($this->arguments) < 2) { $this->error("to few arguments."); $this->usage(); exit; } $this->defineEnvironment($this->arguments[0]); Sabel_Db_Config::initialize(new Config_Database()); $directory = $this->defineMigrationDirectory(); $connectionName = $this->connectionName = $this->getConnectionName(); $this->stmt = Sabel_Db::createStatement($connectionName); $this->metadata = Sabel_Db::createMetadata($connectionName); // @todo //if ($this->arguments[1] === "export") { // $this->export(); // self::$execFinalize = false; //} else { $tblName = $this->arguments[1]; $this->currentVersion = $this->getCurrentVersion(); if (in_array($tblName, array("-v", "--version"), true)) { $this->success("CURRENT VERSION: " . $this->currentVersion); exit; } else { $this->execMigration(); } //} }
public function run() { if (count($this->arguments) < 2) { $this->error("to few arguments."); $this->usage(); exit; } if (!defined('_LEGACY_PREVENT_LOAD_CORE_')) { define('_LEGACY_PREVENT_LOAD_CORE_', 'suin.asia'); require_once dirname(dirname(RUN_BASE)) . '/mainfile.php'; } $this->defineEnvironment($this->arguments[0]); Sabel_Db_Config::initialize(new Config_Database()); $directory = $this->defineMigrationDirectory(); $connectionName = $this->connectionName = $this->getConnectionName(); $this->stmt = Sabel_Db::createStatement($connectionName); $this->metadata = Sabel_Db::createMetadata($connectionName); // @todo //if ($this->arguments[1] === "export") { // $this->export(); // self::$execFinalize = false; //} else { $tblName = $this->arguments[1]; $this->currentVersion = $this->getCurrentVersion(); if (in_array($tblName, array("-v", "--version"), true)) { $this->success("CURRENT VERSION: " . $this->currentVersion); exit; } else { $this->execMigration(); } //} }
public function run() { clearstatcache(); $this->checkInputs(); $outputDir = RUN_BASE . DS . LIB_DIR_NAME . DS . "schema"; $this->defineEnvironment($this->arguments[0]); Sabel_Db_Config::initialize(new Config_Database()); $isAll = false; $tables = $this->getOutputTables(); if (isset($tables[0]) && strtolower($tables[0]) === "all") { $isAll = count($tables) === 1; } $tList = new TableListWriter($outputDir); foreach (Sabel_Db_Config::get() as $connectionName => $params) { Sabel_Db_Config::add($connectionName, $params); $db = Sabel_Db::createMetadata($connectionName); foreach ($db->getTableList() as $tblName) { if ($isAll || in_array($tblName, $tables, true)) { $writer = new Sabel_Db_Metadata_FileWriter($outputDir); $writer->write($db->getTable($tblName)); $this->success("generate Schema 'Schema_" . convert_to_modelname($tblName) . "'"); } $tList->add($connectionName, $tblName); } if (Sabel_Console::hasOption("l", $this->arguments)) { $tList->write($connectionName); } } }
public static function getTableList($connectionName = "default") { $className = "Schema_" . ucfirst($connectionName) . "TableList"; if (Sabel::using($className)) { $sc = new $className(); return $sc->get(); } else { return Sabel_Db::createMetadata($connectionName)->getTableList(); } }
equals($name->default, "default name"); isTrue($name->nullable); equals($name->max, 128); isTrue($test->isString()); isFalse($test->primary); isFalse($test->increment); isNull($test->default); isTrue($test->nullable); equals($test->max, 255); isTrue($body->isText()); isFalse($body->primary); isFalse($body->increment); isNull($body->default); isFalse($body->nullable); isTrue($bool->isBool()); isFalse($bool->primary); isFalse($bool->increment); isFalse($bool->default); isTrue($bool->nullable); isNull($hoge->ft); isNull($hoge->dbl); isNull($hoge->sint); isNull($hoge->bint); Sabel_Db_Connection::closeAll(); $path = RUN_BASE . "/migration/tmp/1_Hoge_create.php"; system("php exec.php {$path} " . CONNAME . " downgrade"); $accessor = Sabel_Db::createMetadata(CONNAME); $tables = $accessor->getTableList(); isFalse(in_array("hoge", $tables)); Sabel_Db_Connection::closeAll(); echo "\n";
<?php define("RUN_BASE", getcwd()); require_once "/usr/local/lib/php/Sabel/Sabel.php"; require_once RUN_BASE . "/config/INIT.php"; require_once RUN_BASE . "/config/environment.php"; $configs = array("sqlite" => array("package" => "sabel.db.pdo.sqlite", "database" => "/home/ebine/test.sq3"), "mysql" => array("package" => "sabel.db.mysql", "host" => "127.0.0.1", "database" => "sdb_test", "port" => "3306", "user" => "root", "password" => ""), "pgsql" => array("package" => "sabel.db.pgsql", "host" => "127.0.0.1", "database" => "sdb_test", "user" => "pgsql", "password" => "pgsql"), "oci" => array("package" => "sabel.db.oci", "host" => "127.0.0.1", "database" => "XE", "schema" => "DEVELOP", "user" => "DEVELOP", "password" => "DEVELOP")); foreach ($configs as $key => $param) { Sabel_Db_Config::add($key, $param); } $args = $_SERVER["argv"]; $path = $args[1]; $conName = $args[2]; $type = $args[3]; $schema = Sabel_Db::createMetadata($conName); $stmt = Sabel_Db::createStatement($conName); Sabel_Db_Migration_Manager::setSchema($schema); Sabel_Db_Migration_Manager::setStatement($stmt); Sabel_Db_Migration_Manager::setDirectory(RUN_BASE . "/migration/tmp"); Sabel_Db_Migration_Manager::setApplyMode($type); $dirs = explode(".", Sabel_Db_Config::getPackage($conName)); $className = implode("_", array_map("ucfirst", $dirs)) . "_Migration"; $mig = new $className(); $mig->execute($path);