Re: Renaming sequences

Alvaro Herrera <[email protected]> Wed, 18 Dec 2019 08:34:31 -0300
Newsgroups gmane.comp.db.postgresql.novice
Message-ID <[email protected]>
On 2019-Dec-18, Mike Dewhirst wrote:

> 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.

I don't know django, but it's certainly possible that it's obtaining the
sequence name from the Postgres catalogs, not from its own migration
record; there's introspection facilities in Postgres for that.  I would
be surprised if it breaks just because you rename a sequence whose name
does not appear directly in its database definition.

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services