Appeals court halts long-term migrant detention