How to reset auto increment in laravel user deletion?

前端 未结 4 630
北恋
北恋 2021-02-05 09:17

I have been struggling to find out a way to reset the auto increment value in Laravel 4 but it seems that this functionality is not embedded in laravel 4 at least for now. so i

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-05 10:07

    If you are using PostgreSQL:

    public function resetAutoincrement()
    {
        $max = DB::table('users')->max('id') + 1;
        DB::statement('ALTER SEQUENCE users_id_seq RESTART WITH ' . $max);
    }
    

提交回复
热议问题