fuel/fuel/core/classes/migrate.php
protected static function table_version_check()
	{
		// set connection
		static::$connection === null or \DBUtil::set_connection(static::$connection);

		// if table does not exist
		if ( ! \DBUtil::table_exists(static::$table))
		{
			// create table
			\DBUtil::create_table(static::$table, static::$table_definition);
		}

		// check if a table upgrade is needed
		elseif ( ! \DBUtil::field_exists(static::$table, array('migration')))
		{
			// get the current migration status
			$current = \DB::select()->from(static::$table)->order_by('type', 'ASC')->order_by('name', 'ASC')->execute(static::$connection)->as_array();

			// drop the existing table, and recreate it in the new layout
			\DBUtil::drop_table(static::$table);
			\DBUtil::create_table(static::$table, static::$table_definition);

			// check if we had a current migration status
			if ( ! empty($current))
			{
				// do we need to migrate from a v1.0 migration environment?
				if (isset($current[0]['current']))
				{
					// convert the current result into a v1.1. migration environment structure
					$current = array(0 => array('name' => 'default', 'type' => 'app', 'version' => $current[0]['current']));
				}

				// build a new config structure
				$configs = array();

				// convert the v1.1 structure to the v1.2 structure
				foreach ($current as $migration)
				{
					// find the migrations for this entry
					$migrations = static::find_migrations($migration['name'], $migration['type'], null, $migration['version']);

					// array to keep track of the migrations already run
					$config = array();

					// add the individual migrations found
					foreach ($migrations as $file)
					{
						$file = pathinfo($file['path']);

						// add this migration to the table
						\DB::insert(static::$table)->set(array(
							'name' => $migration['name'],
							'type' => $migration['type'],
							'migration' => $file['filename'],
						))->execute(static::$connection);

						// and to the config
						$config[] = $file['filename'];
					}

					// create a config entry for this name and type if needed
					isset($configs[$migration['type']]) or $configs[$migration['type']] = array();
					$configs[$migration['type']][$migration['name']] = $config;
				}

				// write the updated migrations config back
				\Config::set('migrations.version', $configs);
				\Config::save(\Fuel::$env.DS.'migrations', 'migrations');
			}

			// delete any old migration config file that may exist
			is_file(APPPATH.'config'.DS.'migrations.php') and unlink(APPPATH.'config'.DS.'migrations.php');
		}

		// set connection to default
		static::$connection === null or \DBUtil::set_connection(null);
	}
protected static function table_version_check()
	{
		// set connection
		static::$connection === null or \DBUtil::set_connection(static::$connection);

		// if table does not exist
		if ( ! \DBUtil::table_exists(static::$table))
		{
			// create table
			\DBUtil::create_table(static::$table, static::$table_definition);
		}

		// check if a table upgrade is needed
		elseif ( ! \DBUtil::field_exists(static::$table, array('migration')))
		{
			// get the current migration status
			$current = \DB::select()->from(static::$table)->order_by('type', 'ASC')->order_by('name', 'ASC')->execute(static::$connection)->as_array();

			// drop the existing table, and recreate it in the new layout
			\DBUtil::drop_table(static::$table);
			\DBUtil::create_table(static::$table, static::$table_definition);

			// check if we had a current migration status
			if ( ! empty($current))
			{
				// do we need to migrate from a v1.0 migration environment?
				if (isset($current[0]['current']))
				{
					// convert the current result into a v1.1. migration environment structure
					$current = array(0 => array('name' => 'default', 'type' => 'app', 'version' => $current[0]['current']));
				}

				// build a new config structure
				$configs = array();

				// convert the v1.1 structure to the v1.2 structure
				foreach ($current as $migration)
				{
					// find the migrations for this entry
					$migrations = static::find_migrations($migration['name'], $migration['type'], null, $migration['version']);

					// array to keep track of the migrations already run
					$config = array();

					// add the individual migrations found
					foreach ($migrations as $file)
					{
						$file = pathinfo($file['path']);

						// add this migration to the table
						\DB::insert(static::$table)->set(array(
							'name' => $migration['name'],
							'type' => $migration['type'],
							'migration' => $file['filename'],
						))->execute(static::$connection);

						// and to the config
						$config[] = $file['filename'];
					}

					// create a config entry for this name and type if needed
					isset($configs[$migration['type']]) or $configs[$migration['type']] = array();
					$configs[$migration['type']][$migration['name']] = $config;
				}

				// write the updated migrations config back
				\Config::set('migrations.version', $configs);
				\Config::save(\Fuel::$env.DS.'migrations', 'migrations');
			}

			// delete any old migration config file that may exist
			is_file(APPPATH.'config'.DS.'migrations.php') and unlink(APPPATH.'config'.DS.'migrations.php');
		}

		// set connection to default
		static::$connection === null or \DBUtil::set_connection(null);
	}
