Created
September 4, 2015 08:40
-
-
Save boboldehampsink/50961639ee909b4ae89c to your computer and use it in GitHub Desktop.
Migration
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
<?php | |
namespace Craft; | |
/** | |
* The class name is the UTC timestamp in the format of mYYMMDD_HHMMSS_pluginHandle_migrationName. | |
*/ | |
class m150904_071603_inspections_DistanceText extends BaseMigration | |
{ | |
/** | |
* Any migration code in here is wrapped inside of a transaction. | |
* | |
* @return bool | |
*/ | |
public function safeUp() | |
{ | |
// Get original field context | |
$context = craft()->content->fieldContext; | |
// Set supertable field context (there's only one supertable: 1) | |
craft()->content->fieldContext = 'superTableBlockType:1'; | |
// Get distance field | |
$field = craft()->fields->getFieldByHandle('distance'); | |
// Rename the field | |
$field->name = 'Meters'; | |
// Save field | |
craft()->fields->saveField($field); | |
// Revert to original field context | |
craft()->content->fieldContext = $context; | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment