Resetting autoincrement in h2

前端 未结 3 741
无人及你
无人及你 2021-01-04 20:38

I\'m testing a controller that returns a json response but the tests fail after the first time because the h2 database does not reset the auto increment id. Using fixtures o

3条回答
  •  我在风中等你
    2021-01-04 21:15

    Start your play app, fire up browser with this url (if you run play app locally):

    http://localhost:9000/@db
    

    Enter your h2 db, and type the command below and run:

    ALTER TABLE  ALTER COLUMN  RESTART WITH 1
    

    If you'd like to do this programmatically, Fixtures.executeSQL() might be useful

    For more information, check http://www.h2database.com/html/grammar.html#alter_table_alter

提交回复
热议问题