Fix migrations and move associations into models.