We are going to change something that we have an enum to an id of a linked table instead.
How would we go about that?
Our current enum name: strat
Our new linked name: stratid
What I was thinking was something along the lines of:
UPDATE table_name
SET stratid = (SELECT id FROM link_table WHERE stratname = table_name.strat);
I have not created the link table yet, right now it is all theory.
Will the above work?
Is there anything I should change in order to transfer from an enum to the linked table?
No gotchas for making the update other than that you
needwant to make triple sure that yourlink_table.ids are populated strictly in the order thattable_name.stratoptions are defined.For example, if
stratisenum('FOO', 'BAR')then inlinked_tablethe record withid == 1should be the “FOO” record.After that, you ‘d perhaps want to make the
stratidcolumnNON NULL; this is not strictly equivalent to your previous arrangement, but it would probably be closer to what you want.