Ejemplo n.º 1
0
 public static function down($migrationsPath, $targetVersion = null)
 {
     $m = new SMigrator('down', $migrationsPath, $targetVersion);
     $m->executeMigration();
 }
Ejemplo n.º 2
0
<?php

define('APP_MODE', 'dev');
define('ROOT_DIR', str_replace('\\', '/', realpath(dirname(__FILE__) . '/../..')));
define('CORE_DIR', ROOT_DIR . '/core');
require_once CORE_DIR . '/common/common.php';
require_once CORE_DIR . '/cli/cli.php';
require_once CORE_DIR . '/model/model.php';
$options = SConsoleUtils::readOptions('v:', array('version='));
if (isset($options['version'])) {
    $version = $options['version'];
} elseif (isset($options['v'])) {
    $version = $options['v'];
} else {
    $version = null;
}
SMigrator::migrate(ROOT_DIR . '/db/migrate', $version);
Ejemplo n.º 3
0
 public function testMigratorGoingDownDueToVersionTarget()
 {
     SMigrator::up(dirname(__FILE__) . '/fixtures/migrate', 1);
     SMigrator::migrate(dirname(__FILE__) . '/fixtures/migrate', 0);
     $this->assertFalse(in_array('last_name', array_keys(SActiveRecord::connection()->columns('people'))));
     $this->assertFalse(SActiveStore::tableExists('reminders'));
     SMigrator::migrate(dirname(__FILE__) . '/fixtures/migrate');
     $this->assertEqual(2, SMigrator::currentVersion());
     SActiveStore::resetAttributeInformation('people');
     $this->assertTrue(in_array('last_name', array_keys(SActiveRecord::connection()->columns('people'))));
     $r = new Reminder(array('content' => 'hello world', 'remind_at' => SDateTime::today()));
     $r->save();
     $this->assertEqual('hello world', SActiveStore::findFirst('reminder')->content);
 }