php - DB:SEED Laravel 6 不起作用
问题描述
这是我得到的错误。
chenasmartin@MacBook-Air-von-Chenas blog % php artisan db:seed
Illuminate\Database\QueryException : SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'description' at row 1 (SQL: insert into `companies` (`user_id`, `cname`, `slug`, `address`, `phone`, `website`, `logo`, `cover_photo`, `slogan`, `description`, `updated_at`, `created_at`) values (57, Ondricka-Mraz, ondricka-mraz, 4277 Helga Mount
Amandaview, OH 09189, 231-727-1719, parisian.net, avatar/man.jpg, cover/tumblr-image-sizes-banner.png, learn-earn and grow, Nesciunt eveniet quia iste. Architecto ipsa ad provident molestias rem nisi. Blanditiis tempora nostrum sequi error excepturi velit occaecati. Quis ab et ab reprehenderit. Facere quae et odio deserunt dolores vel autem provident. Eligendi eum dolore eos sunt dolorem. Vero est odio vel quia cum et. Velit quia et sed ipsa. Vero rerum iste laboriosam deserunt expedita similique et hic. Consequuntur enim assumenda repellat et inventore numquam. Ut saepe et beatae rerum facere. Ullam quia laudantium nisi. Autem sint sed eos fugit voluptatibus alias., 2021-03-25 12:32:59, 2021-03-25 12:32:59))
at /Applications/XAMPP/xamppfiles/htdocs/blog/vendor/laravel/framework/src/Illuminate/Database/Connection.php:669
665| // If an exception occurs when attempting to run a query, we'll format the error
666| // message to include the bindings with SQL, which will make this exception a
667| // lot more helpful to the developer instead of just the database's errors.
668| catch (Exception $e) {
> 669| throw new QueryException(
670| $query, $this->prepareBindings($bindings), $e
671| );
672| }
673|
Exception trace:
1 PDOException::("SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'description' at row 1")
/Applications/XAMPP/xamppfiles/htdocs/blog/vendor/laravel/framework/src/Illuminate/Database/Connection.php:463
2 PDOStatement::execute()
/Applications/XAMPP/xamppfiles/htdocs/blog/vendor/laravel/framework/src/Illuminate/Database/Connection.php:463
Please use the argument -v to see more details.
https://github.com/chenas-sketch/Factory
这是我的 github 和我发布的代码。
解决方案
您有一个companies
带有字符串列的表,称为description
字符串列,它不能容纳长文本,请将其从字符串更改为文本,以便它可以容纳这么多的数据。
因此,在您的 create_companies_table 迁移中:
$table->text('description')->nullable(); // nullable or not it's your choice
推荐阅读
- python - 具有线性目标函数的 Python 离散优化
- java - 如何使用泛型和供应商 lambda 安全地修复抽象方法上的这种类型不匹配
- python - Django Rest 框架 - 发布外键
- python-3.x - Modulating Bokeh Servers within Flask
- mongodb - Mongo Aggregation Grouping and Mapping of Object Array
- ios - WCSession:在 iOS 上提交的数据永远不会在 Watch 上收到
- sql-server - SELECT 语句中的 SQL Server NULL 检查
- java - 视频开始播放之前的java vlcj长时间延迟
- c# - Convert PHP's dot concatenation of a binary part + string part to C#
- jquery - 在引导程序模态中创建引导程序表单时控制不对齐