From 11f58dcb887316f86e9e1f148355bf3a01ca1877 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 3 Jan 2014 13:57:58 +0200 Subject: [ci skip] Update the Migration library docs --- user_guide_src/source/libraries/migration.rst | 116 ++++++++++++++------------ 1 file changed, 62 insertions(+), 54 deletions(-) (limited to 'user_guide_src/source/libraries/migration.rst') diff --git a/user_guide_src/source/libraries/migration.rst b/user_guide_src/source/libraries/migration.rst index b734f5c34..a007d5be7 100644 --- a/user_guide_src/source/libraries/migration.rst +++ b/user_guide_src/source/libraries/migration.rst @@ -10,8 +10,8 @@ need to be run against the production machines next time you deploy. The database table **migration** tracks which migrations have already been run so all you have to do is update your application files and -call **$this->migration->current()** to work out which migrations should be run. -The current version is found in **config/migration.php**. +call ``$this->migration->current()`` to work out which migrations should be run. +The current version is found in **application/config/migration.php**. ******************** Migration file names @@ -28,23 +28,24 @@ method taken. Two numbering styles are available: helps prevent numbering conflicts when working in a team environment, and is the preferred scheme in CodeIgniter 3.0 and later. -The desired style may be selected using the **$config['migration_type']** -setting in your **migration.php** config file. +The desired style may be selected using the ``$config['migration_type']`` +setting in your *application/config/migration.php* file. Regardless of which numbering style you choose to use, prefix your migration files with the migration number followed by an underscore and a descriptive name for the migration. For example: -* **001_add_blog.php** (sequential numbering) -* **20121031100537_add_blog.php** (timestamp numbering) +* 001_add_blog.php (sequential numbering) +* 20121031100537_add_blog.php (timestamp numbering) ****************** Create a Migration ****************** This will be the first migration for a new site which has a blog. All -migrations go in the folder **application/migrations/** and have names such -as **20121031100537_add_blog.php**.:: +migrations go in the **application/migrations/** directory and have names such +as *20121031100537_add_blog.php*. +:: load->library('migration'); - - if ($this->migration->current() === FALSE) - { - show_error($this->migration->error_string()); - } - } - } - -****************** -Function Reference -****************** - -$this->migration->current() -============================ - -The current migration is whatever is set for **$config['migration_version']** in -**application/config/migration.php**. - -$this->migration->error_string() -================================= - -This returns a string of errors while performing a migration. - -$this->migration->find_migrations() -==================================== -An array of migration filenames are returned that are found in the **migration_path** -property. - -$this->migration->latest() -=========================== - -This works much the same way as current() but instead of looking for -the **$config['migration_version']** the Migration class will use the very -newest migration found in the filesystem. - -$this->migration->version() -============================ - -Version can be used to roll back changes or step forwards programmatically to -specific versions. It works just like current but ignores **$config['migration_version']**.:: + public function index() + { + $this->load->library('migration'); - $this->load->library('migration'); + if ($this->migration->current() === FALSE) + { + show_error($this->migration->error_string()); + } + } - $this->migration->version(5); + } ********************* Migration Preferences @@ -161,3 +126,46 @@ Preference Default Options Des **migration_type** 'timestamp' 'timestamp' / 'sequential' The type of numeric identifier used to name migration files. ========================== ====================== ========================== ============================================= + +*************** +Class Reference +*************** + +.. class:: CI_Migration + + .. method:: current() + + :returns: mixed + + Migrates up to the current version (whatever is set for ``$config['migration_version']`` in *application/config/migration.php*). + + .. method:: error_string() + + :returns: string + + This returns a string of errors that were detected while performing a migration. + + .. method:: find_migrations() + + :returns: array + + An array of migration filenames are returned that are found in the **migration_path** property. + + .. method:: latest() + + :returns: mixed + + This works much the same way as ``current()`` but instead of looking for + the ``$config['migration_version']`` the Migration class will use the very + newest migration found in the filesystem. + + .. method:: version($target_version) + + :param mixed $target_version: Migration version to process + :returns: mixed + + Version can be used to roll back changes or step forwards programmatically to + specific versions. It works just like ``current()`` but ignores ``$config['migration_version']``. + :: + + $this->migration->version(5); \ No newline at end of file -- cgit v1.2.3-24-g4f1b From cc042095bcce9856402cc04997f44310074716e0 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 3 Jan 2014 17:08:27 +0200 Subject: [ci skip] Some more generic user guide cleanup --- user_guide_src/source/libraries/migration.rst | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'user_guide_src/source/libraries/migration.rst') diff --git a/user_guide_src/source/libraries/migration.rst b/user_guide_src/source/libraries/migration.rst index a007d5be7..128796c4d 100644 --- a/user_guide_src/source/libraries/migration.rst +++ b/user_guide_src/source/libraries/migration.rst @@ -13,6 +13,13 @@ run so all you have to do is update your application files and call ``$this->migration->current()`` to work out which migrations should be run. The current version is found in **application/config/migration.php**. +.. contents:: + :local: + +.. raw:: html + +
+ ******************** Migration file names ******************** -- cgit v1.2.3-24-g4f1b From 28c2c975b118016d07212ed8e7c22ff280309f82 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 8 Feb 2014 04:27:48 +0200 Subject: [ci skip] Add return types to library docs --- user_guide_src/source/libraries/migration.rst | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'user_guide_src/source/libraries/migration.rst') diff --git a/user_guide_src/source/libraries/migration.rst b/user_guide_src/source/libraries/migration.rst index 4143609bb..e8ea1d977 100644 --- a/user_guide_src/source/libraries/migration.rst +++ b/user_guide_src/source/libraries/migration.rst @@ -142,25 +142,30 @@ Class Reference .. method:: current() - :returns: mixed + :returns: TRUE if no migrations are found, current version string on success, FALSE on failure + :rtype: mixed - Migrates up to the current version (whatever is set for ``$config['migration_version']`` in *application/config/migration.php*). + Migrates up to the current version (whatever is set for + ``$config['migration_version']`` in *application/config/migration.php*). .. method:: error_string() - :returns: string + :returns: Error messages + :rtype: string This returns a string of errors that were detected while performing a migration. .. method:: find_migrations() - :returns: array + :returns: An array of migration files + :rtype: array An array of migration filenames are returned that are found in the **migration_path** property. .. method:: latest() - :returns: mixed + :returns: TRUE if no migrations are found, current version string on success, FALSE on failure + :rtype: mixed This works much the same way as ``current()`` but instead of looking for the ``$config['migration_version']`` the Migration class will use the very @@ -168,11 +173,12 @@ Class Reference .. method:: version($target_version) - :param mixed $target_version: Migration version to process - :returns: mixed + :param mixed $target_version: Migration version to process + :returns: TRUE if no migrations are found, current version string on success, FALSE on failure + :rtype: mixed Version can be used to roll back changes or step forwards programmatically to specific versions. It works just like ``current()`` but ignores ``$config['migration_version']``. :: - $this->migration->version(5); + $this->migration->version(5); \ No newline at end of file -- cgit v1.2.3-24-g4f1b