add legacyref table with orphaned ref ids