我正在使用Laravel 5.3,迁移功能非常好用,可控制数据库开发。
我的问题是:当我将列类型从字符串更改为文本时,一切都运行良好。但是,如果用户保存的数据长度超过了255(varchar),则我的迁移无法回滚。它会显示“列数据过长”。请问大家有什么解决方法?
Seeder(种子节点):
我的问题是:当我将列类型从字符串更改为文本时,一切都运行良好。但是,如果用户保存的数据长度超过了255(varchar),则我的迁移无法回滚。它会显示“列数据过长”。请问大家有什么解决方法?
Schema::table('tbname', function(Blueprint $table)
{
$table->text('value')->change();
});
Schema::table('tbname', function(Blueprint $table)
{
$table->string('value')->change();
});
Seeder(种子节点):
$records = [
[
'description' => 'The description is longer than 255. The description is longer than 255. The description is longer than 255. The description is longer than 255. The description is longer than 255. The description is longer than 255. The description is longer than 255. The description is longer than 255. The description is longer than 255. The description is longer than 255. The description is longer than 255. '
],
[
'description' => 'The description is longer than 255. The description is longer than 255. The description is longer than 255. The description is longer than 255. The description is longer than 255. The description is longer than 255. The description is longer than 255. The description is longer than 255. The description is longer than 255. The description is longer than 255. The description is longer than 255. '
]
];
foreach ($records as $index => $record) {
Desc::create($record);
}