-
-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Formie 3 migration prep for field layout changes
- Loading branch information
1 parent
7584999
commit 9925889
Showing
5 changed files
with
159 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
namespace verbb\formie\migrations; | ||
|
||
use verbb\formie\elements\Form; | ||
use verbb\formie\helpers\Plugin; | ||
|
||
use craft\db\Migration; | ||
use craft\db\Query; | ||
use craft\helpers\StringHelper; | ||
|
||
class m231231_000000_formie3_prep extends Migration | ||
{ | ||
public function safeUp(): bool | ||
{ | ||
if (!$this->db->tableExists('{{%formie_newlayout}}')) { | ||
$this->createTable('{{%formie_newlayout}}', [ | ||
'id' => $this->primaryKey(), | ||
'formId' => $this->integer()->notNull(), | ||
'layoutConfig' => $this->text(), | ||
'dateCreated' => $this->dateTime()->notNull(), | ||
'dateUpdated' => $this->dateTime()->notNull(), | ||
'uid' => $this->uid(), | ||
]); | ||
} | ||
|
||
if (!$this->db->tableExists('{{%formie_newnestedlayout}}')) { | ||
$this->createTable('{{%formie_newnestedlayout}}', [ | ||
'id' => $this->primaryKey(), | ||
'fieldId' => $this->integer()->notNull(), | ||
'layoutConfig' => $this->text(), | ||
'dateCreated' => $this->dateTime()->notNull(), | ||
'dateUpdated' => $this->dateTime()->notNull(), | ||
'uid' => $this->uid(), | ||
]); | ||
} | ||
|
||
foreach (Form::find()->status(null)->all() as $form) { | ||
Plugin::saveFormie3Layout($form); | ||
} | ||
|
||
return true; | ||
} | ||
|
||
public function safeDown(): bool | ||
{ | ||
echo "m231231_000000_formie3_prep 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