You could do a rewrite that takes into account the bad old database schema, but doesn't repeat the wrong code design choices based on it.
Then, when that's ready and stable and working with the existing schema, it's way easier to do a refactor and adapt to the new schema too.