title: Node.js Sequelize UUID primary key + Postgres
body: <p>I try to create database model by using sequelize but I'm facing a problem with model's primary key.</p>
  <h3>Setting</h3>
  <p>I'm using Postgres (v10) in docker container and sequalize (Node.js v10.1.0
  ) for models and GraphQL (0.13.2) + GraphQL-Sequalize (8.1.0) for request processing.</p>
  <h3>Problem</h3>
  <p>After creating models by sequelize-cli I've <strong>manually tried to replace id column with uuid</strong>. Here's my model migration that I'm using.</p>
  <pre><code>'use strict';
  const DataTypes = require('sequelize').DataTypes;
  
  module.exports = {
    up: (queryInterface, Sequelize) =&gt; {
      return queryInterface.createTable('Currencies', {
        uuid: {
          primaryKey: true,
          type: Sequelize.UUID,
          defaultValue: DataTypes.UUIDV4,
          allowNull: false
        },
        name: {
          type: Sequelize.STRING
        },
        ticker: {
          type: Sequelize.STRING
        },
        alt_tickers: {
          type: Sequelize.ARRAY(Sequelize.STRING)
        },
        createdAt: {
          allowNull: false,
          type: Sequelize.DATE
        },
        updatedAt: {
          allowNull: false,
          type: Sequelize.DATE
        }
      });
    },
    down: (queryInterface, Sequelize) =&gt; {
      return queryInterface.dropTable('Currencies');
    }
  };
  </code></pre>
  <p>Model:</p>
  <pre><code>'use strict';
  module.exports = (sequelize, DataTypes) =&gt; {
      const Currency = sequelize.define('Currency', {
          uuid: DataTypes.UUID,
          name: DataTypes.STRING,
          ticker: DataTypes.STRING,
          alt_tickers: DataTypes.ARRAY(DataTypes.STRING)
      }, {});
      Currency.associate = function(models) {
          // associations can be defined here
      };
      return Currency;
  };
  </code></pre>
  <p>Due to some problem sequalize executes next expression:</p>
  <blockquote>
  <p>Executing (default): SELECT &quot;id&quot;, &quot;uuid&quot;, &quot;name&quot;, &quot;ticker&quot;, &quot;alt_tickers&quot;, &quot;createdAt&quot;, &quot;updatedAt&quot; FROM &quot;Currencies&quot; AS &quot;Currency&quot; ORDER BY &quot;Currency&quot;.&quot;id&quot; ASC;</p>
  </blockquote>
  <p>That leads to &quot;column 'id' doesn't exist&quot; error.</p>
  <p>Alternatively, I've tried to fix it by renaming <em>uuid</em> column to <em>id</em> at migration:</p>
  <pre><code>  ...      
    id: {
        allowNull: false,
        primaryKey: true,
        type: Sequelize.UUID,
        defaultValue: Sequelize.UUIDV4()
    },
    ... 
  </code></pre>
  <p>And at the model:</p>
  <pre><code>'use strict';
  module.exports = (sequelize, DataTypes) =&gt; {
      const Currency = sequelize.define('Currency', {
          id: DataTypes.INTEGER,
          name: DataTypes.STRING,
          ticker: DataTypes.STRING,
          alt_tickers: DataTypes.ARRAY(DataTypes.STRING)
      }, {});
      Currency.associate = function(models) {
          // associations can be defined here
      };
      return Currency;
  };
  </code></pre>
  <p>but the result was the following error at the start of the program:</p>
  <blockquote>
  <p>Error: A column called 'id' was added to the attributes of 'Currencies' but not marked with 'primaryKey: true'</p>
  </blockquote>
  <h3>Questions</h3>
  <ul>
  <li>So, is there a way to force sequelize to use UUID as the tables primary key without defining id column?</li>
  <li>Is there a way to create columns without id columns?</li>
  <li>What possibly caused this errors and how should fix it?</li>
  </ul>
  <p>Thanks in advance!</p>