如何在Laravel模式中创建带符号的增量?

tot*_*dli 4 php laravel

我的迁移文件中包含以下内容:

public function up()
{
   Schema::create('Users', function($table)
   {
      $table->engine='InnoDB';
      $table->increments('id');
      $table->string('name', 255);
   });
}
Run Code Online (Sandbox Code Playgroud)

到目前为止,整个应用程序都使用了signedid,而我不想破坏它,那么如何制作它们signed呢?我知道默认值是unsigned并且有一个->unsigned()修饰符(如果这是默认值,我不明白这是什么意思),但是据此我认为也有一个->signed(),但是没有。以下代码运行无错误,但是当我在phpMyAdmin中观看该ID时,其ID仍未签名:

Schema::create('Users', function($table)
{
   $table->engine='InnoDB';
   $table->increments('id')->signed();
   $table->string('name', 255);
});
Run Code Online (Sandbox Code Playgroud)

我搜索了官方文件和非官方文件,但是他们都没有提及任何内容。那我该怎么做呢signed

ran*_*dom 5

如果您还希望对整数列进行签名,那么设置为自动增量的整数列就可以解决问题。

$table->integer('id', true);
Run Code Online (Sandbox Code Playgroud)

来自:framework / src / Illuminate / Database / Schema / Blueprint.php

/**
 * Create a new integer column on the table.
 *
 * @param  string  $column
 * @param  bool  $autoIncrement
 * @param  bool  $unsigned
 * @return \Illuminate\Support\Fluent
 */
public function integer($column, $autoIncrement = false, $unsigned = false)
{
  return $this->addColumn('integer', $column, compact('autoIncrement', 'unsigned'));
}
Run Code Online (Sandbox Code Playgroud)