Laravel:"未知数据库类型_int4已请求"在迁移中

时间:2016-09-19 08:15:31

标签: php laravel laravel-5.2 database-migration

我在一次迁移中创建了列user_id

public function up()
{
    Schema::create($this->_tableName, function (Blueprint $table) {
        $table->increments('id');

        $table->unsignedInteger('user_id')->index();
        $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
        ...

现在我尝试在第二次迁移中将此列设为可为空:

public function up()
{
    Schema::table($this->_tableName, function(Blueprint $table) {
        $table->unsignedInteger('user_id')->nullable()->change();
    });
}

但我获得了下一条消息:

$ php artisan migrate


  [Doctrine\DBAL\DBALException]                                                                          
  Unknown database type _int4 requested, Doctrine\DBAL\Platforms\PostgreSqlPlatform may not support it.  

有什么问题?

1 个答案:

答案 0 :(得分:0)

我不知道这个问题的根源。但现在我使用:

DB::statement("ALTER TABLE " . $this->_tableName . " ALTER COLUMN user_id DROP NOT NULL");