PHP Class CI_Migration, TastyIgniter

All migrations should implement this, forces up() and down() and gives access to the CI super-global.
Author: Reactor Engineers
ファイルを表示 Open project: tastyigniter/tastyigniter Class Usage Examples

Protected Properties

Property Type Description
$_error_string string Error message
$_migration_auto_latest boolean Whether to automatically run migrations
$_migration_enabled boolean Whether the library is enabled
$_migration_path string Path to migration classes
$_migration_regex string Migration basename regex
$_migration_table string Database table with migration info
$_migration_type boolean Migration numbering type
$_migration_version mixed Current migration version

Public Methods

Method Description
__construct ( array $config = [] ) : void Initialize Migration Class
__get ( string $var ) : mixed Enable the use of CI super-global
current ( ) : mixed Sets the schema to the migration version set in config
error_string ( ) : string Error string
find_migrations ( ) : array Retrieves list of available migration scripts
latest ( ) : mixed Sets the schema to the latest migration
version ( string $target_version ) : mixed Migrate to a schema version

Protected Methods

Method Description
_get_migration_name ( string $migration ) : string Extracts the migration class name from a filename
_get_migration_number ( string $migration ) : string Extracts the migration number from a filename
_get_version ( ) : string Retrieves current schema version
_update_version ( string $migration ) : void Stores the current schema version

Method Details

__construct() public method

Initialize Migration Class
public __construct ( array $config = [] ) : void
$config array
return void

__get() public method

Enable the use of CI super-global
public __get ( string $var ) : mixed
$var string
return mixed

_get_migration_name() protected method

Extracts the migration class name from a filename
protected _get_migration_name ( string $migration ) : string
$migration string
return string text portion of a migration filename

_get_migration_number() protected method

Extracts the migration number from a filename
protected _get_migration_number ( string $migration ) : string
$migration string
return string Numeric portion of a migration filename

_get_version() protected method

Retrieves current schema version
protected _get_version ( ) : string
return string Current migration version

_update_version() protected method

Stores the current schema version
protected _update_version ( string $migration ) : void
$migration string Migration reached
return void

current() public method

Sets the schema to the migration version set in config
public current ( ) : mixed
return mixed TRUE if no migrations are found, current version string on success, FALSE on failure

error_string() public method

Error string
public error_string ( ) : string
return string Error message returned as a string

find_migrations() public method

Retrieves list of available migration scripts
public find_migrations ( ) : array
return array list of migration file paths sorted by version

latest() public method

Sets the schema to the latest migration
public latest ( ) : mixed
return mixed Current version string on success, FALSE on failure

version() public method

Calls each migration step required to get to the schema version of choice
public version ( string $target_version ) : mixed
$target_version string Target schema version
return mixed TRUE if no migrations are found, current version string on success, FALSE on failure

Property Details

$_error_string protected_oe property

Error message
protected string $_error_string
return string

$_migration_auto_latest protected_oe property

Whether to automatically run migrations
protected bool $_migration_auto_latest
return boolean

$_migration_enabled protected_oe property

Whether the library is enabled
protected bool $_migration_enabled
return boolean

$_migration_path protected_oe property

Path to migration classes
protected string $_migration_path
return string

$_migration_regex protected_oe property

Migration basename regex
protected string $_migration_regex
return string

$_migration_table protected_oe property

Database table with migration info
protected string $_migration_table
return string

$_migration_type protected_oe property

Migration numbering type
protected bool $_migration_type
return boolean

$_migration_version protected_oe property

Current migration version
protected mixed $_migration_version
return mixed