Skip to content

Commit

Permalink
Dev Changed nontoken/response tables to innodb for mysql.
Browse files Browse the repository at this point in the history
  • Loading branch information
SamMousa committed Jun 15, 2015
1 parent df85b12 commit a983e4d
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 618 deletions.
47 changes: 47 additions & 0 deletions application/migrations/m150615_114842_use_innodb_mysql.php
@@ -0,0 +1,47 @@
<?php
namespace ls\migrations;
use \CDbMigration;

class m150615_114842_use_innodb_mysql extends CDbMigration
{
/**
* Describe the migration in this PHPDOC.
* Implement it below.
* @return boolean True if migration was a success.
*/
public function safeUp()
{
$schema = App()->db->schema;
if ($schema instanceof \MysqlSchema) {

$prefix = App()->db->tablePrefix;
// var_dump($prefix);
foreach(App()->db->schema->tableNames as $tableName) {
// Check if we "own" this table.
if (strncmp($prefix, $tableName, strlen($prefix)) === 0) {
// Check if it is not a response or token table.
if (!preg_match("/^{$prefix}(survey_|token_).*\\d+/", $tableName)) {
if (!$schema->alterEngine($tableName, $schema::ENGINE_INNODB)) {
echo "Failed to convert table.\n";
return false;
}
}
}

}
}
return true;
}

/**
* @return boolean True if migration was a success.
*/

public function safeDown()
{
echo "m150615_114842_use_innodb_mysql does not support migration down.\\n";
return false;

}

}

0 comments on commit a983e4d

Please sign in to comment.