Migrations are a convenient way for you to alter your database in a structured and organized manner. You **could** edit fragments of SQL by hand but you would then be responsible for telling other developers that they need to go and run them and where they are located.
__dbforge()__ loaded by the migration class, can be used to create and delete tables
- __active record__ can be used to do simple updates/deletes
- __log_message()__ to log changes made to the database (console app in mac to watch)
- ect..
## Configuration
> Migrations are disabled by default
Migrations are managed via the migrations file:
application/config/migrations.php
There are two settings of importance
$config['migration_enabled'] = FALSE;
$config['migration_version'] = 0;
**migration_enabled** switches database migrations on or off and the **migration_version** identifies the migration version this installation should use when triggered (see Updates and Rollbacks)
> While **migration_version** lists the target migration version, the current migration version is managed in the the *migrations.version* field in the database. The Migration system automatically version up() or down() based on the version differences -- **WHEN TRIGGERED**!
## Updates and Rollbacks
Check out my custom `migrate` controller, it provides 4 operations
| Method | Description |
|:--------|:------------|
| migrate/current | brings database to current version listed in config |
| migrate/ | alias for _migrate/current/__ |
| migrate/version/[num] | migrates to [num] revision passed in |
| migrate/latest | ignores config, and updates to latest migration file |
### Usage
Usage is _really_ split between to groups, __developers__ and __deployments__.
##### Developers Workflow
Developers should _NOT_ modify
config/migrations.php
Instead, developers should manage their local database via
- _migrate/latest_ to load the latest migration file on their system
- or _migrate/version/[num]_ to go to a migration version to test
##### Deployment Workflow
When setting up a deployment, the _config/migrations.php_ would be modified to reflect the version you want that deployment set to:
$config['migration_version'] = 121; //used migration version
and then run
migrate/current
---
> There currently is no UI, however one could be build based on the return values of the _migrate_ methods.