我在一次迁移中创建了列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.
有什么问题?
答案 0 :(得分:0)
我不知道这个问题的根源。但现在我使用:
DB::statement("ALTER TABLE " . $this->_tableName . " ALTER COLUMN user_id DROP NOT NULL");