easyappointments/application/migrations/012_legal_contents.php

171 lines
5.4 KiB
PHP
Raw Normal View History

<?php defined('BASEPATH') or exit('No direct script access allowed');
/* ----------------------------------------------------------------------------
2022-01-18 15:05:42 +03:00
* Easy!Appointments - Online Appointment Scheduler
*
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
2021-12-18 19:43:45 +03:00
* @copyright Copyright (c) Alex Tselegidis
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
* @link https://easyappointments.org
* @since v1.3.2
* ---------------------------------------------------------------------------- */
2021-10-29 11:19:10 +03:00
class Migration_Legal_contents extends EA_Migration {
/**
* Upgrade method.
*/
public function up()
{
if ( ! $this->db->get_where('settings', ['name' => 'display_cookie_notice'])->num_rows())
{
$this->db->insert('settings', [
'name' => 'display_cookie_notice',
'value' => '0'
]);
}
if ( ! $this->db->get_where('settings', ['name' => 'cookie_notice_content'])->num_rows())
{
$this->db->insert('settings', [
'name' => 'cookie_notice_content',
'value' => 'Cookie notice content.'
]);
}
if ( ! $this->db->get_where('settings', ['name' => 'display_terms_and_conditions'])->num_rows())
{
$this->db->insert('settings', [
'name' => 'display_terms_and_conditions',
'value' => '0'
]);
}
if ( ! $this->db->get_where('settings', ['name' => 'terms_and_conditions_content'])->num_rows())
{
$this->db->insert('settings', [
'name' => 'terms_and_conditions_content',
'value' => 'Terms and conditions content.'
]);
}
if ( ! $this->db->get_where('settings', ['name' => 'display_privacy_policy'])->num_rows())
{
$this->db->insert('settings', [
'name' => 'display_privacy_policy',
'value' => '0'
]);
}
if ( ! $this->db->get_where('settings', ['name' => 'privacy_policy_content'])->num_rows())
{
$this->db->insert('settings', [
'name' => 'privacy_policy_content',
'value' => 'Privacy policy content.'
]);
}
if ( ! $this->db->table_exists('consents'))
{
$this->dbforge->add_field([
'id' => [
'type' => 'INT',
'constraint' => 11,
'auto_increment' => TRUE
],
'created' => [
'type' => 'TIMESTAMP',
'null' => TRUE
],
'modified' => [
'type' => 'TIMESTAMP',
'null' => TRUE
],
'first_name' => [
'type' => 'VARCHAR',
'constraint' => '256',
'null' => TRUE,
],
'last_name' => [
'type' => 'VARCHAR',
'constraint' => '256',
'null' => TRUE,
],
'email' => [
'type' => 'VARCHAR',
'constraint' => '512',
'null' => TRUE,
],
'ip' => [
'type' => 'VARCHAR',
'constraint' => '256',
'null' => TRUE,
],
'type' => [
'type' => 'VARCHAR',
'constraint' => '256',
'null' => TRUE,
],
]);
$this->dbforge->add_key('id', TRUE);
$this->dbforge->create_table('consents', TRUE, ['engine' => 'InnoDB']);
}
}
/**
* Downgrade method.
*/
public function down()
{
if ($this->db->get_where('settings', ['name' => 'display_cookie_notice'])->num_rows())
{
$this->db->delete('settings', [
'name' => 'display_cookie_notice'
]);
}
if ($this->db->get_where('settings', ['name' => 'cookie_notice_content'])->num_rows())
{
$this->db->delete('settings', [
'name' => 'cookie_notice_content'
]);
}
if ($this->db->get_where('settings', ['name' => 'display_terms_and_conditions'])->num_rows())
{
$this->db->delete('settings', [
'name' => 'display_terms_and_conditions'
]);
}
if ($this->db->get_where('settings', ['name' => 'terms_and_conditions_content'])->num_rows())
{
$this->db->delete('settings', [
'name' => 'terms_and_conditions_content'
]);
}
if ($this->db->get_where('settings', ['name' => 'display_privacy_policy'])->num_rows())
{
$this->db->delete('settings', [
'name' => 'display_privacy_policy'
]);
}
if ($this->db->get_where('settings', ['name' => 'privacy_policy_content'])->num_rows())
{
$this->db->delete('settings', [
'name' => 'privacy_policy_content'
]);
}
if ($this->db->table_exists('consents'))
{
$this->dbforge->drop_table('consents');
}
}
}