/** * @return void * @param Nano_Db $db */ public static function sqlite(Nano_Db $db) { $db->exec('create table ' . Nano_Migrate::VERSION_TABLE . '( id integer not null primary key , version text )'); }
/** * @return string[] * @param Nano_Db $db * @param boolean $force */ public static function getAll(Nano_Db $db, $force = false) { if (null === self::$versions || true === $force) { self::$versions = $db->getAssoc('select version, id from ' . Nano_Migrate::VERSION_TABLE); } return self::$versions; }
/** * @return voud * @param Nano_Db $db */ public static function clean(Nano_Db $db) { $tables = $db->query('show tables', PDO::FETCH_NUM); foreach ($tables as $row) { if (Nano_Migrate::VERSION_TABLE === $row[0]) { continue; } $db->query('truncate table `' . $row[0] . '`'); } }
/** * @return void * @param Nano_Db $db */ public function run(Nano_Db $db) { $this->load(); foreach ($this->queries as $query) { $db->query($query); } $this->getScript()->run($db); unset($this->queries); unset($this->script); }
/** * @return Nano_Db */ protected static function db() { return Nano_Db::instance(); }
public function run(Nano_Db $db) { $db->exec('insert into migration_test(id, comment) values (301, ' . $db->quote('3rd migration script') . ')'); }
<?php error_reporting(E_ALL); ini_set('error_log', dirName(__FILE__) . '/reports/error.log'); define('TESTING', true); require dirName(__FILE__) . '/../library/Nano.php'; Nano::instance(); Nano::config('selenium'); Nano_Db::setDefault('test');
public static function setDefault($name) { self::$default = $name; }
/** * @return Nano_Db * @param string $name */ public static function db($name = null) { return Nano_Db::instance($name); }
protected function setVersion($name) { $this->db->insert(Nano_Migrate::VERSION_TABLE, array('version' => $name)); }
protected function tearDown() { Nano_Db::clean(); Nano_Db::close(); }
protected function tearDown() { if ($this->clearDbAfterTest) { Nano_Db::clean(); } if ($this->clearLogAfterTest) { Nano_Log::clear(); } parent::tearDown(); }
<?php require dirName(__DIR__) . '/library/Nano.php'; Nano::instance(); $db = isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : Nano_Db::DEFAULT_NAME; try { Nano_Db::setDefault($db); $migration = new Nano_Migrate(); $migration->run(); } catch (Exception $e) { echo $e; }
protected function tearDown() { Nano_Db::clean(); TestDbTable1::dropTable(); TestDbTable2::dropTable(); }