From 2e984ffe22a152e763f96016baf637d659360674 Mon Sep 17 00:00:00 2001 From: Kyle Spier-Swenson Date: Tue, 1 Sep 2020 01:20:23 -0700 Subject: [PATCH] Adds some robust database programming tips to contributing.md (#53347) --- .github/CONTRIBUTING.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index b925b070fa7..62b400448fe 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -263,6 +263,12 @@ This is good: * Primary keys are inherently immutable and you must never do anything to change the primary key of a row or entity. This includes preserving auto increment numbers of rows when copying data to a table in a conversion script. No amount of bitching about gaps in ids or out of order ids will save you from this policy. +* The ttl for data from the database is 10 seconds. You must have a compelling reason to store and reuse data for longer then this. + +* Do not write stored and transformed data to the database, instead, apply the transformation to the data in the database directly. + * ie: SELECTing a number from the database, doubling it, then updating the database with the doubled number. If the data in the database changed between step 1 and 3, you'll get an incorrect result. Instead, directly double it in the update query. `UPDATE table SET num = num*2` instead of `UPDATE table SET num = [num]`. + * if the transformation is user provided (such as allowing a user to edit a string), you should confirm the value being updated did not change in the database in the intervening time before writing the new user provided data by checking the old value with the current value in the database, and if it has changed, allow the user to decide what to do next. + ### Mapping Standards * TGM Format & Map Merge * All new maps submitted to the repo through a pull request must be in TGM format (unless there is a valid reason present to have it in the default BYOND format.) This is done using the [Map Merge](https://github.com/tgstation/tgstation/wiki/Map-Merger) utility included in the repo to convert the file to TGM format.