【发布时间】:2020-08-19 01:10:05
【问题描述】:
我是 PHP 和 laravel 平台的新手,在运行迁移任务以将表列类型从数字更改为字符串时需要您的帮助来解决 PDOException。
...
public function up()
{
Schema::table('BuildTable', function (Blueprint $table) {
$table->string('snapshot_id')->change();
});
}
....
在运行迁移任务时获取 PDOException
Doctrine\DBAL\Driver\PDOException::("SQLSTATE[0A000]: Feature not supported: 7 ERROR: unimplemented: type conversion from INT8 to VARCHAR(255) requires overwriting existing values which is not yet implemented
HINT: You have attempted to use a feature that is not yet implemented.
现有的表结构是使用
创建的 Schema::create(
$this->tablename,
function (Blueprint $table) {
$table->increments('id');
$table->integer('account_id')->unsigned();
$table->integer('snapshot_id')->unsigned();
$table->timestamps(6);
$table->softDeletes('deleted_at', 6)->default(null);
}
);
现有的表已经有snapshot_id中的数据
php 版本是 7.3.20 运行在 linux mint 操作系统,数据库 - cockroachDB
【问题讨论】:
-
克里斯,细节没有解决问题,我得到“SQLSTATE[0A000]: Feature not supported: 7 ERROR: unimplemented: type conversion from INT8 to VARCHAR(255) requires覆盖现有值尚未实施
-
我认为错误信息是不言自明的。您的表已经包含存储为
INT8的数据,并且您要求引擎转换为VARCHAR(255),但它不知道该怎么做。如果表中没有数据,情况会有所不同。你为什么要把看起来像外键的东西转换成字符串? -
@sykez @Unflux 你是对的,这是一个与数据库相关的问题,因为我在工具中直接执行 SQL 时也遇到了类似的异常。我们正在使用 cockroachDB,它看起来像从 INT8 到 VARCHAR 的直接数据转换功能不适用于这个特定版本
标签: php laravel postgresql migration