Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Refactors backend/DB so that zones are stored as plain
text
rather thanjsonb
.With incoming map cache changes, we perform a hash check on map load to check zone files match the hash on the
zoneHash
field of theMapVersion
table. Currently, zones are stored in Postgres asjsonb
, a Postgres-specific binary serialization of JSON. It doesn't store whitespace, so makes storing zone hashes unreliable - it's probably possible to get the hash check to be consistent but I was struggling to get it working and felt very messy.The main purpose of
jsonb
is to allow queries over that JSON data, which for zones we never need to do - we're really just using using the field for storage. The only thing we gain from usingjsonb
is that Prisma queries automatically parse the JSON into JSOs for us; this change requires we stick someJSON.parse
s in the backend code, but it's really not a big deal.I haven't spent the time benching/profiling anything, but I suspect this method is quite a lot more performant overall, since the
maps/<mapID>/zones
GETs can just return raw strings, rather than having to serialize and deserialize each time, and that endpoint is called very frequently by the game.Checks
nx run db:create-migration <name>
and committed the migration if I've made DB schema changesfeat: Add foo
,chore: Update bar
, etc...fixup
ed into my original commits