Naomikho,
@Naomikho@monyet.cc avatar

I actually screwed up twice on dev environment. Luckily the second case was salvageable without using data from an old backup(I wasn’t given one that time) and I managed to sweep it up fast.

I started testing my queries super carefully after the first incident, but I was too tired once that I forgot to restrict the update scope for testing and screwed up again.

threelonmusketeers, (edited )

https://youtu.be/X6NJkWbM1xk :)

Whenever SQL databases come up, I always think of this video from one of the greatest ‘content’ creators in history.

SzethFriendOfNimi,

Transactions are your friend here

Begin transaction;

Then

Your sql here

Double/triple check the messages/console for results. Look good?

Commit;

Worried?

Rollback;

Just be sure to mind your transaction logs for long running queries and by all things holy be sure you’re not doing this to a live db with a ton of transactions since you’re basically pausing any updates until the commit or rollback on the affected tables

xmunk,

This makes it safer but like… don’t run queries on production outside emergencies ever.

That transaction frame, depending on your specific DB, may cause severe performance side effects.

Look, the safe approach is to write it into something, PR it, get it reviewed, and then run it as part of a structured deployment process.

SzethFriendOfNimi,

Absolutely. It should have been tested and verified.

JoMiran,
@JoMiran@lemmy.ml avatar

Me: “Ok. What’s the big deal.”

Also me: “Less than a million affected. That’s nothing.”

Still me: “Rule 1: Never let pesky details get in the way of a funny meme.”

Ultimately me: 😱😂 “That guy is in for a rough Monday!”

derfl007,

oopsie daisy moment

TangledHyphae, (edited )

Looks like little bobby tables is at it again. (edit: for reference: xkcd.com/327/)

Edit #2: For lemmy app users: xkcd.com/327

And thanks to @Gestrid for the correction.

Gestrid,

My Lemmy app doesn’t like that parenthese. Fixed link in case anyone else is affected: xkcd.com/327/

TangledHyphae,

Sorry about that, I will update future links to not use parenthesis.

Gestrid,

No problem. And all you need to do, really, is put a space between the link and the parenthese.

Tenthrow,
@Tenthrow@lemmy.world avatar

This is giving me PTSD

argo_yamato,

Had something like that happen to a local dev database (thankfully). A dev next me blurts out “how to I rollback an update in SQL server”? He was used to Oracle and how easy it is to rollback something. Had to explain that commit just happens in SQL server regardless of whether or not you put that commit line in.

originalucifer,
@originalucifer@moist.catsweat.com avatar

wasnt halloween last week. stop scarin me

neosheo,
@neosheo@discuss.tchncs.de avatar

I’m dying lol

r00ty,
@r00ty@kbin.life avatar

For MS-SQL. If it is production, it has a full transaction log, right? I mean I know for development use I turn that off, but for live data you want that on. You should be able to roll back to any point since the last time it was truncated. Or right before hitting return to whatever level of accuracy you're comfortable with.

jabberati,
@jabberati@social.anoxinon.de avatar

BEGIN TRANSACTION is your friend

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • uselessserver093
  • Food
  • aaaaaaacccccccce
  • [email protected]
  • test
  • CafeMeta
  • testmag
  • MUD
  • RhythmGameZone
  • RSS
  • dabs
  • Socialism
  • KbinCafe
  • TheResearchGuardian
  • Ask_kbincafe
  • oklahoma
  • feritale
  • SuperSentai
  • KamenRider
  • All magazines