fix: migrate patch timestamps to timezone-aware UTC instants - #96
Merged
Conversation
Replace LocalDateTime with Instant throughout the patch lifecycle, API, statistics, and time utilities. Persist last_updated as a timezone-aware database timestamp and parse backend timestamps as UTC in the frontend. Add Flyway migrations for H2 and PostgreSQL, including conversion of existing legacy timestamps, and switch Hibernate schema handling to validation. When upgrading a database created by the previous version, configure spring.flyway.placeholders.legacy_timezone to the timezone used by the old deployment if it was not UTC.
There was a problem hiding this comment.
Pull request overview
This PR migrates patch lifecycle timestamps from LocalDateTime to UTC-based Instant end-to-end (DB schema + backend API + frontend parsing) to make timestamps timezone-safe and consistent across deployments.
Changes:
- Backend: replace
LocalDateTimewithInstantforPatch.lastUpdated, API DTOs, stats calculations, and time utilities. - Database: add Flyway migrations for H2/PostgreSQL to convert
last_updatedtoTIMESTAMP WITH TIME ZONE, with alegacy_timezoneplaceholder for interpreting old local timestamps. - Frontend: parse patch
lastUpdatedtimestamps as UTC and then display them in the user’s local timezone.
Reviewed changes
Copilot reviewed 11 out of 13 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| web/src/lib/types.ts | Documents lastUpdated as an ISO 8601 UTC datetime string returned by the API. |
| web/src/lib/components/PatchesTable.svelte | Parses lastUpdated as UTC before converting to local display time. |
| src/main/resources/db/migration/postgresql/V1__create_patch_table.sql | Introduces baseline patch table definition for Flyway-managed PostgreSQL schemas. |
| src/main/resources/db/migration/postgresql/V2__convert_last_updated_to_utc.sql | Converts legacy last_updated values to a timezone-aware column using a configurable legacy timezone. |
| src/main/resources/db/migration/h2/V1__create_patch_table.sql | Introduces baseline patch table definition for Flyway-managed H2 schemas. |
| src/main/resources/db/migration/h2/V2__convert_last_updated_to_utc.sql | Converts legacy last_updated values for H2 (currently contains a likely invalid H2 ALTER syntax). |
| src/main/resources/application.yaml | Enables/configures Flyway and switches Hibernate schema handling to validate. |
| src/main/java/io/papermc/patchroulette/util/TimeUtil.java | Updates interval types from LocalDateTime to Instant. |
| src/main/java/io/papermc/patchroulette/service/PatchService.java | Updates patch lifecycle updates to use Instant.now(). |
| src/main/java/io/papermc/patchroulette/model/Patch.java | Migrates lastUpdated field and duration update logic to Instant. |
| src/main/java/io/papermc/patchroulette/controller/ApiController.java | Updates API DTO and stats computations to use Instant. |
| build.gradle.kts | Adds Flyway dependencies (including PostgreSQL database support). |
| .gitignore | Stops ignoring the Flyway migration resources directory. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Replace LocalDateTime with Instant throughout the patch lifecycle, API, statistics, and time utilities. Persist last_updated as a timezone-aware database timestamp and parse backend timestamps as UTC in the frontend.
Add Flyway migrations for H2 and PostgreSQL, including conversion of existing legacy timestamps, and switch Hibernate schema handling to validation.
When upgrading a database created by the previous version, configure spring.flyway.placeholders.legacy_timezone to the timezone used by the old deployment if it was not UTC.