Re: Renaming sequences

Поиск
Список
Период
Сортировка
От Mike Dewhirst
Тема Re: Renaming sequences
Дата
Msg-id 711c4f7f-11a7-8065-9906-d2b9dfc1dbb5@dewhirst.com.au
обсуждение исходный текст
Ответ на Renaming sequences  (Mike Dewhirst <miked@dewhirst.com.au>)
Ответы Re: Renaming sequences  (Zahid Rahman <zahidr1000@gmail.com>)
Re: Renaming sequences  (Alvaro Herrera <alvherre@2ndquadrant.com>)
Список pgsql-novice
On 18/12/2019 5:03 pm, Zahid Rahman wrote:

If you are referring to a sequence which meets the same definition below. That is to say a persistent number generator. 

Surely by  changing  the sequence name then any  code using that sequence by name will fail. That's from an application developer's view.


Yes.

I think I'd better ask on the Django users list.

The fact that it is working with mismatched names probably means it would stop working if I adjusted them. Django probably reads the migration record to establish which sequence to use.

Thanks



sequence inPostgreSQL is a user-defined schema-bound object that generates asequence of integers based on a specified specification. To create a sequence in PostgreSQL, you use the CREATE SEQUENCE statement.

After a sequence is created, you use the 

functions nextvalcurrval, and setval to operate on the sequence. These functions are documented in Section 9.16.

Although you cannot update a sequence directly, you can use a query like:

SELECT * FROM name;


On Wed, 18 Dec 2019, 05:33 Mike Dewhirst, <miked@dewhirst.com.au> wrote:
Are there any consequences for renaming sequences to match the tables which own them?

In an existing production Django project I have just converted auth.user into common.user and company.userprofile into common.userprofile.

Having gone through the migration process more or less unscathed the original sequences are owned by the renamed tables. Eg public.auth_user_id_seq is owned by public.common_user.id

Everything seems to work fine but my unit tests are playing up and error messages are showing the original (and still correct) sequence names. It would make much visual sense to me now and especially to the future me (or anyone else) if the sequences were renamed as well.

I know how I could do it but I just need to know if I should.

Thanks for any advice

Mike


В списке pgsql-novice по дате отправления:

Предыдущее
От: Zahid Rahman
Дата:
Сообщение: Fwd: Renaming sequences
Следующее
От: Zahid Rahman
Дата:
Сообщение: Re: Renaming sequences