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

View file

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

View file

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