Exemple #1
0
    /**
     * @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
		)');
    }
Exemple #2
0
 /**
  * @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;
 }
Exemple #3
0
 /**
  * @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] . '`');
     }
 }
Exemple #4
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);
 }
Exemple #5
0
 /**
  * @return Nano_Db
  */
 protected static function db()
 {
     return Nano_Db::instance();
 }
Exemple #6
0
 public function run(Nano_Db $db)
 {
     $db->exec('insert into migration_test(id, comment) values (301, ' . $db->quote('3rd migration script') . ')');
 }
Exemple #7
0
<?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');
Exemple #8
0
 public static function setDefault($name)
 {
     self::$default = $name;
 }
Exemple #9
0
 /**
  * @return Nano_Db
  * @param string $name
  */
 public static function db($name = null)
 {
     return Nano_Db::instance($name);
 }
Exemple #10
0
 protected function setVersion($name)
 {
     $this->db->insert(Nano_Migrate::VERSION_TABLE, array('version' => $name));
 }
Exemple #11
0
 protected function tearDown()
 {
     Nano_Db::clean();
     Nano_Db::close();
 }
Exemple #12
0
 protected function tearDown()
 {
     if ($this->clearDbAfterTest) {
         Nano_Db::clean();
     }
     if ($this->clearLogAfterTest) {
         Nano_Log::clear();
     }
     parent::tearDown();
 }
Exemple #13
0
<?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;
}
Exemple #14
0
 protected function tearDown()
 {
     Nano_Db::clean();
     TestDbTable1::dropTable();
     TestDbTable2::dropTable();
 }