Port of the old syncdb code. Loathe to remove this as it's been there forever.