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

@ -18,12 +18,15 @@ class Migration_Add_google_analytics_setting extends EA_Migration {
* @throws Exception
*/
public function up()
{
if ( ! $this->db->get_where('settings', ['name' => 'google_analytics_code'])->num_rows())
{
$this->db->insert('settings', [
'name' => 'google_analytics_code',
'value' => ''
]);
}
}
/**
* Downgrade method.
@ -31,7 +34,10 @@ class Migration_Add_google_analytics_setting extends EA_Migration {
* @throws Exception
*/
public function down()
{
if ($this->db->get_where('settings', ['name' => 'google_analytics_code'])->num_rows())
{
$this->db->delete('settings', ['name' => 'google_analytics_code']);
}
}
}

View file

@ -18,12 +18,15 @@ class Migration_Add_customer_notifications_setting extends EA_Migration {
* @throws Exception
*/
public function up()
{
if ( ! $this->db->get_where('settings', ['name' => 'customer_notifications'])->num_rows())
{
$this->db->insert('settings', [
'name' => 'customer_notifications',
'value' => '1'
]);
}
}
/**
* Downgrade method.
@ -31,7 +34,10 @@ class Migration_Add_customer_notifications_setting extends EA_Migration {
* @throws Exception
*/
public function down()
{
if ($this->db->get_where('settings', ['name' => 'customer_notifications'])->num_rows())
{
$this->db->delete('settings', ['name' => 'customer_notifications']);
}
}
}

View file

@ -18,12 +18,15 @@ class Migration_Add_date_format_setting extends EA_Migration {
* @throws Exception
*/
public function up()
{
if ( ! $this->db->get_where('settings', ['name' => 'date_format'])->num_rows())
{
$this->db->insert('settings', [
'name' => 'date_format',
'value' => 'DMY'
]);
}
}
/**
* Downgrade method.
@ -31,7 +34,10 @@ class Migration_Add_date_format_setting extends EA_Migration {
* @throws Exception
*/
public function down()
{
if ($this->db->get_where('settings', ['name' => 'date_format'])->num_rows())
{
$this->db->delete('settings', ['name' => 'date_format']);
}
}
}

View file

@ -18,12 +18,15 @@ class Migration_Add_require_captcha_setting extends EA_Migration {
* @throws Exception
*/
public function up()
{
if ( ! $this->db->get_where('settings', ['name' => 'require_captcha'])->num_rows())
{
$this->db->insert('settings', [
'name' => 'require_captcha',
'value' => '0'
]);
}
}
/**
* Downgrade method.
@ -31,7 +34,10 @@ class Migration_Add_require_captcha_setting extends EA_Migration {
* @throws Exception
*/
public function down()
{
if ($this->db->get_where('settings', ['name' => 'require_captcha'])->num_rows())
{
$this->db->delete('settings', ['name' => 'require_captcha']);
}
}
}