Skip to content

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

@unicornboat

Description

@unicornboat

迁移的时候报错"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');
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions