generalize the various table regen functions in order to share more code.
also, use table regeneration instead of ALTER TABLE when adding fields, as it provides more flexibility for sqlite.