Sure it can. Not in a vacuum, maybe, but with some guidance from the user as to dependency relations. Ideally you have enough data baked into your schema to infer those relations.
It is literally impossible for that to be done automatically. Someone needs to look at the resulting code and confirm that that was the case.