public static function run() { $version = \Cli::option('v', \Cli::option('version')); if ($version > 0) { \Migrate::version($version); } else { \Migrate::current(); } }
/** * migrates item to current config version * * @param string name of the type (in case of app, it's 'default') * @param string type (app, module or package) */ protected static function _current($name, $type) { // -v or --version if (\Cli::option('v', \Cli::option('version', '')) !== '') { \Cli::write('You can not define a version when using the "current" command.', 'red'); } $migrations = \Migrate::current($name, $type); if ($migrations) { \Cli::write('Newly installed migrations for ' . $type . ':' . $name . ':', 'green'); foreach ($migrations as $migration) { \Cli::write('- ' . $migration); } } else { // migration is already on current version \Cli::write('Already on the current migration version for ' . $type . ':' . $name . '.'); } }
/** * Migrates item to current config verision * * @param string * @param string */ private static function _current($name, $type) { $version = \Migrate::current($name, $type); // if version is a number if (is_numeric($version)) { // show what version the item migrated to \Cli::write('Migrated to version: ' . $version . ' for ' . $type . ':' . $name . '.'); } else { // migration is already on current version \Cli::write('Already on current migration version for ' . $type . ':' . $name . '.'); } }
public static function current() { \Migrate::current(); }
public function create_tables() { if (file_exists(APPPATH . 'config/production/db.php') == true) { Log::error('shit worked!'); } // DBUtil::set_connection(null); if (DBUtil::table_exists('urls')) { if (DBUtil::field_exists('urls', array('time'))) { // Upgrade Me try { DBUtil::rename_table('urls', 'v2_urls'); DBUtil::rename_table('stats', 'v2_stats'); DBUtil::rename_table('settings', 'v2_settings'); } catch (\Database_Exception $e) { Log::error($e); } Controller_Install::create_tables(); } else { // Already Installed } } else { $oil_path = str_replace('public/', '', DOCROOT); try { @Migrate::current('default', 'app'); @Migrate::current('auth', 'package'); } catch (\Database_exception $e) { Debug::Dump('PLEASE REVISIT THIS /install (DONT RELOAD) THAT SHOULD INSTALL THE SCRIPT FOR YOU IF NOT THEN: Access has been denied for the database user , go to fuel/app/config/production/db.php , and edit your username and password!'); die; } try { \DBUtil::create_index('urls', 'short_url'); } catch (\Database_exception $e) { Log::error($e); } try { \DBUtil::create_index('urls', 'user_id'); } catch (\Database_exception $e) { Log::error($e); } try { \DBUtil::create_index('urls', array('id', 'short_url')); } catch (\Database_exception $e) { Log::error($e); } try { \DBUtil::create_index('urls', array('id', 'user_id')); } catch (\Database_exception $e) { Log::error($e); } try { \DBUtil::create_index('urls', array('id', 'short_url', 'user_id')); } catch (\Database_exception $e) { Log::error($e); } try { \DBUtil::create_index('url_stats', 'url_id'); } catch (\Database_exception $e) { Log::error($e); } try { \DBUtil::create_index('url_stats', 'country'); } catch (\Database_exception $e) { Log::error($e); } try { \DBUtil::create_index('url_stats', array('id', 'url_id')); } catch (\Database_exception $e) { Log::error($e); } try { \DBUtil::create_index('url_stats_countries', 'start_ip'); } catch (\Database_exception $e) { Log::error($e); } try { \DBUtil::create_index('url_stats_countries', 'end_ip'); } catch (\Database_exception $e) { Log::error($e); } try { \DBUtil::create_index('url_stats_countries', 'country'); } catch (\Database_exception $e) { Log::error($e); } try { \DBUtil::create_index('url_stats_countries', array('start_ip', 'end_ip')); } catch (\Database_exception $e) { Log::error($e); } try { \DBUtil::create_index('url_stats_countries', array('start_ip', 'end_ip', 'country')); } catch (\Database_exception $e) { Log::error($e); } try { \DBUtil::modify_fields('urls', array('url' => array('constraint' => 255, 'type' => 'varchar'))); } catch (\Database_exception $e) { Log::error($e); } } return true; }