phinx中id字段设置为auto_increment,biginteger方法

如下,需要注意的是identity字段,而不是auto_increment。

$table = $this->table('test', ['id' => false, 'primary_key' => 'id']);
        $table->addColumn('id', 'biginteger', ['null' => false, 'signed' => false, 'identity' => true])
            ->addColumn('title', 'string', ['limit' => 50, 'null' => false])
            ->addColumn('created_at', 'datetime', ['null' => false])
            ->create();

Was this helpful?

0 / 0

发表回复 0