mirror of
https://github.com/alextselegidis/easyappointments.git
synced 2024-11-22 16:02:54 +03:00
Migration classes will first check if changes need to be integrated before executing them.
This commit is contained in:
parent
f78f45ef6f
commit
95e32bbd38
4 changed files with 48 additions and 46 deletions
|
@ -16,17 +16,21 @@ class Migration_Add_calendar_view_setting extends CI_Migration {
|
|||
{
|
||||
$this->load->dbforge();
|
||||
|
||||
$fields = [
|
||||
'calendar_view' => [
|
||||
'type' => 'VARCHAR',
|
||||
'constraint' => '32',
|
||||
'default' => 'default'
|
||||
]
|
||||
];
|
||||
$fields = $this->db->list_fields('ea_user_settings');
|
||||
|
||||
$this->dbforge->add_column('ea_user_settings', $fields);
|
||||
|
||||
$this->db->update('ea_user_settings', ['calendar_view' => 'default']);
|
||||
if (!in_array('calendar_view', $fields, true)) {
|
||||
$fields = [
|
||||
'calendar_view' => [
|
||||
'type' => 'VARCHAR',
|
||||
'constraint' => '32',
|
||||
'default' => 'default'
|
||||
]
|
||||
];
|
||||
|
||||
$this->dbforge->add_column('ea_user_settings', $fields);
|
||||
|
||||
$this->db->update('ea_user_settings', ['calendar_view' => 'default']);
|
||||
}
|
||||
}
|
||||
|
||||
public function down()
|
||||
|
|
|
@ -14,25 +14,26 @@
|
|||
class Migration_Add_service_availabilities_type extends CI_Migration {
|
||||
public function up()
|
||||
{
|
||||
$this->load->dbforge();
|
||||
|
||||
$fields = [
|
||||
'availabilities_type' => [
|
||||
'type' => 'VARCHAR',
|
||||
'constraint' => '32',
|
||||
'default' => 'flexible',
|
||||
'after' => 'description'
|
||||
]
|
||||
];
|
||||
|
||||
$this->dbforge->add_column('ea_services', $fields);
|
||||
|
||||
$this->db->update('ea_services', ['availabilities_type' => 'flexible']);
|
||||
if (!$this->db->field_exists('availabilities_type', 'ea_services')) {
|
||||
$fields = [
|
||||
'availabilities_type' => [
|
||||
'type' => 'VARCHAR',
|
||||
'constraint' => '32',
|
||||
'default' => 'flexible',
|
||||
'after' => 'description'
|
||||
]
|
||||
];
|
||||
|
||||
$this->dbforge->add_column('ea_services', $fields);
|
||||
|
||||
$this->db->update('ea_services', ['availabilities_type' => 'flexible']);
|
||||
}
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
$this->load->dbforge();
|
||||
$this->dbforge->drop_column('ea_services', 'availabilities_type');
|
||||
if ($this->db->field_exists('availabilities_type', 'ea_services')) {
|
||||
$this->dbforge->drop_column('ea_services', 'availabilities_type');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,25 +14,26 @@
|
|||
class Migration_Add_service_attendants_number extends CI_Migration {
|
||||
public function up()
|
||||
{
|
||||
$this->load->dbforge();
|
||||
|
||||
$fields = [
|
||||
'attendants_number' => [
|
||||
'type' => 'INT',
|
||||
'constraint' => '11',
|
||||
'default' => '1',
|
||||
'after' => 'availabilities_type'
|
||||
]
|
||||
];
|
||||
|
||||
$this->dbforge->add_column('ea_services', $fields);
|
||||
|
||||
$this->db->update('ea_services', ['attendants_number' => '1']);
|
||||
if (!$this->db->field_exists('attendants_number', 'ea_services')) {
|
||||
$fields = [
|
||||
'attendants_number' => [
|
||||
'type' => 'INT',
|
||||
'constraint' => '11',
|
||||
'default' => '1',
|
||||
'after' => 'availabilities_type'
|
||||
]
|
||||
];
|
||||
|
||||
$this->dbforge->add_column('ea_services', $fields);
|
||||
|
||||
$this->db->update('ea_services', ['attendants_number' => '1']);
|
||||
}
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
$this->load->dbforge();
|
||||
$this->dbforge->drop_column('ea_services', 'attendants_number');
|
||||
if (!$this->db->field_exists('attendants_number', 'ea_services')) {
|
||||
$this->dbforge->drop_column('ea_services', 'attendants_number');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,8 +14,6 @@
|
|||
class Migration_Change_column_types extends CI_Migration {
|
||||
public function up()
|
||||
{
|
||||
$this->load->dbforge();
|
||||
|
||||
// Appointments
|
||||
$fields = [
|
||||
'id' => [
|
||||
|
@ -189,8 +187,6 @@ class Migration_Change_column_types extends CI_Migration {
|
|||
|
||||
public function down()
|
||||
{
|
||||
$this->load->dbforge();
|
||||
|
||||
// Appointments
|
||||
$fields = [
|
||||
'id' => [
|
||||
|
|
Loading…
Reference in a new issue