Thread
#exposed
    s

    savrov

    2 years ago
    Hello. Lets say, i need to reset in-memory database before each test. Reset - delete all existed rows and add default ones. But the problem is that after I call
    deleteAll()
    the PK value is not reseted to 0. Is there a way to do it?
    exec("ALTER SEQUENCE 'slots_id_seq' RESTART WITH 1")
    return me an error:
    Syntax error in SQL statement "ALTER SEQUENCE 'slots_id_seq'[*] RESTART WITH 1"; expected "identifier"
    tapac

    tapac

    2 years ago
    What
    in-memory
    database do you use? Maybe it's simplier allways recreate the whole database from the ground?
    s

    savrov

    2 years ago
    damn, i forgot that im using h2 database for tests and tried to apply postgresql command on it. for h2 its simple as:
    exec("ALTER TABLE slots ALTER COLUMN id RESTART WITH 1")