Keep the old version until the new one works.
The model rewrote my login page and it looked beautiful — cleaner code, nicer layout, half the lines. I deleted the old version on the spot, because the new one was obviously better. Then I ran it, and the login button did nothing. No error, no crash, just a button that sat there. The old version had handled a weird case the new one never saw: a user with no profile picture, and the code that filled that gap was gone with the file I had just deleted. I spent the evening rebuilding from memory what I had thrown away in ten seconds.
A rewrite is a guess until it runs. It does not matter how clean it looks — clean code that does not work is still broken code, and the old ugly version that worked was worth more than the new pretty version that did not. The model does not know your edge cases unless you tell it, and the one edge case you forgot is always the one it drops. That is not the model failing. That is you deleting your only safety net before the replacement proved itself.
Now the rule is simple: the old version stays until the new one is running in front of me. I keep it in a second file, or I commit before the rewrite, or I just do not delete anything that day. The new code gets tested with the ugly data — the empty list, the missing picture, the user who never filled in their name — and only when all of that passes does the old version go. Most days that takes five minutes. The one day I skipped it cost me an evening.
Never trade a working version for a promising one. Keep the old one until the new one has earned its place.