Inheritance: extends CI_Controller
Exemplo n.º 1
0
 /**
  * {@inheritDoc}
  * @see \ColdTrick\EntityTools\Migrate::changeContainer()
  */
 public function changeContainer($new_container_guid)
 {
     // do all the default stuff
     parent::changeContainer($new_container_guid);
     // move all subpages to the new container
     $this->moveSubpages($new_container_guid);
 }
Exemplo n.º 2
0
 /**
  * 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');
     }
 }
Exemplo n.º 3
0
 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);
 }
Exemplo n.º 4
0
 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'])));
 }
Exemplo n.º 5
0
 /**
  * migrates item down to the given version
  *
  * @param string
  * @param string
  */
 protected static function _down($name, $type)
 {
     // -v or --version
     $version = \Cli::option('v', \Cli::option('version', null));
     // if version has a value, make sure only 1 item was passed
     if ($version and static::$default + static::$module_count + static::$package_count > 1) {
         \Cli::write('Migration: version only accepts 1 item.');
         return;
     }
     $migrations = \Migrate::down($version, $name, $type);
     if ($migrations) {
         \Cli::write('Reverted migrations for ' . $type . ':' . $name . ':', 'green');
         foreach ($migrations as $migration) {
             \Cli::write('- ' . $migration);
         }
     } else {
         // there is no 'down'...
         \Cli::write('There are no migrations installed to revert for ' . $type . ':' . $name . '.');
     }
 }
Exemplo n.º 6
0
 /**
  * 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 . '.');
     }
 }
Exemplo n.º 7
0
 public static function current()
 {
     \Migrate::current();
 }
Exemplo n.º 8
0
 /**
  * Resets the application database structure and content.
  *
  * @return void
  */
 public static function reset()
 {
     // Revert to app default (sans migrations).
     \Migrate::version(0);
     \Cli::write('Database Reset', 'green');
     $migration_config = APPPATH . DS . 'config' . DS . 'development' . DS . 'migrations.php';
     if (file_exists($migration_config)) {
         \File::delete($migration_config);
         \Cli::write('Migration Config Removed', 'green');
     }
     // Truncate sessions table.
     \Oil\Refine::run('session:clear');
     // Rerun setup.
     \Oil\Refine::run('setup');
 }
Exemplo n.º 9
0
 /** 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;
 }
Exemplo n.º 10
0
 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);
 }
Exemplo n.º 11
0
<?php

//its in a class because I already had the code that way and I din't feel like extracting it.
$migration = new Migrate();
$migration->printQueries();
class Migrate
{
    public function printQueries()
    {
        $this->printAddProcedures();
        $queries = array();
        $queries = array_merge($queries, $this->getDropTriggers());
        $queries = array_merge($queries, $this->getDropForeignKeys());
        $queries = array_merge($queries, $this->getDropIndexes());
        $queries = array_merge($queries, $this->getDropKeys());
        $queries = array_merge($queries, $this->getDropPrimaryKeys());
        $queries = array_merge($queries, $this->getChangeEngine());
        $queries = array_merge($queries, $this->getChangeCharset());
        $queries = array_merge($queries, $this->getAddColumns());
        $queries = array_merge($queries, $this->getColumnChanges());
        $queries = array_merge($queries, $this->getDropTables());
        $queries = array_merge($queries, $this->getDropColumns());
        $queries = array_merge($queries, $this->getAddPrimaryKeys());
        $queries = array_merge($queries, $this->getAddIndexes());
        $queries = array_merge($queries, $this->getAddForeignKeys());
        foreach ($queries as $sql) {
            print $sql . ";\n";
        }
        $this->printDropProcedures();
    }
    protected function printAddProcedures()
 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;
 }
Exemplo n.º 13
0
	public static function install()
	{
		\Migrate::install();
	}