Jaymon / prom

A PostgreSQL or SQLite orm for Python
MIT License
22 stars 4 forks source link

Add ability to reset auto-increment sequence #59

Closed Jaymon closed 1 year ago

Jaymon commented 6 years ago

I recently had a need in a test to mess with the auto-increments and this is what I did:

        Foo.interface.query(
            "ALTER SEQUENCE {}__id_seq RESTART WITH 218832".format(Foo.table_name),
            ignore_result=True
        )
        Bar.interface.query(
            "ALTER SEQUENCE {}__id_seq RESTART WITH 24".format(Bar.table_name),
            ignore_result=True
        )

It would be great if this was codified into the Interface, it could also discover the field's primary key name.

helpful link

Jaymon commented 1 year ago

I've never needed to do this since and I don't think it needs to be codified into the interface and I don't think this issue needs to stay open