How can I set AUTO_INCREMENT in Laravel with Eloquent?

I'm working on an application and my employer wants the user table ID to start with 100,000 instead of 1. How can I do this? Is this a parameter in the schematic builder itself? Or do I need to install something in MySQL?

+3


source to share


1 answer


You can use SQL for yourself to do this. ALTER TABLE <table_name> AUTO_INCREMENT=100000;

...

Or

Do it like here

And use an unprepared statement;



$statement = "ALTER TABLE MY_TABLE AUTO_INCREMENT = 100000;";

DB::unprepared($statement);

      

or

DB::update("ALTER TABLE {your table name} AUTO_INCREMENT = 100000;");

      

which can then be put into a migration that creates the table.

+7


source







All Articles