This week's project: Performing open heart surgery (not literal)

My business, a SaaS for irrigation district operations management called Watervize, consists of a #Django codebase that has grown over the past 8 years.

Despite being an amateur programmer and having zero ag knowledge at the start, I was fortunate to make a lot of the right decisions early on.

But I also made some major mistakes here and there (a 6 month foray into 'microservices' 😬 for instance).

1/3

But one thing I've had to work around more & more the past couple years was an incorrect early assumption.

It was one of those decisions where I didn't know what I didn't know - until it was too late & had become a critical part of the system.

Essentially, I have a few related models in an app, and I tied critical model fields & responsibilities to one which that should have been applied to others.

Also, the model names don't correctly reflect the concepts they need to support.

2/3

These models are used in literally thousands of places in the project - they're truly the heart of the system. And this weekend I am attempting a major heart surgery to rewire them.

This includes standard migrations, data migrations, and lots and lots of refactoring throughout the project.

Terrifying stuff.

Wish me luck 😬

3/3

#Programming #Refactoring #Decisions #Schema #DataModeling

@jack you got this 💪
@jack remember to do a good backup of the DB before attempting the migration.
Good luck!

@germanio Great point! I've got automated backups running twice a day to a separate remote location and I periodically pull backups to my local machine as well.

I've gotten very proficient at quickly restoring db backups 😆

@jack nice! yeah having a (proven) way to rollback is excellent to reduce risk.
Also, if you can figure out a way to make intermediate steps for the migration, that also helps.

@germanio I've been breaking the work down over the past couple weeks - writing notes, getting stuck, letting it work through my mind for a while, and then updating a bit more.

Essentially, I'm working through 4 big stages that won't (well, shouldn't 😅) block each other.

Working through the first now.

Hopefully it doesn't take too many do-overs, but thank goodness for git and backups. It's such a relief to know with certainty that I can always get back to the current state if it goes wrong.

@jack nice! Sounds really well thought.
Hope it goes smoothly 🤞