<?php
defined('BASEPATH') or exit('No direct script access allowed');

class Migration_Version_619 extends CI_Migration
{
    public function __construct()
    {
        parent::__construct();
    }

    public function up()
    {
        if ($this->db->table_exists('tbl_promotions') && !$this->db->field_exists('print_date', 'tbl_promotions')) {
            $this->db->query("ALTER TABLE `tbl_promotions` ADD `print_date` date DEFAULT NULL AFTER `promotion_date`");
        }

        if ($this->db->table_exists('tbl_config')) {
            $this->db->where('config_key', 'version')->update('tbl_config', array('value' => '6.1.9'));
        }
    }

    public function down()
    {
        if ($this->db->table_exists('tbl_promotions') && $this->db->field_exists('print_date', 'tbl_promotions')) {
            $this->db->query("ALTER TABLE `tbl_promotions` DROP COLUMN `print_date`");
        }

        if ($this->db->table_exists('tbl_config')) {
            $this->db->where('config_key', 'version')->update('tbl_config', array('value' => '6.1.8'));
        }
    }
}
