magic_removal table update

0 views
Skip to first unread message

Max Battcher

unread,
Jan 25, 2006, 3:56:21 AM1/25/06
to django...@googlegroups.com
I'm living on the bleeding edge (just migrated to rev. 2123) with my
current development, and followed the suggested ALTER TABLE commands
from the wiki page, and though I can read from the data (all of the
views work correctly), I can't save because all of the sequences are now
out of sync. I tried renaming the sequences to fit the new naming
scheme, but to no avail (Django is calling the new sequence name and the
table itself still refers to the old sequence name).

At this point I'm a bit stumped on how to properly do this. Is there an
easy way to resync the sequences in PostgreSQL that I've overlooked?

Otherwise, I'm assuming:

* Dump the data to a file
* Drop Cascade everything
* Re-install
* Import back from the file

I made a brief remark on the wiki page that someone should probably
amplify into some better general migration guideline.

--
--Max Battcher--
http://www.worldmaker.net/

Andreas Stuhlmüller

unread,
Jan 25, 2006, 4:04:17 AM1/25/06
to django...@googlegroups.com
On 1/25/06, Max Battcher <m...@worldmaker.net> wrote:
> At this point I'm a bit stumped on how to properly do this. Is there an
> easy way to resync the sequences in PostgreSQL that I've overlooked?

Did you try "django-admin.py sqlsequencereset"? This used to work for me.

Andreas

Jason Davies

unread,
Jan 25, 2006, 6:57:01 AM1/25/06
to Django users

Max Battcher wrote:
> I'm living on the bleeding edge (just migrated to rev. 2123) with my
> current development, and followed the suggested ALTER TABLE commands
> from the wiki page, and though I can read from the data (all of the
> views work correctly), I can't save because all of the sequences are now
> out of sync. I tried renaming the sequences to fit the new naming
> scheme, but to no avail (Django is calling the new sequence name and the
> table itself still refers to the old sequence name).

Yeah, you need to do something like:

ALTER TABLE auth_groups_id_seq RENAME TO auth_group_id_seq;
ALTER TABLE auth_groups ALTER id SET DEFAULT
nextval('public.auth_group_id_seq'::text);

...for each sequence that needs renaming.

Regards,
Jason

Adrian Holovaty

unread,
Jan 25, 2006, 9:58:21 AM1/25/06
to django...@googlegroups.com
On 1/25/06, Max Battcher <m...@worldmaker.net> wrote:
> I'm living on the bleeding edge (just migrated to rev. 2123) with my
> current development, and followed the suggested ALTER TABLE commands
> from the wiki page, and though I can read from the data (all of the
> views work correctly), I can't save because all of the sequences are now
> out of sync. I tried renaming the sequences to fit the new naming
> scheme, but to no avail (Django is calling the new sequence name and the
> table itself still refers to the old sequence name).

This is the one lame thing about PostgreSQL -- when you rename tables,
you have to rename the sequences as well. Here's an example:

ALTER TABLE chicagocrime_wards RENAME TO chicagocrime_ward;
ALTER TABLE chicagocrime_wards_id_seq RENAME TO chicagocrime_ward_id_seq;
ALTER TABLE chicagocrime_ward ALTER COLUMN id DROP DEFAULT;
ALTER TABLE chicagocrime_ward ALTER COLUMN id SET DEFAULT
nextval('public.chicagocrime_ward_id_seq'::text);

I will edit the RemovingTheMagic wiki page to add this example explicitly.

Adrian

--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org

Max Battcher

unread,
Jan 25, 2006, 10:51:17 PM1/25/06
to django...@googlegroups.com
Jason Davies wrote:
> ALTER TABLE auth_groups ALTER id SET DEFAULT
> nextval('public.auth_group_id_seq'::text);

This was the peculiar incantation I was looking for, thanks. Now I just
have a non-fatal, non-blocking error from the django_content_types table...

Reply all
Reply to author
Forward
0 new messages