Skip to content

fix: migrate patch timestamps to timezone-aware UTC instants - #96

Merged
jpenilla merged 1 commit into
masterfrom
fix/timezones
Aug 8, 2026
Merged

fix: migrate patch timestamps to timezone-aware UTC instants#96
jpenilla merged 1 commit into
masterfrom
fix/timezones

Conversation

@jpenilla

@jpenilla jpenilla commented Aug 8, 2026

Copy link
Copy Markdown
Member

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.

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 LocalDateTime with Instant for Patch.lastUpdated, API DTOs, stats calculations, and time utilities.
  • Database: add Flyway migrations for H2/PostgreSQL to convert last_updated to TIMESTAMP WITH TIME ZONE, with a legacy_timezone placeholder for interpreting old local timestamps.
  • Frontend: parse patch lastUpdated timestamps 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.

@jpenilla
jpenilla merged commit 3bea0d0 into master Aug 8, 2026
3 checks passed
@jpenilla
jpenilla deleted the fix/timezones branch August 8, 2026 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants