New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.6] Support initial auto_increment #22587

Closed
wants to merge 2 commits into
base: 5.6
from

Conversation

Projects
None yet
4 participants
@carusogabriel
Contributor

carusogabriel commented Dec 31, 2017

Inspired by @LaravelDaily's post about set auto-increment, I've added that functionality to our increments* columns:

$table->increments('id', 100);

Still working in other databases beyond MySQL 馃毀

@GrahamCampbell GrahamCampbell changed the base branch from 5.5 to 5.6 Jan 1, 2018

@GrahamCampbell GrahamCampbell changed the title from [5.5] Support initial auto_increment to [5.6] Support initial auto_increment Jan 1, 2018

@GrahamCampbell

This comment has been minimized.

Show comment
Hide comment
@GrahamCampbell

GrahamCampbell Jan 1, 2018

Member

Please use camelCase for variable names.

Member

GrahamCampbell commented Jan 1, 2018

Please use camelCase for variable names.

* @return \Illuminate\Support\Fluent
*/
public function integer($column, $autoIncrement = false, $unsigned = false)
public function integer($column, $autoIncrement = false, $unsigned = false, $auto_increment = 1)

This comment has been minimized.

@carusogabriel

carusogabriel Jan 1, 2018

Contributor

@GrahamCampbell but then we conflict with the existing one. Any suggestions? 馃様

@carusogabriel

carusogabriel Jan 1, 2018

Contributor

@GrahamCampbell but then we conflict with the existing one. Any suggestions? 馃様

@taylorotwell

This comment has been minimized.

Show comment
Hide comment
@taylorotwell

taylorotwell Jan 1, 2018

Member

No plans to add right now.

Member

taylorotwell commented Jan 1, 2018

No plans to add right now.

@carusogabriel carusogabriel deleted the carusogabriel:auto-increment branch Jan 1, 2018

@timothymarois

This comment has been minimized.

Show comment
Hide comment
@timothymarois

timothymarois Oct 11, 2018

@taylorotwell Was this never implemented? It should be. I never like to start items at 1 with incremental ids.

You'll have to run a raw query like this: And that's a bit lame since we have a whole Schema dedicated to building these tables out.

DB::statement("ALTER TABLE table AUTO_INCREMENT = 1000;");

I also don't think it should be on the $table->increments() method, but rather on the variable for table options like the use of $table->engine = 'InnoDB'; which is on the same level. To follow by standard SQL options, it should be it's own property.

$table->auto_increment = 1000;

Those table options are described here,
https://laravel.com/docs/5.7/migrations#tables

timothymarois commented Oct 11, 2018

@taylorotwell Was this never implemented? It should be. I never like to start items at 1 with incremental ids.

You'll have to run a raw query like this: And that's a bit lame since we have a whole Schema dedicated to building these tables out.

DB::statement("ALTER TABLE table AUTO_INCREMENT = 1000;");

I also don't think it should be on the $table->increments() method, but rather on the variable for table options like the use of $table->engine = 'InnoDB'; which is on the same level. To follow by standard SQL options, it should be it's own property.

$table->auto_increment = 1000;

Those table options are described here,
https://laravel.com/docs/5.7/migrations#tables

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment