public inbox for [email protected]
help / color / mirror / Atom feedFrom: Zahid Rahman <[email protected]>
To: Mike Dewhirst <[email protected]>
Cc: [email protected]
Subject: Re: Renaming sequences
Date: Wed, 18 Dec 2019 07:03:44 +0000
Message-ID: <CAPGSW3Tf6AzUZtaOt81C5EccV_vwDLx8CffWFxaQkAddtPq1TA@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
<CAPGSW3SRLw=NDMnJ0FDfnCR1Ld3Kvqdy4aROgxy5tjvJQAzLGQ@mail.gmail.com>
<[email protected]>
> The fact that it is working with mismatched names .
I just had a quick look at django. It is not something I know of or use.
Just a front end framework using python language as far as I can see.
>mismatched names
I suspect you have sequences with different names.
Use
Select * from sequence_name_a;
Select * from sequence_name_b;
If you get error free results then that means you have sequences with
different names.
If I understand what you are to begin with.
On Wed, 18 Dec 2019, 06:23 Mike Dewhirst, <[email protected]> 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.
>
> Thanks
>
>
>
> A *sequence* in*PostgreSQL* is a user-defined schema-bound object that
> generates a*sequence* 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 nextval, currval, and setval to operate on the sequence. These
> functions are documented in Section 9.16
> <https://www.postgresql.org/docs/9.5/functions-sequence.html;.
>
> 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, <[email protected]> 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
>>
>>
>
view thread (12+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected]
Subject: Re: Renaming sequences
In-Reply-To: <CAPGSW3Tf6AzUZtaOt81C5EccV_vwDLx8CffWFxaQkAddtPq1TA@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox