You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The migration files included in this are just examples. You should install them where ever you
41
41
point your $config["migrations_path"] to.
42
42
43
43
h3. Usage
44
44
45
-
$this->load->library('migrate');
46
-
$this->migration->set_verbose(TRUE); // echo statments or not
47
-
$this->migration->version(id); // migrate the database to a particular version
48
-
$this->migration->install(); // install to the latest version.
49
-
50
-
The dbmigreate.php controller just shows the use of these functions. If you are going to use it.
51
-
remove the 'die();' and put it back in place when you are done.
52
-
53
-
-** THE KICKER **-
54
-
-At the bottom of migreate.php we assume you are keeping track of your versions with a db table called config. Yes you can not use this migration script to create that table. You need at least one table installed to boot strap this. You will want to review the _update_schema_version() function to either modify or copy how it works.-
55
-
56
-
-Also, in our applcations we have this code to set our applcation configs. We do not believe in writting to the file system that is what a database is for :).-
45
+
$this->load->library('migrations');
46
+
$this->migrations->set_verbose(TRUE); // echo statments or not
47
+
$this->migrations->version(id); // migrate the database to a particular version
48
+
$this->migrations->install(); // install to the latest version.
57
49
50
+
The migreate.php controller just shows the use of these functions. If you are going to use it.
51
+
comment out the show_error() in the construct, and put it back in place when you are done.
52
+
58
53
-System configury code gone-
59
54
60
-
-In this code we set. $this->CI->config->item('migration_version'); and that is how _get_schema_version()
55
+
-In this code we set. $this->config->item('migration_version'); and that is how _get_schema_version()
61
56
gets the current version. This is the version this database is set too.-
62
57
63
-
** Suggestion **
64
-
We also do this on login to make sure this database is migrated to the version the config files wants it to be migrated too.
if ( ! $this->migration->version($this->config->item('migrations_version')))
60
+
{
69
61
show_error($this->migration->error);
70
-
62
+
}
71
63
72
64
Over all you should read this and http://codeigniter.com/wiki/Migrations to get an over all feel for this and make any changes
73
65
you need for your applcation.
74
-
75
66
76
67
Other Helpful Stuff:
77
68
78
-
Included in this git repo is an example system.php file. A way to have migrations run on every page load. You can copy it directly or use it as an example for your own code structure.
79
-
80
-
When you auto load the system.php lib this should be your order: $autoload['libraries'] = array('database', 'migrate', 'system', 'session');
69
+
Included in this git repo is an example CodeIgniter Hook and a basic config/hooks.php to show
70
+
how to enable it. This hook is one of several ways to have migrations run on every page load. You
71
+
could also place the code into a MY_Controller.
81
72
82
73
Here is a video walk through of migrations in action.
0 commit comments