-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change ownership, add ownership migration, bump the schema version
- Loading branch information
1 parent
0616ed2
commit 00b0438
Showing
12 changed files
with
95 additions
and
68 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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,60 @@ | ||
<?php | ||
|
||
namespace jalendport\preparse\migrations; | ||
|
||
use Craft; | ||
use craft\db\Migration; | ||
use jalendport\preparse\fields\PreparseFieldType; | ||
use yii\base\ErrorException; | ||
use yii\base\Exception; | ||
|
||
/** | ||
* m240711_230833_jalendport migration. | ||
*/ | ||
class m240711_230833_jalendport extends Migration | ||
{ | ||
/** | ||
* @inheritdoc | ||
*/ | ||
public function safeUp(): bool | ||
{ | ||
$oldType = 'besteadfast\preparsefield\fields\PreparseFieldType'; | ||
|
||
$this->update('{{%fields}}', ['type'=> PreparseFieldType::class], ['type' => $oldType]); | ||
|
||
// Don’t make the same config changes twice | ||
$projectConfig = Craft::$app->getProjectConfig(); | ||
$schemaVersion = $projectConfig->get('plugins.preparse-field.schemaVersion', true); | ||
|
||
if (version_compare($schemaVersion, '1.1.0', '>=')) | ||
{ | ||
return true; | ||
} | ||
|
||
$fields = $projectConfig->get('fields') ?? []; | ||
|
||
foreach ($fields as $fieldUid => $field) | ||
{ | ||
if ($field['type'] === $oldType) | ||
{ | ||
$field['type'] = PreparseFieldType::class; | ||
try { | ||
$projectConfig->set("fields.{$fieldUid}", $field); | ||
} catch (Exception|ErrorException $e) { | ||
return false; | ||
} | ||
} | ||
} | ||
|
||
return true; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function safeDown(): bool | ||
{ | ||
echo "m240711_230833_jalendport cannot be reverted.\n"; | ||
return false; | ||
} | ||
} |
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
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
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
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
<?php | ||
|
||
class_exists(\besteadfast\preparsefield\fields\PreparseFieldType::class); | ||
class_exists(\jalendport\preparse\fields\PreparseFieldType::class); |