public static function run() { \Config::load('migrations', true); $current_version = \Config::get('migrations.version'); // -v or --version $version = \Cli::option('v', \Cli::option('version')); // version is used as a flag, so show it if ($version === true) { \Cli::write('Currently on migration: ' . $current_version . '.', 'green'); return; } else { if (!is_null($version) and $version == $current_version) { throw new \Oil\Exception('Migration: ' . $version . ' already in use.'); return; } } $run = false; // Specific version if (is_numeric($version) and $version >= 0) { if (\Migrate::version($version) === false) { throw new \Oil\Exception('Migration ' . $version . ' could not be found.'); } else { static::_update_version($version); \Cli::write('Migrated to version: ' . $version . '.', 'green'); } } else { if (($result = \Migrate::latest()) === false) { throw new \Oil\Exception("Could not migrate to latest version, still using {$current_version}."); } else { static::_update_version($result); \Cli::write('Migrated to latest version: ' . $result . '.', 'green'); } } }
/** * Migrate modules writen in manifest.json * */ public function migrate_modules() { $manifest = json_decode(file_get_contents(DOCROOT . 'assets/modules/manifest.json')); foreach ($manifest->modules as $modul) { \Migrate::latest($modul, 'module'); } }
public function action_index() { \Migrate::latest(); $data['posts'] = Model_Post::find('all', array('order_by' => array('id' => 'desc'))); $data['title'] = 'IMAGEPLAY BBS'; $this->template->set_global($data); $this->template->content = View::forge('post/index', $data); }
public function action_upgrade() { $mig = \Migrate::latest(); $version = \Model_Version::find('last', array('order_by' => array('meta_update_time' => 'desc'))); Config::load('install', true); Config::set('install.version', $version['value']); Config::save('install', 'install'); echo json_encode(array('status' => true, 'ver' => $version['value'], 'dat' => Date('d/m/Y', $version['meta_update_time']))); }
public static function run() { // -v or --version $version = \Cli::option('v', \Cli::option('version')); $run = false; // Spoecific version if ($version > 0) { if (\Migrate::version($version) === false) { \Cli::write(\Cli::color('Already on migration: ' . $version . '.', 'light_red')); } else { static::_update_version($result); \Cli::write(\Cli::color('Migrated to version: ' . $version . '.', 'green')); } } else { if (($result = \Migrate::latest()) === false) { \Cli::write(\Cli::color('Already on latest migration.', 'light_red')); } else { static::_update_version($result); \Cli::write(\Cli::color('Migrated to latest version: ' . $result . '.', 'green')); } } }
/** * migrates to the latest version unless -version is specified * * @param string name of the type (in case of app, it's 'default') * @param string type (app, module or package) * @param string direction of migration (up or down) */ protected static function _run($name, $type) { // -v or --version $version = \Cli::option('v', \Cli::option('version', '')); // version is used as a flag, so show it if ($version === true) { \Cli::write('Currently installed migrations for ' . $type . ':' . $name . ':', 'green'); foreach (\Config::get('migrations.version.' . $type . '.' . $name, array()) as $version) { \Cli::write('- ' . $version); } return; } elseif ($version !== '') { // if version has a value, make sure only 1 item was passed if (static::$default + static::$module_count + static::$package_count > 1) { \Cli::write('Migration: version only accepts 1 item.'); return; } $migrations = \Migrate::version($version, $name, $type, \Cli::option('catchup', false)); } else { $migrations = \Migrate::latest($name, $type, \Cli::option('catchup', false)); } // any migrations executed? if ($migrations) { \Cli::write('Performed migrations for ' . $type . ':' . $name . ':', 'green'); foreach ($migrations as $migration) { \Cli::write($migration); } } else { if ($migrations === false) { \Cli::write('Some migrations where skipped for ' . $type . ':' . $name . '. Please re-run the migrations.', 'cyan'); } elseif ($version !== '') { \Cli::write('No migrations were found for ' . $type . ':' . $name . '.'); } else { \Cli::write('Already on the latest migration for ' . $type . ':' . $name . '.'); } } }
/** * Migrates to the latest version unless -version is specified * * @param string * @param string */ private static function _run($name, $type) { $current_version = \Config::get('migrations.version.' . $type . '.' . $name); if (!$current_version) { $current_version = 0; } // -v or --version $version = \Cli::option('v', \Cli::option('version')); // version is used as a flag, so show it if ($version === true) { \Cli::write('Currently on migration: ' . $current_version . ' for ' . $type . ':' . $name . '.', 'green'); return; } elseif (!is_null($version) and static::$default + static::$module_count + static::$package_count > 1) { \Cli::write('Migration: version only excepts 1 item.'); return; } elseif (!is_null($version) and $version == $current_version) { \Cli::write('Migration: ' . $version . ' already in use for ' . $type . ':' . $name . '.'); return; } $run = false; // Specific version if (is_numeric($version) and $version >= 0) { if (\Migrate::version($version, $name, $type) === false) { \Cli::write('Migration ' . $version . ' could not be found for ' . $type . ':' . $name . '.'); } else { static::_update_version($version, $name, $type); \Cli::write('Migrated ' . $type . ':' . $name . ' version: ' . $version . '.', 'green'); } } else { if (($result = \Migrate::latest($name, $type)) === false) { \Cli::write('Already on latest migration for ' . $type . ':' . $name . '.'); } else { static::_update_version($result, $name, $type); \Cli::write('Migrated ' . $type . ':' . $name . ' to latest version: ' . $result . '.', 'green'); } } }
/** Migrate all to lastest version * * @return boolean */ private function __migrate() { //migrate nucleus $this->_comet_echo('migrate', 'coredata'); $app = Migrate::latest('default', 'app'); //migrate moduels $mod = $this->__migrate_modules(); return ($app and $mod) ? true : false; }
protected function _install($data) { $this->_makeConfig($data); //load config data and connect to database $l = Config::load('install', true); $lastestVersion = Config::get('install.version'); $l = Config::load(Fuel::$env . '/db', null, true, true); Migrate::latest('default', 'app'); $this->_installDefaultUserInDb($data); $this->migrate_modules(); $this->__erase_old_migration(); $db_master = Model_Version::find()->limit(1)->order_by('id', 'desc')->get_one(); //set master on last $db_master->value = $lastestVersion; //set mode on last $db_master->mode = $lastestVersion; $db_master->save(); $data['instaled'] = true; $data['version'] = $db_master; return View::forge('install/version', $data); }