Have you ever done something so incredibly stupid that you questioned all your life choices? I did, so you don’t have to. Let me tell you a story of why it is important to have a set of rules and stick to them.
How to NOT fuck up your day
Arbeitswelt & Schule
PHP (CodeIgniter 3)
Various types of workshops to choose from
"Out of Control - was das Internet über dich weiß" (OOC)
OOC - Details
3 time slots per day
09:00 - 10:30
10:45 - 12:15
12:30 - 14:00
So they ended up with this
09:00 - 10:15
10:15 - 11:30
11:30 - 12:45
12:45 - 14:00
The task at hand
All dates for the ﬁrst 6 months of 2020 were already created
Don't touch those that were already booked
Edit all other dates and revert them to the original time slots
Remove any superﬂuous fourth slot
How I would normally do it
Copy production DB down to my machine
Write small PHP program that fetches the corresponding rows
Make the program spit out SQL statements
Test those SQL statements on my machine
Make sure everything went as planned
Do stuff on the production DB
How it should've been done
What really went down
Wrote small PHP program on production server
No tests, no dry runs
Run the program
Shit hits the fan
What happened next
All 2020 timeslots were updated to 2020-01-07 09:00 - 10:30
That's about 400 rows
Got a small export in Excel beforehand, just to be on the safe
Let's change 400 rows back to their initial state by hand
Hey Christian, there's something wrong with Arbeitswelt & Schule,
every workshop shows up with the same date.
— Some Administrator
Backups to the rescue!
Steps to ﬁx your fuck up
1. Stop right now.
2. Turn on maintenance mode.
3. Inform key users.
4. Request backup.
5. Restore and make sure you didn’t fuck up too much. Backups tend to be older than 5 minutes ago.
6. Don’t fuck up again.
7. Live on.
Database stuff is dangerous.
Backups are important.
No, they really are.
Seriously, do backups!
There’s (usually) no cmd/ctrl + z in your SQL tool of choice.
There’s commit and rollback though.
And there’s simulate query.
Adhere to your rules - and trust yourself!
I fucked up at least two times in my 15+ years being a developer because I
didn’t follow my own rules:
1. Copy production to local
2. Try stuff locally
3. Make sure everything went as expected
4. Then do stuff in production
5. Make sure you didn’t fuck up
Slides can be found at