UnhandledPromiseRejectionWarning: Error: Error: SequelizeDatabaseError: column "created_at" does not exist

189 views
Skip to first unread message

Hemant Joshi

unread,
Feb 18, 2020, 4:58:31 AM2/18/20
to Sequelize

 Hi , 

 I have a following XYZ Model . Even though i have added created_at column but still getting  SequelizeDatabaseError: column "created_at" does not exist.
 I am very new to Sequelize , kindly suggest what is the correct way for the same .

//define models this way
module.exports = (sequelize, DataTypes) => {
  const xyz = sequelize.define('XYZ', {
      id: {
        type: DataTypes.UUID,
        allowNull: false,
        primaryKey: true,
        defaultValue: DataTypes.UUIDV4
      },
      employee_id: {
        type: DataTypes.STRING,
        allowNull: true
      },
      legal_entity_id: {
        type: DataTypes.STRING,
        allowNull: true
      },
      financial_year: {
        type: DataTypes.STRING,
        allowNull: true
      },
      previous_employer: {
        type: DataTypes.JSONB,
        allowNull: true
      },
      master_salary: {
        type: DataTypes.ARRAY(DataTypes.JSONB),
        allowNull: true
      },
      created_at: {
        type: DataTypes.DATE,
        field: 'created_at'
      },

      updated_at: {
        type: DataTypes.DATE,
        field: 'updated_at'
      }
    }, {
      timestamps: false,
      underscored: true,
      freezeTableName: true,
      tableName: 'XYZ' })

     return XYZ;
  }
  
Regards,
Riya
Reply all
Reply to author
Forward
0 new messages