-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes issue adding subscription plan #369
- Loading branch information
1 parent
bcb65b5
commit 9f05929
Showing
2 changed files
with
55 additions
and
1 deletion.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
src/migrations/m231030_000000_update_enupalmultipleplans_selectplan.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,54 @@ | ||
<?php | ||
|
||
namespace enupal\stripe\migrations; | ||
|
||
use craft\db\Migration; | ||
use craft\db\Query; | ||
use Craft; | ||
|
||
/** | ||
* m231030_000000_update_enupalmultipleplans_selectplan migration. | ||
*/ | ||
class m231030_000000_update_enupalmultipleplans_selectplan extends Migration | ||
{ | ||
/** | ||
* @return bool | ||
* @throws \yii\base\Exception | ||
*/ | ||
public function safeUp() | ||
{ | ||
$matrixTable = '{{%matrixcontent_enupalmultipleplans}}'; | ||
|
||
$field = (new Query()) | ||
->select(['*']) | ||
->from('{{%fields}}') | ||
->where(["name" => 'Select Plan', 'handle' => 'selectPlan', 'type' => 'craft\fields\Dropdown']) | ||
->andWhere(['like', 'context', 'matrixBlockType:%', false]) | ||
->one(); | ||
|
||
if (empty($field)) { | ||
Craft::error('Unable to find Stripe Payment field selectPlan', __METHOD__); | ||
return null; | ||
} | ||
|
||
$column = 'field_subscriptionPlan_selectPlan_'.$field['columnSuffix']; | ||
|
||
if ($this->db->columnExists($matrixTable, $column)) { | ||
$this->alterColumn($matrixTable, $column, $this->string(255)); | ||
} else { | ||
Craft::error('Unable to find Stripe Payment select plan column: '.$column, __METHOD__); | ||
} | ||
|
||
return true; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function safeDown() | ||
{ | ||
echo "m230208_000000_add_adjustable_quantity 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