Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need ability to add "ON UPDATE" and non-escaped values #172

Open
ericnakagawa opened this issue Jun 17, 2014 · 2 comments
Open

Need ability to add "ON UPDATE" and non-escaped values #172

ericnakagawa opened this issue Jun 17, 2014 · 2 comments
Labels

Comments

@ericnakagawa
Copy link

ericnakagawa commented Jun 17, 2014

For TIMESTAMP data type setting the value you to CURRENT_TIMESTAMP results in the escaped string value being sent: 'CURRENT_TIMESTAMP'. The ideal way this would work is to pass along without quotes.

Secondly, I'd like to be able to add "ON UPDATE" perhaps as "OnUpdate" as API value.

-- I've been trying to add updated timestamp on record update


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@wzrdtales
Copy link
Member

related to #211

@robertfernanV
Copy link

robertfernanV commented May 28, 2019

Hello
while creating the feature.
with runSql you can modify the field ON UPDATE CURRENT_TIMESTAMP

exports.up = function(db) {
  return db.createTable('users',{
    id:{type:'bigint',primaryKey:true,autoIncrement:true, unsigned: true},
    name:{type:'string',length:255,notNull:true},
    email:{type:'string',length:100,unique:true,notNull:true},
    password:{type:'string',length:255,},
    created_at:{type:'timestamp',defaultValue:new String('CURRENT_TIMESTAMP')},
    updated_at:{type:'timestamp'}
  }).then( ()=>{
    db.runSql("ALTER TABLE `users`	CHANGE COLUMN `updated_at` `updated_at` TIMESTAMP NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP AFTER `created_at`;");
  });
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants