I have two fields i need to increment the character limit on. I're read through the documentation and to my surprise i found no option for it. Is it possible to do? If not, how should i go about solving this?

I could drop the column and re-create it with the correct properties, but i don't want to loose any data in the database.

推荐答案

Use Raw Queries:

/**
 * Make changes to the database.
 *
 * @return void
 */
public function up()
{
  DB::query('ALTER TABLE mytable MODIFY mycolumn VARCHAR(new-length)');
}

/**
 * Revert the changes to the database.
 *
 * @return void
 */
public function down()
{
  DB::query('ALTER TABL mytable MODIFY mycolumn VARCHAR(old-length)');
}

更换mytablemycolumnnew-lengthold-length.

For Laravel 5+ replace DB::query with DB::statement.

Laravel相关问答推荐

如何将错误从laravel恢复到inertiajs/vue 3应用程序?

为什么我的 Laravel 开发服务器不提供 public 文件夹下的文件?

如何返回Blade Laravel 中的按钮?

我在 laravel 中插入多个复选框值.我怎样才能做到这一点?

导出所有客户端不起作用,文件保存时没有名称和扩展名

基于值laravel提交表单后如何返回特定页面

RuntimeException 未安装 Zip PHP 扩展

所有 POST 请求上的 Laravel 4 CSRF

Laravel - 将变量从中间件传递到控制器/路由

RouteCollection.php 第 219 行中的 MethodNotAllowedHttpException

使用 Eloquent 的 Laravel 块方法

Laravel Electron邮件验证模板位置

Laravel vagrant up 不工作 - Errno::EADDRNOTAVAIL

如何在没有 Artisan 的情况下运行 Laravel?

Laravel:验证 json 对象

Laravel - 动态创建表(无需迁移)

在 laravel 中安装 vue 3.0

如何卸载 Laravel Passport

Laravel 单元测试依赖注入

如何在 Laravel 5 请求类中使用有时规则