Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DevEx]: Update the timestamp columns across the codebase to use postgres’ timestampz data type #811

Open
itsalaidbacklife opened this issue Nov 26, 2023 · 0 comments · May be fixed by #824
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

Comments

@itsalaidbacklife
Copy link
Contributor

itsalaidbacklife commented Nov 26, 2023

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:

  1. Updating the models in api/models so that the time-related attributes have a columnType of timestampz
  2. Updating code that consumes or writes to these columns so that it correctly parses them to and from dayjs() instances (where most of the processing logic happens)
  3. Checking and revising any queries that compare times to ensure that they still correctly do what they are supposed to do.

In particular, we should check the Season and Match models’ startTime and endTime attributes, and the lockedAt attribute of the Game model. We should update the consumers of those columns, including the StatsController and its associated helpers, the helpers used when the game ends to add the game to its appropriate match, and the lock-game and unlock-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 and updatedAt columns which are automatically managed by sails

@itsalaidbacklife itsalaidbacklife added dev experience Improvements to the code base that make it easier/better/more enjoyable to contribute to Cuttle backend Requires changes to the (node) backend webserver frontend Requires changes to the frontend (vue) client labels Nov 26, 2023
@Haviles04 Haviles04 linked a pull request Dec 1, 2023 that will close this issue
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant