diff options
author | Cloudmanic Labs, LLC <github@cloudmanic.com> | 2011-09-18 21:08:56 +0200 |
---|---|---|
committer | Cloudmanic Labs, LLC <github@cloudmanic.com> | 2011-09-18 21:08:56 +0200 |
commit | 539dcb0b2968a2d83c16b42a20252011152f2e65 (patch) | |
tree | eb7e685698ba4eeb3ac70f876f2f1ed72dc0e561 /system | |
parent | 4ff4896dbc6bd24efc3d005df90bdb3667255f09 (diff) |
Added support to select the name of the database table you are going to use in Migrations
Diffstat (limited to 'system')
-rw-r--r-- | system/libraries/Migration.php | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/system/libraries/Migration.php b/system/libraries/Migration.php index 3734e18f5..682d90752 100644 --- a/system/libraries/Migration.php +++ b/system/libraries/Migration.php @@ -32,7 +32,8 @@ class CI_Migration { protected $_migration_enabled = FALSE; protected $_migration_path = NULL; protected $_migration_version = 0; - + protected $_migration_table = 'migrations'; + protected $_error_string = ''; public function __construct($config = array()) @@ -68,16 +69,22 @@ class CI_Migration { // They'll probably be using dbforge $this->load->dbforge(); + // Make sure the migration table name was set. + if ( (! isset($this->_migration_table)) OR (empty($this->_migration_table))) + { + show_error('Migrations configuration file (migration.php) must have "migration_table" set.'); + } + // If the migrations table is missing, make it - if ( ! $this->db->table_exists('migrations')) + if ( ! $this->db->table_exists($this->_migration_table)) { $this->dbforge->add_field(array( 'version' => array('type' => 'INT', 'constraint' => 3), )); - $this->dbforge->create_table('migrations', TRUE); + $this->dbforge->create_table($this->_migration_table, TRUE); - $this->db->insert('migrations', array('version' => 0)); + $this->db->insert($this->_migration_table, array('version' => 0)); } } @@ -299,7 +306,7 @@ class CI_Migration { */ protected function _get_version() { - $row = $this->db->get('migrations')->row(); + $row = $this->db->get($this->_migration_table)->row(); return $row ? $row->version : 0; } @@ -314,7 +321,7 @@ class CI_Migration { */ protected function _update_version($migrations) { - return $this->db->update('migrations', array( + return $this->db->update($this->_migration_table, array( 'version' => $migrations )); } |