1
0
Fork 0
mirror of https://github.com/Oreolek/kohana-migrations.git synced 2024-06-26 03:40:54 +03:00

Merge pull request #35 from EvanPurkhiser/feature/config-table-name

Add a configuration option for the table name
This commit is contained in:
Lorenzo Pisani 2012-10-24 00:25:16 -07:00
commit 21757aea08
4 changed files with 19 additions and 10 deletions

View file

@ -15,7 +15,7 @@ class Model_Minion_Migration extends Model
* The table that's used to store the migrations * The table that's used to store the migrations
* @var string * @var string
*/ */
protected $_table = 'minion_migrations'; protected $_table;
/** /**
* Constructs the model, taking a Database connection as the first and only * Constructs the model, taking a Database connection as the first and only
@ -26,6 +26,8 @@ class Model_Minion_Migration extends Model
public function __construct(Kohana_Database $db) public function __construct(Kohana_Database $db)
{ {
$this->_db = $db; $this->_db = $db;
$this->_table = Kohana::$config->load('minion/migration.table');
} }
/** /**
@ -170,7 +172,9 @@ class Model_Minion_Migration extends Model
if ( ! count($query)) if ( ! count($query))
{ {
$sql = file_get_contents(Kohana::find_file('', 'minion_schema', 'sql')); $sql = View::factory('minion/task/migrations/schema')
->set('table_name', $this->_table)
->render();
$this->_db->query(NULL, $sql); $this->_db->query(NULL, $sql);
} }

View file

@ -7,6 +7,11 @@ return array(
), ),
/**
* The table used to store migrations
*/
'table' => 'minion_migrations',
/** /**
* This specifies which migration should be the "base", in timestamp form. * This specifies which migration should be the "base", in timestamp form.
* This migration will not be run when --migrate-down is called * This migration will not be run when --migrate-down is called

View file

@ -1,8 +0,0 @@
CREATE TABLE `minion_migrations` (
`timestamp` varchar(14) NOT NULL,
`description` varchar(100) NOT NULL,
`group` varchar(100) NOT NULL,
`applied` tinyint(1) DEFAULT '0',
PRIMARY KEY (`timestamp`,`group`),
UNIQUE KEY `MIGRATION_ID` (`timestamp`,`description`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

View file

@ -0,0 +1,8 @@
CREATE TABLE `<? echo $table_name; ?>` (
`timestamp` varchar(14) NOT NULL,
`description` varchar(100) NOT NULL,
`group` varchar(100) NOT NULL,
`applied` tinyint(1) DEFAULT '0',
PRIMARY KEY (`timestamp`,`group`),
UNIQUE KEY `MIGRATION_ID` (`timestamp`,`description`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;