title: On saving entity PrimaryGeneratedColumn value not generated, gives NOT NULL constraint error
body: <p>Typeorm 0.2.8</p>
  
  <p>I'm building an Ionic app for both mobile use and browser (PWA) use. Below is some shortened code from my project. I create a simple entity with a <code>PrimaryGeneratedColumn</code> and try to insert one instance. This generates an error about the primary column being <code>NULL</code>. Doesn't the word 'generated' mean the column value gets generated?</p>
  
  <p>Is this a bug? Something specific to the <code>sqljs</code> driver? Or something obvious and simple I missed?</p>
  
  <h3>Entity</h3>
  
  <pre><code>@Entity()
  export class MyEntity {
  
      @PrimaryGeneratedColumn()
      id:number;
  
      @Column()
      name:string;
  
      @CreateDateColumn()
      createdAt:string;
  }
  </code></pre>
  
  <h3>Migration</h3>
  
  <pre><code>export class Migration20181022133900 implements MigrationInterface {
  
      async up(queryRunner: QueryRunner): Promise&lt;any&gt; {
          await queryRunner.createTable(new Table({
              name: 'my_entity',
              columns: [
                  {
                      name: 'id',
                      type: 'int',
                      isPrimary: true,
                      isGenerated: true
                  },
                  {
                      name: 'name',
                      type: 'varchar'
                  },
                  {
                      name: 'createdAt',
                      type: 'timestamp',
                      'default': 'now()'
                  }
              ]
          }), true);
      }
  
      async down(queryRunner: QueryRunner): Promise&lt;any&gt; {
          await queryRunner.dropTable('my_entity');
      }
  }
  </code></pre>
  
  <h3>Database provider</h3>
  
  <pre><code>const DATABASE_SHARED_OPTIONS:Partial&lt;ConnectionOptions&gt; = {
      entities: [
          MyEntity
      ],
      logging: 'all',
      logger: new DatabaseLogger(),
      migrationsRun: true,
      migrations: [
          Migration20181022133900
      ]
  };
  @Injectable()
  export class Database {
  
      constructor(public platform:Platform) {}
  
      setup(): Promise&lt;Connection&gt; {
          let options: CordovaConnectionOptions | SqljsConnectionOptions;
  
          // Mobile app
          if (this.platform.is('cordova')) {
              options = {
                  type: 'cordova',
                  database: 'my_project.db',
                  location: 'default',
              };
              options = Object.assign(options, DATABASE_SHARED_OPTIONS);
          }
  
          // Browser PWA app
          else {
              options = {
                  type: 'sqljs',
                  autoSave: true,
                  location: 'my_project',
              };
              options = Object.assign(options, DATABASE_SHARED_OPTIONS);
          }
  
          return createConnection(options);
      }
  }
  </code></pre>
  
  <h3>App component</h3>
  
  <pre><code>export class MyApp {
  
      constructor(
          platform: Platform,
          database: Database
      ) {
        platform.ready().then(() =&gt; {
          database.setup()
              .then((connection) =&gt; {
                    this.insertTest();
              });
        });
      }
  
      insertTest() {
          const myEntity= new MyEntity();
          myEntity.name = 'foo';
          getRepository(MyEntity).save(myEntity)
              .then((data) =&gt; {
                    console.log(data); // never reached due to error
              });
      }
  }
  </code></pre>
  
  <p>The database log show the following query (with parameters <code>["foo"]</code>):</p>
  
  <pre><code>INSERT INTO "my_entity"("name", "createdAt") VALUES (?, datetime('now'))
  </code></pre>
  
  <p>The following error shows up in my console:</p>
  
  <pre><code>ERROR Error: Uncaught (in promise): QueryFailedError: NOT NULL constraint failed: my_entity.id
  </code></pre>
  
  <h3>Update 1</h3>
  
  <p>It only seems to give the error when using migrations. Removing the migrations and using <code>synchronize: true</code> on the database setting works and generates an <code>id</code> for the entity. So is there something wrong with my column definition in the migration code?</p>
  
  <pre><code>{
      name: 'id',
      type: 'int',
      isPrimary: true,
      isGenerated: true
  }
  </code></pre>
  
  <h3>Update 2</h3>
  
  <p>Okay, I fixed it. The migration configuration for a <code>@PrimaryGeneratedColumn</code> seems to be very specific. For anyone else facing this issue, this fixed it for me:</p>
  
  <pre><code>{
      name: 'id',
      type: 'integer', // instead of 'int', required for the increment strategy
      isPrimary: true,
      isGenerated: true,
      generationStrategy: 'increment' // thought this was the default
  }
  </code></pre>