I havent generated a script yet, I entered an update for every class directly into a query window.
lets take shaman again for example:
update npc_types set npc_spells_id=6 where (class=10 or class=29) and npc_spells_id=0
and so on for every caster class.
As reference, take the npc_spells table and the link trevius posted above.
It worked like a charm. At least kelethin and north freeport casters are behaving now like what they are: casters

Havent tested bard guild yet.