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

Reply via email to