title: TypeORM: auto generated UUID in PostgreSQL
body: <p>I am writing an REST API and for data access I am using typeorm, I have used this successfully but I would like to have a UUID auto-generated primary key on one of my tables.</p>
  
  <p>Does anyone know how to setup a column in typeorm that is a UUID type and auto-generated, I have tried the following:</p>
  
  <p>Using <code>@PrimaryGeneratedColumn()</code></p>
  
  <pre><code>@PrimaryGeneratedColumn() id: string;
  </code></pre>
  
  <p>This gives me an exception when synchronising with the database</p>
  
  <pre><code>TypeORM connection error: Error: column "id" cannot be cast automatically to type integer
  app.ts:65
  at new QueryFailedError (/Users/neilstevens/repositories/Capp.co/capp/ms/ms-token-server/node_modules/typeorm/error/QueryFailedError.js:27:28)
  at Query.callback (/Users/neilstevens/repositories/Capp.co/capp/ms/ms-token-server/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:216:38)
  at Query.handleError (/Users/neilstevens/repositories/Capp.co/capp/ms/ms-token-server/node_modules/pg/lib/query.js:143:17)
  at Connection.connectedErrorHandler (/Users/neilstevens/repositories/Capp.co/capp/ms/ms-token-server/node_modules/pg/lib/client.js:132:26)
  at emitOne (events.js:115:13)
  at Connection.emit (events.js:210:7)
  at Socket.&lt;anonymous&gt; (/Users/neilstevens/repositories/Capp.co/capp/ms/ms-token-server/node_modules/pg/lib/connection.js:118:12)
  at emitOne (events.js:115:13)
  at Socket.emit (events.js:210:7)
  at addChunk (_stream_readable.js:266:12)
  </code></pre>
  
  <p>Using <code>@PrimaryColumn</code> and <code>@Generated</code></p>
  
  <pre><code>@PrimaryColumn({type:"uuid"})
  @Generated("uuid") id: string;
  </code></pre>
  
  <p>I get the following error when attempting this</p>
  
  <pre><code>TypeORM connection error: Error: sequence "SystemUser_id_seq" does not exist
  app.ts:65
  at new QueryFailedError (/Users/neilstevens/repositories/Capp.co/capp/ms/ms-token-server/node_modules/typeorm/error/QueryFailedError.js:27:28)
  at Query.callback (/Users/neilstevens/repositories/Capp.co/capp/ms/ms-token-server/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:216:38)
  at Query.handleError (/Users/neilstevens/repositories/Capp.co/capp/ms/ms-token-server/node_modules/pg/lib/query.js:143:17)
  at Connection.connectedErrorHandler (/Users/neilstevens/repositories/Capp.co/capp/ms/ms-token-server/node_modules/pg/lib/client.js:132:26)
  at emitOne (events.js:115:13)
  at Connection.emit (events.js:210:7)
  at Socket.&lt;anonymous&gt; (/Users/neilstevens/repositories/Capp.co/capp/ms/ms-token-server/node_modules/pg/lib/connection.js:118:12)
  at emitOne (events.js:115:13)
  at Socket.emit (events.js:210:7)
  at addChunk (_stream_readable.js:266:12)
  </code></pre>
  
  <p>So it looks like this way I can get a primary column but typeorm is not creating the sequence required for this to be an auto-generated column.</p>
  
  <p>If I use <code>@PrimaryColumn({type: "uuid"})</code> then I do get a UUID column in the table but <strong>NOT</strong> and auto-generated column</p>
  
  <p>I cannot see any other way to achieve this so could someone please advise if this is a) even possible and b) how one would go about creating a auto-generated UUID column...please?</p>