<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class DeleteSMSColumns extends Migration
{
    public function up()
    {
      $this->forge->dropColumn('notification', ['is_send_sms', 'send_sms_notification']);
      $this->forge->dropColumn('settings', ['sms_gateway','sms_account_id', 'sms_auth_token', 'sms_info_add',
                  'sms_confirmation', 'send_sms_register', 'send_sms_welcome']);
      $this->forge->dropColumn('user', ['sms_confirmed']);
    }

    public function down()
    {
      $sql = "ALTER TABLE `wg_notification` ADD `is_send_sms` tinyint(1) NOT NULL DEFAULT '0';";
      $this->db->query($sql);
      $sql = "ALTER TABLE `wg_notification` ADD `send_sms_notification` tinyint(1) NOT NULL DEFAULT '0';";
      $this->db->query($sql);

      $sql = "ALTER TABLE `wg_settings` ADD `sms_gateway` enum('twilio') COLLATE latin1_general_ci NOT NULL DEFAULT 'twilio';";
      $this->db->query($sql);
      $sql = "ALTER TABLE `wg_settings` ADD `sms_account_id` varchar(255) COLLATE latin1_general_ci DEFAULT NULL;";
      $this->db->query($sql);
      $sql = "ALTER TABLE `wg_settings` ADD `sms_auth_token` varchar(255) COLLATE latin1_general_ci DEFAULT NULL;";
      $this->db->query($sql);
      $sql = "ALTER TABLE `wg_settings` ADD `sms_info_add` varchar(255) COLLATE latin1_general_ci DEFAULT NULL;";
      $this->db->query($sql);
      $sql = "ALTER TABLE `wg_settings` ADD `sms_confirmation` tinyint(1) NOT NULL DEFAULT '0';";
      $this->db->query($sql);
      $sql = "ALTER TABLE `wg_settings` ADD `send_sms_register` tinyint(1) NOT NULL DEFAULT '0';";
      $this->db->query($sql);
      $sql = "ALTER TABLE `wg_settings` ADD `send_sms_welcome` tinyint(1) NOT NULL DEFAULT '0';";
      $this->db->query($sql);

      $sql = "ALTER TABLE `wg_user` ADD `sms_confirmed` tinyint(4) NOT NULL DEFAULT '0';";
      $this->db->query($sql); 
    }
}