Laravel 5.5在迁移文件中设置整数字段的大小 [英] Laravel 5.5 set size of integer fields in migration file

查看:63
本文介绍了Laravel 5.5在迁移文件中设置整数字段的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是laravel的新手.

I am new to laravel.

现在我正在使用migration命令制作表,但是字段的长度不适用.Laravel不提供此选项.?

Now i am using the migrate command to make a table, but the length of the filed is not applicable. Laravel does not provide this option. ?

以下是我的代码:

$table->increments('id')->length(11);
$table->dateTime('created_time');
$table->integer('bank_id')->length(11);
$table->tinyInteger('is_black')->length(1);

字段 is_black 的长度应为1,但实际上是作为4生成的.我该如何解决这个问题?

The length of the field is_black should be 1, but it is actually being generated as 4. How can I solve this problem ?

任何建议或建议都将不胜感激.

Any suggestion or advice would be appreciated.

提前谢谢

推荐答案

您不能执行此操作,但是可以使用其他类型的整数:

You can't do this, but you can use different types of integer:

$table->bigInteger()
$table->mediumInteger()
$table->integer()
$table->smallInteger()
$table->tinyInteger()

https://laravel.com/docs/5.5/migrations#columns

这篇关于Laravel 5.5在迁移文件中设置整数字段的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