These are chat archives for db-migrate/node-db-migrate

10th
Feb 2019
Theo
@shierro
Feb 10 03:51
Hi! i was wondering how to create a migration script, with default value using the literal DEFAULT_TIMESTAMP of mysql. i tried to search the docs & repo for ways to do this, but can't find any. can anyone help me please? Thanks!
Tobias Gurtzick
@wzrdtales
Feb 10 20:17
@shierro depends on the driver. in doubt new String('xyz') always works
in updated drivers such as the cockroachdb one there is a new raw property
in those you can write it like this:
    createdAt: {
      type: 'timestamptz',
      notNull: true,
      defaultValue: {
        raw: 'CURRENT_TIMESTAMP()'
      }
    }
if i am right this needs to be added to the other official drivers though. in that case fall back to new String
and you mean probably CURRENT_TIMESTAMP and not DEFAULT_TIMESTAMP
this is natively supported by the mysql driver anyway
just put it like that defaultValue: 'CURRENT_TIMESTAMP'
new String and raw will be more cross compatible in doubt though