title: JavaScript - unable to create table using sequelize .create function
body: <p>At the top of the file, I have <code>const Sequelize = require('sequelize')</code>. After this, I did <code>sequelize.authenticate()</code>, and connection to database works. Then I have this to define my department table:</p>
  
  <pre><code>var Department = sequelize.define('Department', {
      departmentId: {
          type: Sequelize.INTEGER,
          primaryKey: true,
          autoIncrement: true
      },
      departmentName: Sequelize.STRING,
      }, {
          createdAt: false,
          updatedAt: false
  })
  </code></pre>
  
  <p>Then, I had <code>sequelize.sync()</code> which works. But when I try to create table:</p>
  
  <pre><code>module.exports.addDepartment = function(departmentData)
  {
      return new Promise(function(resolve, reject){
  
          for (var i in departmentData)
          {
              if (departmentData[i] == "")
                  departmentData[i] = null
          }
  
          Department.create(
              {
                  departmentId: departmentData.departmentId,
                  departmentName: departmentData.departmentName
              }
          ).then(() =&gt; { 
              resolve() 
          }).catch(() =&gt; { 
              reject("unable to create department") 
          })
      })
  }
  </code></pre>
  
  <p>It doesn't work. I made sure that <code>departmentData.departmentName</code> has a value and <code>departmentData.departmentId</code> is null. No matter what I try, this is what it prints on my console:</p>
  
  <blockquote>
    <p>Executing (default): CREATE TABLE IF NOT EXISTS "Departments" ("departmentId"  SERIAL , "departmentName" VARCHAR(255), PRIMARY KEY ("departmentId"));
    Executing (default): SELECT i.relname AS name, ix.indisprimary AS primary, ix.indisunique AS unique, ix.indkey AS indkey, array_agg(a.attnum) as
    column_indexes, array_agg(a.attname) AS column_names, pg_get_indexdef(ix.indexrelid) AS definition FROM pg_class t, pg_class i, pg_index ix, pg_attribute a WHERE t.oid = ix.indrelid AND i.oid = ix.indexrelid AND a.attrelid = t.oid AND t.relkind = 'r' and t.relname = 'Departments' GROUP BY
    i.relname, ix.indexrelid, ix.indisprimary, ix.indisunique, ix.indkey ORDER BY i.relname;
    Executing (default): INSERT INTO "Departments" ("departmentId","departmentName") VALUES (DEFAULT,'Creative Services') RETURNING *;
    unable to create department</p>
  </blockquote>
  
  <p>What am I doing wrong? Does anyone have any suggestion as to what I may be doing wrong?</p>