I have the following in my migration file:
public function up()
{
Schema::create('Users', function($table)
{
$table->engine='InnoDB';
$table->increments('id');
$table->string('name', 255);
});
}
So far the whole application used signed
ids, and I don't want to break this so how can I make them signed
? I know that the default value is unsigned
and that there is a ->unsigned()
modifier (that I don't understand whats is for if this is the default value) but from this I supposed there is a ->signed()
too, but there isn't. The following code runs without errors but the id is still unsigned when I watch it in phpMyAdmin:
Schema::create('Users', function($table)
{
$table->engine='InnoDB';
$table->increments('id')->signed();
$table->string('name', 255);
});
I searched the official and a non official documentation but none of them mentioned anything about this. So how can I make it signed
?
An integer column set to auto-increment should do just the trick if you also want it signed.
$table->integer('id', true);
From: 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'));
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With