[DevEx]: Update the timestamp columns across the codebase to use postgres’ timestampz
data type
#811
Labels
backend
Requires changes to the (node) backend webserver
dev experience
Improvements to the code base that make it easier/better/more enjoyable to contribute to Cuttle
frontend
Requires changes to the frontend (vue) client
Improvement Summary
Currently, our time-related columns are stored as simple numbers, represented as milliseconds since Epoch. We should update these in both the code and database to use a proper timestamp type so that the values are human readable and so that we avoid limitations on the size of numbers in both postgres int8 and JavaScript types.
Detailed Description
This will require updating frontend, the backend, and migrating the existing database rows to convert the existing values to the new format.
The timezone should be set to EST for all timestamp rows.
At the code level, the three types of changes to look for:
columnType
oftimestampz
dayjs()
instances (where most of the processing logic happens)In particular, we should check the Season and Match models’
startTime
andendTime
attributes, and thelockedAt
attribute of theGame
model. We should update the consumers of those columns, including theStatsController
and its associated helpers, the helpers used when the game ends to add the game to its appropriate match, and thelock-game
andunlock-game
helpers.Generally we should look for usages of
dayjs
which are the areas that involve time calculations and ensure those features still work correctly.For the database migration, we will need to alter the column types and convert the existing values to match the new types, being careful not to corrupt the existing data. For this reason, the migrations will require significant testing.
Note that we should not need to change the existing
createdAt
andupdatedAt
columns which are automatically managed by sailsThe text was updated successfully, but these errors were encountered: