I agree with the idea of a militia. A % of the population that's similar to a peon or worse (if that's possible). Basically something to prevent the example given by the OP. Take it from the existing population. If those units die, then the city also loses that number from the population. This encourages the garrison of a trained fighting force to protect the peasants from being destroyed... unless the sovereign doesn't care.
(forum search ftw)