2
votes

I'm following the tutorial here: http://docs.sequelizejs.com/manual/tutorial/migrations.html#creating-first-model-and-migration-

But when I do:

node_modules/.bin/sequelize db:seed:all

it gives to me:

ERROR: null value in column "createdAt" violates not-null constraint

I tested in a new npm init project with a new Postgres DB 10.4.

Dialect: postgres

Dialect version: "pg": "7.4.3",

Database version: 10.4

Sequelize version: "sequelize": "4.38.0"

Maybe this is a way to go? http://mmiyauchi.com/?p=2057

3

3 Answers

1
votes

I found the answer; for some reason createdAt and updatedAt were added to the SequelizeMeta table -- but the migration was adding a record to the SeqwuelizeMeta table without date values and it was THAT query that was breaking the migration.

0
votes

i had the same error for my case it's because i had a datas in my tables, to solve it i dumped all datas and run sequelize sync.

0
votes

Happened to me using Sequelize + Postgres.

Adding to the sequelize.define options parameter timestamps: true solved it.

Steps:

  1. I Defined the columns createdAt, updatedAt, and deletedAt on the table creation (queryInterface.createTable).

  2. On the model definition options object (sequelize.define(modelName, attributes, options)), I forgot timestamps: true.