Skip to content

Commit

Permalink
fix: table tests and backup migration for integration options
Browse files Browse the repository at this point in the history
  • Loading branch information
gustavs-gutmanis committed Dec 10, 2024
1 parent de132ae commit bdf529a
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ public function testReverseTransform()
$output = (new TableTransformer())->reverseTransform($value);

$expected = [
['label' => 'Col 1', 'value' => 'one', 'type' => 'string'],
['label' => 'Col 2', 'value' => 'two', 'type' => 'checkbox'],
['label' => 'Col 3', 'value' => 'three;four;five', 'type' => 'select'],
['label' => 'Col 1', 'value' => 'one', 'type' => 'string', 'placeholder' => '', 'options' => [], 'checked' => false],
['label' => 'Col 2', 'value' => 'two', 'type' => 'checkbox', 'placeholder' => '', 'options' => [], 'checked' => false],
['label' => 'Col 3', 'value' => 'three;four;five', 'type' => 'select', 'placeholder' => '', 'options' => [], 'checked' => false],
];

$this->assertEquals($expected, $output);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ class m241104_091432_AddOptionsToIntegrationFields extends Migration
{
public function safeUp(): bool
{
if ($this->db->columnExists('{{%freeform_crm_fields}}', 'options')) {
return true;
}

$this->addColumn(
'{{%freeform_crm_fields}}',
'options',
Expand All @@ -25,6 +29,10 @@ public function safeUp(): bool

public function safeDown(): bool
{
if (!$this->db->columnExists('{{%freeform_crm_fields}}', 'options')) {
return true;
}

$this->dropColumn('{{%freeform_crm_fields}}', 'options');
$this->dropColumn('{{%freeform_email_marketing_fields}}', 'options');

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

namespace Solspace\Freeform\migrations;

use craft\db\Migration;

class m241210_054218_AddOptionColumnFixForIntegrations extends Migration
{
public function safeUp(): bool
{
if ($this->db->columnExists('{{%freeform_crm_fields}}', 'options')) {
return true;
}

$this->addColumn(
'{{%freeform_crm_fields}}',
'options',
$this->json()->after('required')
);

$this->addColumn(
'{{%freeform_email_marketing_fields}}',
'options',
$this->json()->after('required')
);

return true;
}

public function safeDown(): bool
{
if (!$this->db->columnExists('{{%freeform_crm_fields}}', 'options')) {
return true;
}

$this->dropColumn('{{%freeform_crm_fields}}', 'options');
$this->dropColumn('{{%freeform_email_marketing_fields}}', 'options');

return true;
}
}

0 comments on commit bdf529a

Please sign in to comment.