关于 artisan migrate 的问题,如何给 tinyInteger 类型加长度限制?
public function tinyInteger($column, $autoIncrement = false, $unsigned = false)
{
return $this->addColumn('tinyInteger', $column, compact('autoIncrement', 'unsigned'));
}
怎么设置tinyInteger的长度捏?
Schema::create('backend_user', function (Blueprint $table) {
$table->increments('id');
$table->string('nickname');
$table->string('email')->unique();
$table-> tinyInteger('type)->unique();
$table->string('password', 32);
$table->timestamps();
});
哥们,tinyInteger分为有符号和无符号,无符号是0-255,有符号是-127-127.你还限制他的长度干啥?明白了吗?最怕设计数据库的人不明白字段的属性,就瞎搞。另外,设置长度只是设置的显示的位数,例如,你设置int(2),表示只显示前两个数字,但是范围还是正负21亿。占的空间是4byte.