Perform setting related migration improvements

This commit is contained in:
Alex Tselegidis 2022-05-20 18:27:57 +02:00
parent 14305d08cc
commit 66106fcd18
4 changed files with 44 additions and 20 deletions

View file

@ -19,10 +19,13 @@ class Migration_Add_google_analytics_setting extends EA_Migration {
*/ */
public function up() public function up()
{ {
$this->db->insert('settings', [ if ( ! $this->db->get_where('settings', ['name' => 'google_analytics_code'])->num_rows())
'name' => 'google_analytics_code', {
'value' => '' $this->db->insert('settings', [
]); 'name' => 'google_analytics_code',
'value' => ''
]);
}
} }
/** /**
@ -32,6 +35,9 @@ class Migration_Add_google_analytics_setting extends EA_Migration {
*/ */
public function down() public function down()
{ {
$this->db->delete('settings', ['name' => 'google_analytics_code']); if ($this->db->get_where('settings', ['name' => 'google_analytics_code'])->num_rows())
{
$this->db->delete('settings', ['name' => 'google_analytics_code']);
}
} }
} }

View file

@ -19,10 +19,13 @@ class Migration_Add_customer_notifications_setting extends EA_Migration {
*/ */
public function up() public function up()
{ {
$this->db->insert('settings', [ if ( ! $this->db->get_where('settings', ['name' => 'customer_notifications'])->num_rows())
'name' => 'customer_notifications', {
'value' => '1' $this->db->insert('settings', [
]); 'name' => 'customer_notifications',
'value' => '1'
]);
}
} }
/** /**
@ -32,6 +35,9 @@ class Migration_Add_customer_notifications_setting extends EA_Migration {
*/ */
public function down() public function down()
{ {
$this->db->delete('settings', ['name' => 'customer_notifications']); if ($this->db->get_where('settings', ['name' => 'customer_notifications'])->num_rows())
{
$this->db->delete('settings', ['name' => 'customer_notifications']);
}
} }
} }

View file

@ -19,10 +19,13 @@ class Migration_Add_date_format_setting extends EA_Migration {
*/ */
public function up() public function up()
{ {
$this->db->insert('settings', [ if ( ! $this->db->get_where('settings', ['name' => 'date_format'])->num_rows())
'name' => 'date_format', {
'value' => 'DMY' $this->db->insert('settings', [
]); 'name' => 'date_format',
'value' => 'DMY'
]);
}
} }
/** /**
@ -32,6 +35,9 @@ class Migration_Add_date_format_setting extends EA_Migration {
*/ */
public function down() public function down()
{ {
$this->db->delete('settings', ['name' => 'date_format']); if ($this->db->get_where('settings', ['name' => 'date_format'])->num_rows())
{
$this->db->delete('settings', ['name' => 'date_format']);
}
} }
} }

View file

@ -19,10 +19,13 @@ class Migration_Add_require_captcha_setting extends EA_Migration {
*/ */
public function up() public function up()
{ {
$this->db->insert('settings', [ if ( ! $this->db->get_where('settings', ['name' => 'require_captcha'])->num_rows())
'name' => 'require_captcha', {
'value' => '0' $this->db->insert('settings', [
]); 'name' => 'require_captcha',
'value' => '0'
]);
}
} }
/** /**
@ -32,6 +35,9 @@ class Migration_Add_require_captcha_setting extends EA_Migration {
*/ */
public function down() public function down()
{ {
$this->db->delete('settings', ['name' => 'require_captcha']); if ($this->db->get_where('settings', ['name' => 'require_captcha'])->num_rows())
{
$this->db->delete('settings', ['name' => 'require_captcha']);
}
} }
} }