title: My Sql Alter Table using knex.js
body: <p>Need to change a Data type and Default value of a column in MySql Db using knex;
  Later the data type was <strong>date</strong> and needed to change that in to <strong>dateTime</strong> and also the default  value needed to change from <strong>NULL</strong> to <strong>CURRENT_TIMESTAMP</strong></p>
  
  <p>MySql Query to achieve the corresponding is given below</p>
  
  <pre><code>ALTER TABLE `Employees` 
  CHANGE COLUMN `added_date` `added_date` DATETIME DEFAULT CURRENT_TIMESTAMP ;
  </code></pre>
  
  <p>I have created the knex migration file to run the above changes:</p>
  
  <p>Content of  Migration file is given below:</p>
  
  <pre><code>exports.up = function(knex, Promise) {
  return knex.schema.alterTable('Employee', function(t) {
         t.dateTime('added_date').defaultTo(knex.fn.now());       
  });
  } ;
  
  exports.down = function(knex, Promise) {
    return knex.schema.alterTable('Employee', function(t) {
   t.date('added_date').nullable();       
  });
   };
  </code></pre>
  
  <p>But this always throws error while building. 
  Which is like</p>
  
  <p>Knex:warning - migrations failed with error: alter table      <code>Employee</code> add <code>added_date</code> datetime     default CURRENT_TIMESTAMP - ER_DUP_FIELDNAME: Duplicate column name     'added_date'
  error in  migrating latest version
  Error: ER_DUP_FIELDNAME: Duplicate column name 'added_date'</p>
  
  <h1>Can anyone share the exact method/syntax to ALTER a table with the above given changes?</h1>