Change starting id number

前端 未结 6 1095
灰色年华
灰色年华 2021-02-05 10:53

I have an \'Account\' model in Rails with its corresponding \'accounts\' table in the database. If I wipe the database and start over, the \'account_id\' field will always star

6条回答
  •  天命终不由人
    2021-02-05 11:31

    You'll need to do some specialized database-dependent SQL to get this functionality.

    If you're using MySQL, you can add the following code to your migration after the create_table code:

    execute("ALTER TABLE tbl AUTO_INCREMENT = 1000")
    

提交回复
热议问题