| Total Complexity | 4 |
| Total Lines | 30 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 3 | class m130915_101849_add_setting_pk_for_mysql extends CDbMigration |
||
| 4 | { |
||
| 5 | |||
| 6 | public function up() |
||
| 7 | { |
||
| 8 | // Bail out if we are not configured for MySQL |
||
| 9 | if (strpos(Yii::app()->db->connectionString, 'sqlite') === 0) |
||
| 10 | { |
||
| 11 | echo "Not configured to use MySQL, skipping this migration ...\n"; |
||
| 12 | return true; |
||
| 13 | } |
||
| 14 | |||
| 15 | // Try to drop any previous defined primary key (in case someone fixed |
||
| 16 | // this on their own) |
||
| 17 | try |
||
| 18 | { |
||
| 19 | $this->dropPrimaryKey('name', 'settings'); |
||
| 20 | } |
||
| 21 | catch (CDbException $e) |
||
| 22 | { |
||
| 23 | // ignore the exception, it means the primary key doesn't exist |
||
| 24 | } |
||
| 25 | |||
| 26 | $this->addPrimaryKey('PRIMARY', 'settings', 'name'); |
||
| 27 | } |
||
| 28 | |||
| 29 | public function down() |
||
| 33 | } |
||
| 34 | |||
| 35 | } |