Re: magic_removal table update

2006-01-25 Thread Max Battcher


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


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


Re: magic_removal table update

2006-01-25 Thread Adrian Holovaty

On 1/25/06, Max Battcher <[EMAIL PROTECTED]> 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


Re: magic_removal table update

2006-01-25 Thread Jason Davies


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



Re: magic_removal table update

2006-01-25 Thread Andreas Stuhlmüller

On 1/25/06, Max Battcher <[EMAIL PROTECTED]> 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


magic_removal table update

2006-01-25 Thread Max Battcher


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/