Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dev Changed nontoken/response tables to innodb for mysql.
- Loading branch information
Showing
2 changed files
with
47 additions
and
618 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
application/migrations/m150615_114842_use_innodb_mysql.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.