fixed migration messages thread sql script