我正在尝试将 Postgres 和 Laravel 6.x 上的列从字符串类型更改为整数。我尝试通过这样的迁移来做到这一点:
public function up()
{
Schema::table('job_listings', function (Blueprint $table) {
$table->integer('company_id')->change();
});
}
当我运行此迁移时,出现错误,表明该列无法自动转换为整数:
In Connection.php line 664:
SQLSTATE[42804]: Datatype mismatch: 7 ERROR: column "company_id" cannot be cast automatically to type integer
HINT: You might need to specify "USING company_id::integer". (SQL: ALTER TABLE job_listings ALTER company_id TYPE INT)
In PDOStatement.php line 123:
SQLSTATE[42804]: Datatype mismatch: 7 ERROR: column "company_id" cannot be cast automatically to type integer
HINT: You might need to specify "USING company_id::integer".
In PDOStatement.php line 121:
SQLSTATE[42804]: Datatype mismatch: 7 ERROR: column "company_id" cannot be cast automatically to type integer
HINT: You might need to specify "USING company_id::integer".
在 PostgreSQL 中,我们如何指定 USING 将此列从字符串类型更改为整数类型?
千万里不及你
Helenr