Change starting id number

前端 未结 6 923
灰色年华
灰色年华 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:46

    for PostgreSQL:

    execute("ALTER SEQUENCE accounts_id_seq START with 1000 RESTART;")
    

    see https://www.postgresql.org/docs/current/static/sql-altersequence.html

提交回复
热议问题