About me
!
Christian Leo-Pernold
"#$%&'(⛰*+,-
.
@mazedlx
⭐
github.com/mazedlx
0
mazedlx.net
1
repod.at
3/37
Slide 4
Slide 4 text
Arbeitswelt & Schule
PHP (CodeIgniter 3)
MySQL
Various types of workshops to choose from
"Out of Control - was das Internet über dich weiß" (OOC)
4/37
Slide 5
Slide 5 text
OOC - Details
3 time slots per day
09:00 - 10:30
10:45 - 12:15
12:30 - 14:00
5/37
Slide 6
Slide 6 text
6/37
Slide 7
Slide 7 text
So they ended up with this
09:00 - 10:15
10:15 - 11:30
11:30 - 12:45
12:45 - 14:00
7/37
Slide 8
Slide 8 text
8/37
Slide 9
Slide 9 text
The task at hand
All dates for the first 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 superfluous fourth slot
9/37
Slide 10
Slide 10 text
How I would normally do it
Deactivate OOC
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
Activate OOC
10/37
Slide 11
Slide 11 text
How it should've been done
11/37
Slide 12
Slide 12 text
What really went down
Wrote small PHP program on production server
No tests, no dry runs
Run the program
Shit hits the fan
12/37
Slide 13
Slide 13 text
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
side
Let's change 400 rows back to their initial state by hand
13/37
Slide 14
Slide 14 text
¯\_(ϑ)_/¯
14/37
Slide 15
Slide 15 text
15/37
Slide 16
Slide 16 text
But then...
Hey Christian, there's something wrong with Arbeitswelt & Schule,
every workshop shows up with the same date.
— Some Administrator
16/37
Slide 17
Slide 17 text
ಠ ಠ
䡞
17/37
Slide 18
Slide 18 text
ಠ_ಠ
18/37
Slide 19
Slide 19 text
ಠ~ಠ
19/37
Slide 20
Slide 20 text
ಠoಠ
20/37
Slide 21
Slide 21 text
ಠ_ಥ
21/37
Slide 22
Slide 22 text
ಥ_ಥ
22/37
Slide 23
Slide 23 text
(˽°□°҂˽Ɨ ˍʓˍ)
23/37
Slide 24
Slide 24 text
24/37
Slide 25
Slide 25 text
Backups to the rescue!
25/37
Slide 26
Slide 26 text
Steps to fix 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.
26/37
Slide 27
Slide 27 text
Learnings
27/37
Slide 28
Slide 28 text
Database stuff is dangerous.
28/37
Slide 29
Slide 29 text
Backups are important.
29/37
Slide 30
Slide 30 text
No, they really are.
30/37
Slide 31
Slide 31 text
Seriously, do backups!
31/37
Slide 32
Slide 32 text
There’s (usually) no cmd/ctrl + z in your SQL tool of choice.
32/37
Slide 33
Slide 33 text
There’s commit and rollback though.
33/37
Slide 34
Slide 34 text
And there’s simulate query.
34/37
Slide 35
Slide 35 text
Adhere to your rules - and trust yourself!
35/37
Slide 36
Slide 36 text
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
6. Profit
36/37
Slide 37
Slide 37 text
!"
Slides can be found at
speakerdeck.com/mazedlx
37/37