CodeIgniter Forums

Full Version: can't add columns to existing table with migration
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
migration file: 242_version_242.php



Code:
<?php

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

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

    public function up()
    {
      $fields = array(
        'monitoring' => array(
          'type' => 'INT',
          'default' => NULL
        ),
        'signatory' => array(
          'type' => 'INT',
          'default' => NULL
        )
      );

      $this->dbforge->add_column('contracts', $fields);
    }
}

controller file: Migration.php


Code:
class Migration extends App_Controller
{
    public function add($version)
    {
      // load migration library
      $this->load->library('migration');

      if(!$this->migration->version($version)){
        show_error($this->migration->error_string());
      } else {
        echo "Migration has been run successfully.";
      }
    }
}

I have run http://localhost:8080/migration/add/242 to run a migration.

I am seeing Migration has been run successfully but the columns were not added.

I have checked that the contracts table exists.

Also, I have checked the application/config/migration file.

Code:
$config['migration_version'] = 242;
$config['migration_type'] = 'sequential';
$config['migration_enabled'] = true;

Can anyone help to fix this issue?