update to use bigint for resourceId and blobId #365
Merged
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.
TL;DR
This pull request updates the ID fields for the
Resource
, andBlob
models to useBigInt
instead ofInt
. Corresponding changes have been made to Prisma schema, migration files, TypeScript types, and various parts of the application code to handle this change.This is in relation to introducing versions later!
What changed?
BigInt
IDs.Note:
Number
in JS throughout, so we are technically limited by the max int support in JS which is 2^53 - 1.How to test?
Resource
, andBlob
models.Why make this change?
To accommodate larger datasets and future-proof the application, enabling the use of
BigInt
for IDs in critical models likeResource
, andBlob
. This change reduces the risk of ID collisions and supports the scaling of the application.As shared, a quick back-of-envelope calculation shows:
We now have a 1-many relationship for resources and versions. Estimating worst case scenario:
Max running order of integer = 5000 sites, 14k pages each site, each page has 1000 versions = 5k * 14k * 1k = 70,000,000,000
Current max supported int = 4 bytes = 32 bits = 2,147,483,647
But JS supports up to 53 bits (2^53 - 1)
Might be good to consider using BigInt for all our IDs - 8 bytes = 64 bits
But in our app, we will only use a max of 53 bits (JS's max INT value)