{"action":"created","issue":{"url":"https://api.github.com/repos/sequelize/sequelize/issues/3908","labels_url":"https://api.github.com/repos/sequelize/sequelize/issues/3908/labels{/name}","comments_url":"https://api.github.com/repos/sequelize/sequelize/issues/3908/comments","events_url":"https://api.github.com/repos/sequelize/sequelize/issues/3908/events","html_url":"https://github.com/sequelize/sequelize/issues/3908","id":86929645,"number":3908,"title":"Missing column \"createdAt\" when using \"field\" param with bulkCreate command","user":{"login":"aysbg","id":2363475,"avatar_url":"https://avatars.githubusercontent.com/u/2363475?v=3","gravatar_id":"","url":"https://api.github.com/users/aysbg","html_url":"https://github.com/aysbg","followers_url":"https://api.github.com/users/aysbg/followers","following_url":"https://api.github.com/users/aysbg/following{/other_user}","gists_url":"https://api.github.com/users/aysbg/gists{/gist_id}","starred_url":"https://api.github.com/users/aysbg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aysbg/subscriptions","organizations_url":"https://api.github.com/users/aysbg/orgs","repos_url":"https://api.github.com/users/aysbg/repos","events_url":"https://api.github.com/users/aysbg/events{/privacy}","received_events_url":"https://api.github.com/users/aysbg/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/sequelize/sequelize/labels/bug","name":"bug","color":"d7e102"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2015-06-10T11:07:52Z","updated_at":"2015-08-04T02:03:34Z","closed_at":null,"body":"I have this error since upgrading to 3.0: (`\"sequelize\": \"^3.2.0\"` to be precise)\r\n```\r\n{ [SequelizeDatabaseError: column \"createdAt\" of relation \"store_table\" does not exist]\r\n  name: 'SequelizeDatabaseError',\r\n  message: 'column \"createdAt\" of relation \"store_table\" does not exist',\r\n  parent:\r\n   { [error: column \"createdAt\" of relation \"store_table\" does not exist]\r\n     name: 'error',\r\n     length: 124,\r\n     severity: 'ERROR',\r\n     code: '42703',\r\n     detail: undefined,\r\n     hint: undefined,\r\n     position: '59',\r\n     internalPosition: undefined,\r\n     internalQuery: undefined,\r\n     where: undefined,\r\n     schema: undefined,\r\n     table: undefined,\r\n     column: undefined,\r\n     dataType: undefined,\r\n     constraint: undefined,\r\n     file: 'parse_target.c',\r\n     line: '923',\r\n     routine: 'checkInsertTargets',\r\n```\r\n\r\nAnd field is defined:\r\n```\r\nmodule.exports = function(sequelize) {\r\n  'use strict';\r\n\r\n  var DataTypes = require('sequelize');\r\n\r\n  return sequelize.define(\r\n    'store_table', {\r\n      id: {\r\n        type: DataTypes.INTEGER,\r\n        autoIncrement: true,\r\n        primaryKey: true\r\n      },\r\n\r\n      brandId: {\r\n        type: DataTypes.INTEGER,\r\n        field: 'brand_id',\r\n        references: 'brand',\r\n        referencesKey: 'id'\r\n      },\r\n\r\n      name: {\r\n        type: DataTypes.STRING,\r\n        allowNull: true,\r\n        validate: {\r\n          len: [1, 64]\r\n        }\r\n      },\r\n\r\n      address: {\r\n        type: DataTypes.TEXT,\r\n        allowNull: true,\r\n        validate: {\r\n          len: [1, 256]\r\n        }\r\n      },\r\n\r\n      createdAt: {\r\n        type: DataTypes.DATE,\r\n        field: 'created_at'\r\n      },\r\n\r\n      updatedAt: {\r\n        type: DataTypes.DATE,\r\n        field: 'updated_at'\r\n      }\r\n\r\n    }, {\r\n      freezeTableName: true\r\n    }\r\n  );\r\n};\r\n```\r\nAnd present in the DB, obviously under the name of `created_at`.\r\nAfter reading this issue: https://github.com/sequelize/sequelize/issues/2641 I tried by adding `underscored: true` flag and it does work as before.\r\n\r\nThe issue is only present on the bulkCreate "},"comment":{"url":"https://api.github.com/repos/sequelize/sequelize/issues/comments/127455654","html_url":"https://github.com/sequelize/sequelize/issues/3908#issuecomment-127455654","issue_url":"https://api.github.com/repos/sequelize/sequelize/issues/3908","id":127455654,"user":{"login":"huangbin30","id":13634390,"avatar_url":"https://avatars.githubusercontent.com/u/13634390?v=3","gravatar_id":"","url":"https://api.github.com/users/huangbin30","html_url":"https://github.com/huangbin30","followers_url":"https://api.github.com/users/huangbin30/followers","following_url":"https://api.github.com/users/huangbin30/following{/other_user}","gists_url":"https://api.github.com/users/huangbin30/gists{/gist_id}","starred_url":"https://api.github.com/users/huangbin30/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/huangbin30/subscriptions","organizations_url":"https://api.github.com/users/huangbin30/orgs","repos_url":"https://api.github.com/users/huangbin30/repos","events_url":"https://api.github.com/users/huangbin30/events{/privacy}","received_events_url":"https://api.github.com/users/huangbin30/received_events","type":"User","site_admin":false},"created_at":"2015-08-04T02:03:34Z","updated_at":"2015-08-04T02:03:34Z","body":"apply following patch to Model.prototype.bulkCreate will resolve this issue:\r\n\r\n    instances.forEach(function(instance) {\r\n      var values = instance.dataValues;\r\n\r\n      // set createdAt/updatedAt attributes\r\n      if (createdAtAttr && !values[createdAtAttr]) {\r\n        values[createdAtAttr] = now;\r\n      }\r\n      if (updatedAtAttr && !values[updatedAtAttr]) {\r\n        values[updatedAtAttr] = now;\r\n      }\r\n\r\n      instance.dataValues = Utils.mapValueFieldNames(values, options.fields, self);\r\n    });\r\n"}}