How to set AUTO_INCREMENT in Laravel with Eloquent?

前端 未结 1 1050
夕颜
夕颜 2021-01-21 03:58

I am working on an application and my employer wants that the id in the user table should begin from 100,000 instead of 1. How can accomplish that? Is it a parameter in the Sche

相关标签:
1条回答
  • 2021-01-21 04:16

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

    Or

    Do it like here

    And use a 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 could then be put within the migration that creates the table.

    0 讨论(0)
提交回复
热议问题