rewrite sql schema