Welcome Guest, Not a member yet? Register   Sign In
can't add columns to existing table with migration
#1

(This post was last modified: 01-31-2020, 03:49 AM by codemicky.)

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?
Reply




Theme © iAndrew 2016 - Forum software by © MyBB