You may wish to deliberately alter the database by pointing it to a specific migration number. This can be achieved by use of the version()
function within CodeIgniter.
Ensure that you have followed the preceding recipe, Using CodeIgniter database migrations.
Using your command line (terminal application), navigate to the root of your CodeIgniter installation (where the index.php file is) and type the following:
php index.php migrate version 1
Consider the following command line:
php index.php migrate version number
number
is highlighted as it specifies the migration file number to move to, that is, 1
, 2
, 3
, and so on.
The first thing we should bear in mind is the constructor in the migrate controller. The constructor is looking at how the migrate controller is accessed; it'll deny access to the migrate controller if it is accessed via anything other than the command line—a useful security measure.
By typing...