Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migrate:run不创建表也不会报错 #78

Open
unicornboat opened this issue Mar 23, 2023 · 1 comment
Open

migrate:run不创建表也不会报错 #78

unicornboat opened this issue Mar 23, 2023 · 1 comment

Comments

@unicornboat
Copy link

unicornboat commented Mar 23, 2023

迁移的时候报错"extra" is not a valid column option. 应该怎么办?

class Contact extends Migrator
{
    public function change()
    {
        $table = $this->table('contact');
        $table->addColumn('user_id', 'integer', ['comment' => '用户 ID'])
            ->addColumn('contact_id', 'integer', ['comment' => '联系人 ID'])
            ->addColumn('type', 'enum', ['values' => ['normal', 'blocked'], 'default' => 'normal', 'comment' => '关系类型'])
            ->addColumn('created_at', 'datetime', array('null' => true, 'default' => 'CURRENT_TIMESTAMP', 'comment' => '创建时间'))
            ->addColumn('updated_at', 'datetime', array('null' => true, 'default' => 'CURRENT_TIMESTAMP', 'extra' => 'ON UPDATE CURRENT_TIMESTAMP', 'comment' => '更新时间'))
            ->create();
    }

    public function down()
    {
        $this->dropTable('contact');
    }
}
@yuanzhihai
Copy link

'extra' => 'ON UPDATE CURRENT_TIMESTAMP', 删除

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants