Use migration to update database structure in more systematic way. For CI version 3.x
Setting up
- Create migration directory – application/migrations
- Update setting application/config/migration.php
- set $config[‘migration_type’] = ‘sequential’
- Create table “migrations” in database. With 1 field named “version” of type INT(11)
- Add controller “Migration” in application/controllers directory
To use
- after add the migration file in application/migrations directory,
- update version number to latest version in config/migration.php
- run migration script https://your_domain/migrate
Other notes and references
- Migration file name should be 001_add_users.php (sequence_number+operation+tablename)
- use dbforge class to construct the migration file