Created
April 12, 2019 18:36
-
-
Save jamesmacwhite/02f23169d2967100cb0ce675d7e1a95e to your computer and use it in GitHub Desktop.
Field type migration for Table Maker for Craft 2 to Craft 3 migrations
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\contentmigrations; | |
use Craft; | |
use craft\db\Migration; | |
use supercool\tablemaker\fields\TableMakerField; | |
/** | |
* m190412_182837_tablemaker_update_fieldtype migration. | |
* | |
* The Table Maker plugin currently doesn't migrate it's own field type... | |
* This migration will update the field type, so our matrix body block tables will work! | |
* | |
*/ | |
class m190412_182837_tablemaker_update_fieldtype extends Migration | |
{ | |
/** | |
* @inheritdoc | |
*/ | |
public function safeUp() | |
{ | |
echo " > Updating Table Maker field type...\n"; | |
// Migrate the old TableMaker field | |
$this->update('{{%fields}}', [ | |
'type' => TableMakerField::class | |
], ['type' => 'TableMaker']); | |
return true; | |
} | |
/** | |
* @inheritdoc | |
*/ | |
public function safeDown() | |
{ | |
echo "m190412_182837_tablemaker_update_fieldtype cannot be reverted.\n"; | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment