php - 如何使用 Laravel 迁移将字符串列类型转换为整数?

标签 php mysql laravel

我正在尝试使用 Laravel 迁移更改列数据类型。但我面临以下错误。请帮帮我。

Schema::table('files', function(Blueprint $table) {
    $table->integer('app_id')->change();
    $table->index(['app_id', 'filename']);
});

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CHARACTER SET utf8 DEFAULT 0 NOT NULL COLLATE utf8_unicode_ci' at line 1 (SQL: ALTER TABLE files CHANGE app_id app_id INT CHARACTER SET utf8 DEFAULT 0 NOT NULL COLLATE utf8_unicode_ci)

最佳答案

您的问题很可能是由 doctrine/dbal 的最新版本中的错误引起的。包裹。该问题是由 v2.10.0 引入的.

您可以随时在您的 composer.json 中降级该软件包。至 v2.9.3它应该工作得很好。

在这里查看官方问题:https://github.com/doctrine/dbal/issues/3714

关于php - 如何使用 Laravel 迁移将字符串列类型转换为整数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58976719/

相关文章:

php - laravel 5.5 邮件通知不更新内容

php - Symfony/Doctrine : getJoinTableName() must be of the type array, 给定为空

php - PHP 中的大括号语法?

php - 从查询中获取 MySQL 结果集大小

sql - MySQL 触发器只针对某个 mysql 用户

php - 从数据库中选择希伯来语数据时出现乱码

php - 字段列表中的列 'id' 在 YII 中不明确

mysql - 阿拉伯语单词更改为????插入Mysql数据库后

laravel - 将 recaptcha 添加到默认的 Laravel 密码重置

php - 无法访问方法中的构造变量(php laravel)