Permalink
Browse files

make plugin working for cake 2.1

  • Loading branch information...
skie committed Jan 31, 2012
1 parent e38df43 commit 840bd64d279a6bd37e564a6d18a802105ea603b3
View
@@ -225,9 +225,9 @@ protected function _run() {
*/
protected function _createTable($type, $tables) {
foreach ($tables as $table => $fields) {
- if (in_array($this->db->fullTableName($table, false), $this->db->listSources())) {
+ if (in_array($this->db->fullTableName($table, false, false), $this->db->listSources())) {
throw new MigrationException($this,
- __d('migrations', 'Table "%s" already exists in database.', $this->db->fullTableName($table, false))
+ __d('migrations', 'Table "%s" already exists in database.', $this->db->fullTableName($table, false, false))
);
}
$this->Schema->tables = array($table => $fields);
@@ -250,9 +250,9 @@ protected function _createTable($type, $tables) {
*/
protected function _dropTable($type, $tables) {
foreach ($tables as $table) {
- if (!in_array($this->db->fullTableName($table, false), $this->db->listSources())) {
+ if (!in_array($this->db->fullTableName($table, false, false), $this->db->listSources())) {
throw new MigrationException($this,
- __d('migrations', 'Table "%s" does not exists in database.', $this->db->fullTableName($table, false))
+ __d('migrations', 'Table "%s" does not exists in database.', $this->db->fullTableName($table, false, false))
);
}
$this->Schema->tables = array($table => array());
@@ -276,13 +276,13 @@ protected function _dropTable($type, $tables) {
protected function _renameTable($type, $tables) {
foreach ($tables as $oldName => $newName) {
$sources = $this->db->listSources();
- if (!in_array($this->db->fullTableName($oldName, false), $sources)) {
+ if (!in_array($this->db->fullTableName($oldName, false, false), $sources)) {
throw new MigrationException($this,
- __d('migrations', 'Table "%s" does not exists in database.', $this->db->fullTableName($oldName, false))
+ __d('migrations', 'Table "%s" does not exists in database.', $this->db->fullTableName($oldName, false, false))
);
} else if (in_array($this->db->fullTableName($newName, false), $sources)) {
throw new MigrationException($this,
- __d('migrations', 'Table "%s" already exists in database.', $this->db->fullTableName($newName, false))
+ __d('migrations', 'Table "%s" already exists in database.', $this->db->fullTableName($newName, false, false))
);
}
$sql = 'RENAME TABLE ' . $this->db->fullTableName($oldName) . ' TO ' . $this->db->fullTableName($newName) . ';';
View
@@ -248,7 +248,7 @@ private function __initMigrations() {
'ds' => $this->connection);
$db =& ConnectionManager::getDataSource($this->connection);
- if (!in_array($db->fullTableName('schema_migrations', false), $db->listSources())) {
+ if (!in_array($db->fullTableName('schema_migrations', false, false), $db->listSources())) {
$map = $this->__loadFile('map', 'Migrations');
list($name, $class) = each($map[1]);
@@ -52,10 +52,10 @@ public function testInitialTableCreation() {
$Schema->tables = array('schema_migrations' => array());
$db->execute($db->dropSchema($Schema));
- $this->assertFalse(in_array($db->fullTableName('schema_migrations', false), $db->listSources()));
+ $this->assertFalse(in_array($db->fullTableName('schema_migrations', false, false), $db->listSources()));
$this->Version = new MigrationVersion(array('connection' => 'test'));
- $this->assertTrue(in_array($db->fullTableName('schema_migrations', false), $db->listSources()));
+ $this->assertTrue(in_array($db->fullTableName('schema_migrations', false, false), $db->listSources()));
}
/**
@@ -131,31 +131,31 @@ public function testCreateDropTable() {
));
$sources = $this->db->listSources();
- $this->assertFalse(in_array($this->db->fullTableName('migration_user', false), $sources));
- $this->assertFalse(in_array($this->db->fullTableName('migration_posts', false), $sources));
+ $this->assertFalse(in_array($this->db->fullTableName('migration_user', false, false), $sources));
+ $this->assertFalse(in_array($this->db->fullTableName('migration_posts', false, false), $sources));
$this->assertTrue($migration->run('up'));
$sources = $this->db->listSources();
- $this->assertTrue(in_array($this->db->fullTableName('migration_users', false), $sources));
- $this->assertTrue(in_array($this->db->fullTableName('migration_posts', false), $sources));
+ $this->assertTrue(in_array($this->db->fullTableName('migration_users', false, false), $sources));
+ $this->assertTrue(in_array($this->db->fullTableName('migration_posts', false, false), $sources));
try {
$migration->run('up');
$this->fail('No exception triggered');
} catch (MigrationException $e) {
- $this->assertEqual('Table "' . $this->db->fullTableName('migration_posts', false) . '" already exists in database.', $e->getMessage());
+ $this->assertEqual('Table "' . $this->db->fullTableName('migration_posts', false, false) . '" already exists in database.', $e->getMessage());
}
$this->assertTrue($migration->run('down'));
$sources = $this->db->listSources();
- $this->assertFalse(in_array($this->db->fullTableName('migration_users', false), $sources));
- $this->assertFalse(in_array($this->db->fullTableName('migration_posts', false), $sources));
+ $this->assertFalse(in_array($this->db->fullTableName('migration_users', false, false), $sources));
+ $this->assertFalse(in_array($this->db->fullTableName('migration_posts', false, false), $sources));
if ($this->db->config['datasource'] != 'Database/Mysql') { // && $this->db->config['driver'] != 'mysqli') {
try {
$migration->run('down');
$this->fail('No exception triggered');
} catch (MigrationException $e) {
- $this->assertEqual('Table "' . $this->db->fullTableName('migration_posts', false) . '" does not exists in database.', $e->getMessage());
+ $this->assertEqual('Table "' . $this->db->fullTableName('migration_posts', false, false) . '" does not exists in database.', $e->getMessage());
}
}
}
@@ -174,25 +174,25 @@ public function testRenameTable() {
));
$sources = $this->db->listSources();
- $this->assertTrue(in_array($this->db->fullTableName('posts', false), $sources));
- $this->assertFalse(in_array($this->db->fullTableName('renamed_posts', false), $sources));
+ $this->assertTrue(in_array($this->db->fullTableName('posts', false, false), $sources));
+ $this->assertFalse(in_array($this->db->fullTableName('renamed_posts', false, false), $sources));
$this->assertTrue($migration->run('up'));
$sources = $this->db->listSources();
- $this->assertFalse(in_array($this->db->fullTableName('posts', false), $sources));
- $this->assertTrue(in_array($this->db->fullTableName('renamed_posts', false), $sources));
+ $this->assertFalse(in_array($this->db->fullTableName('posts', false, false), $sources));
+ $this->assertTrue(in_array($this->db->fullTableName('renamed_posts', false, false), $sources));
try {
$migration->run('up');
$this->fail('No exception triggered');
} catch (MigrationException $e) {
- $this->assertEqual('Table "' . $this->db->fullTableName('posts', false) . '" does not exists in database.', $e->getMessage());
+ $this->assertEqual('Table "' . $this->db->fullTableName('posts', false, false) . '" does not exists in database.', $e->getMessage());
}
$this->assertTrue($migration->run('down'));
$sources = $this->db->listSources();
- $this->assertTrue(in_array($this->db->fullTableName('posts', false), $sources));
- $this->assertFalse(in_array($this->db->fullTableName('renamed_posts', false), $sources));
+ $this->assertTrue(in_array($this->db->fullTableName('posts', false, false), $sources));
+ $this->assertFalse(in_array($this->db->fullTableName('renamed_posts', false, false), $sources));
}
/**
View
@@ -1,6 +1,6 @@
# Migrations Plugin for CakePHP #
-Version 1.2
+Version 2.1
This migrations plugin enables developers to quickly and easily manage and migrate between database schema versions.
@@ -13,7 +13,7 @@ For detailed usage information, please see the [documentation online](http://cak
## Requirements ##
* PHP version: PHP 5.2+
-* CakePHP version: 2.0
+* CakePHP version: 2.1
## Support ##

0 comments on commit 840bd64

Please sign in to comment.