Forum OpenACS Q&A: Help with upgrade.sql

Collapse
Posted by Roberto Mello on

I am doing the upgrade.sql nad need some help with my SQL...

How do I alter a column ? I know about ALTER TABLE foo ALTER COLUMN bar, but according to PG's docs it only lets me change the defaults. As a specific example, I want to change

topic_id varchar(100) not null

to

topic_id integer not null references users

How do I change a constraint ? Can I add something to a constraint or do I have to drop it and then recreate it ? Consequences of that ?

P.S: I am no SQL guru (yet 😊), but I am trying to do this and I'll probably have many questions. Any suggestions, tips, guidelines are appreciated. If someone wants to pitch in and work with me on this, great.

P.S2: I am working from a diff between the newest OpenACS on the CVS (since it wasn't that long ago) and the beta 2 release. Should I do it from the beta 3 release instead ?

Collapse
Posted by Titi Ala'ilima on
PG doesn't have a very extensive alter table command, and changing
the type of a column is a pretty hairy ordeal.  All I'd suggest is rename the  original topic_id to something else,  add the new topic_id column with a default value, update the column based on the value of
the old column, and then drop the default.