Improve partition generation code. BUG: constraints added to parent table by accident