【问题标题】:Laravel: "Unknown database type _int4 requested" in migrationLaravel:迁移中的“未知数据库类型_int4请求”
【发布时间】:2017-01-26 20:35:47
【问题描述】:

我在一次迁移中创建了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.  

怎么了?

【问题讨论】:

    标签: php laravel laravel-5.2 database-migration


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 2020-01-14
      • 2015-05-23
      • 2017-12-03
      • 1970-01-01
      • 2016-01-13
      • 2021-01-25
      • 2017-09-14
      • 2019-11-18
      相关资源
      最近更新 更多