V
V
Vic Shostak2018-04-02 15:57:11
PostgreSQL
Vic Shostak, 2018-04-02 15:57:11

In PostgreSQL 9.6, how do I change the initial ID value (auto-increment field) for a Django model?

Good afternoon!
I am using Django 2.0.3 with Python 3.5.3 and PostgreSQL 9.6 DB.
Can you please tell me how to set / change the initial value of ID (field with auto-increment) for the model? In my case, it is necessary to continue the numbering of orders from a certain date, so as not to violate all the accounting and so on.
Now everything is going on with me, logically, from the very beginning - 1, 2, 3, ...- but it needs to go like this: 159200, 159201, 159202, .... And this is necessary only for certain models (tables), and not for all.
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2018-04-02
@vikkyshostak

alter sequence appname_modelname_id_seq restart with 159200;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question