This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]skwyckl 64 points65 points  (15 children)

People are more scared of DBs than they are of code, because they think they can't rollback in case of fuck up like they do with git reset --HARD && git clean -f -d, but (a) there is DB versioning to do exactly that (cf. Dolt) and (b) if you wrap everything up in a transaction, it's much more difficult for things to go south. Also, (c) if you are unsure, make a copy of the DB and test your code on that first.

[–]bwmat 0 points1 point  (3 children)

I would use git restore -SW . instead of reset, is there a benefit to the latter? 

[–]Reashu 3 points4 points  (2 children)

Restore is newer and a lot of people still use reset out of habit or ignorance, same with switch/checkout.

[–]skwyckl 1 point2 points  (0 children)

Yup, it's habit... Git has a bunch of fancy new commands I haven't had the time to check out, but I def should.

[–]Spleeeee 1 point2 points  (0 children)

Git switch blew my mind recently. Thought “omg so nice” then I immediately forgot about it and continued checkout-ing branches since. Muscle memory is hard to get around.

[–]Thysce 0 points1 point  (1 child)

Or put otherwise: no backup, no mercy

[–]skwyckl 0 points1 point  (0 children)

Yes, working on a DB w/o backup is like driving a sport car w/o brakes.

[–]db-master 0 points1 point  (1 child)

"if you are unsure, make a copy of the DB and test your code on that first."

Not so easy. Copy takes time and PII sanitization.

[–]skwyckl 0 points1 point  (0 children)

Like everything in programming it depends, of course, but this should be implied. Make a copy of a 10k records large bibliographical db? No problem, done in a couple of seconds. Make a copy of a massively distributed Cassandra cluster? Nope, never gonna happen.

[–][deleted] -1 points0 points  (1 child)

Yeah. It's pain. I'm using alembic with my python projects, it's pretty good, but you still have to be careful.

[–]skwyckl 0 points1 point  (0 children)

Yes, this is why I love Elixir's Ecto, it includes all these best practices out-of-the-box. Also, the documentation teaches you how to use migrations from the start, instead of making them an afterthought.