protected static function table_version_check ( ) { // set connection static :: $ connection === null or \ DBUtil :: set_connection ( static :: $ connection ) ; // if table does not exist if ( ! \ DBUtil :: table_exists ( static :: $ table ) ) { // create table \ DBUtil :: create_table ( static :: $ table , static :: $ table_definition ) ; } // check if a table upgrade is needed elseif ( ! \ DBUtil :: field_exists ( static :: $ table , array ( 'migration' ) ) ) { // get the current migration status $ current = \ DB :: select ( ) -> from ( static :: $ table ) -> order_by ( 'type' , 'ASC' ) -> order_by ( 'name' , 'ASC' ) -> execute ( static :: $ connection ) -> as_array ( ) ; // drop the existing table, and recreate it in the new layout \ DBUtil :: drop_table ( static :: $ table ) ; \ DBUtil :: create_table ( static :: $ table , static :: $ table_definition ) ; // check if we had a current migration status if ( ! empty ( $ current ) ) { // do we need to migrate from a v1.0 migration environment? if ( isset ( $ current [ 0 ] [ 'current' ] ) ) { // convert the current result into a v1.1. migration environment structure $ current = array ( 0 => array ( 'name' => 'default' , 'type' => 'app' , 'version' => $ current [ 0 ] [ 'current' ] ) ) ; } // build a new config structure $ configs = array ( ) ; // convert the v1.1 structure to the v1.2 structure foreach ( $ current as $ migration ) { // find the migrations for this entry $ migrations = static :: find_migrations ( $ migration [ 'name' ] , $ migration [ 'type' ] , null , $ migration [ 'version' ] ) ; // array to keep track of the migrations already run $ config = array ( ) ; // add the individual migrations found foreach ( $ migrations as $ file ) { $ file = pathinfo ( $ file [ 'path' ] ) ; // add this migration to the table \ DB :: insert ( static :: $ table ) -> set ( array ( 'name' => $ migration [ 'name' ] , 'type' => $ migration [ 'type' ] , 'migration' => $ file [ 'filename' ] , ) ) -> execute ( static :: $ connection ) ; // and to the config $ config [ ] = $ file [ 'filename' ] ; } // create a config entry for this name and type if needed isset ( $ configs [ $ migration [ 'type' ] ] ) or $ configs [ $ migration [ 'type' ] ] = array ( ) ; $ configs [ $ migration [ 'type' ] ] [ $ migration [ 'name' ] ] = $ config ; } // write the updated migrations config back \ Config :: set ( 'migrations.version' , $ configs ) ; \ Config :: save ( \ Fuel :: $ env . DS . 'migrations' , 'migrations' ) ; } // delete any old migration config file that may exist is_file ( APPPATH . 'config' . DS . 'migrations.php' ) and unlink ( APPPATH . 'config' . DS . 'migrations.php' ) ; } // set connection to default static :: $ connection === null or \ DBUtil :: set_connection ( null ) ; }
installs or upgrades the migration table to the current schema

@return	void

@deprecated	Remove upgrade check in 1.4
installs or upgrades the migration table to the current schema