Skip to content

feat(collections): add created_at and updated_at timestamps to collections and variants tables#1119

Open
fhennig wants to merge 7 commits intomainfrom
collections-with-dates
Open

feat(collections): add created_at and updated_at timestamps to collections and variants tables#1119
fhennig wants to merge 7 commits intomainfrom
collections-with-dates

Conversation

@fhennig
Copy link
Copy Markdown
Contributor

@fhennig fhennig commented Mar 26, 2026

resolves #1113

Summary

Add created_at and updated_at fields to collections and variants; they behave as you'd expect.

Example timestamp: 2026-03-26T12:59:18.027Z - uses millisecond precision.

Adds tests to see that updating works, and that you can't manually set the dates.

Jackson is now configured to always fail parsing on unknown properties.

Example API response object

  {
    "id": 1,
    "name": "Covid: Alpha & Beta comparison",
    "ownedBy": "foobar",
    "organism": "covid",
    "description": "Comparing Alpha and Beta variant trajectories",
    "variants": [
      {
        "type": "query",
        "id": 1,
        "collectionId": 1,
        "name": "Alpha (B.1.1.7)",
        "description": "Alpha lineage globally",
        "countQuery": "pangoLineage=B.1.1.7*",
        "coverageQuery": null,
        "createdAt": "2026-03-26T11:31:23.404Z",
        "updatedAt": "2026-03-26T11:31:23.404Z"
      },
      {
        "type": "query",
        "id": 2,
        "collectionId": 1,
        "name": "Beta (B.1.351)",
        "description": "Beta lineage globally",
        "countQuery": "pangoLineage=B.1.351*",
        "coverageQuery": null,
        "createdAt": "2026-03-26T11:31:23.404Z",
        "updatedAt": "2026-03-26T11:31:23.404Z"
      }
    ],
    "createdAt": "2026-03-26T11:31:23.404Z",
    "updatedAt": "2026-03-26T11:31:23.404Z"
  }

PR Checklist

  • All necessary documentation has been adapted.
  • The implemented feature is covered by an appropriate test.

Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com

…tions and variants tables

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 26, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
dashboards Ready Ready Preview, Comment Apr 8, 2026 1:04pm

Request Review

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…alization

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ion mismatches

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds server-managed createdAt/updatedAt timestamps to collections and variants, persists them in Postgres, and exposes them via the API. This addresses issue #1113 by making timestamps available to API consumers and ensuring updatedAt changes on updates.

Changes:

  • Add created_at / updated_at columns to collections_table and variants_table via a new DB migration.
  • Plumb timestamps through Exposed entities/model logic into the Collection and Variant API responses, and update timestamps on writes.
  • Add tests around timestamp presence/update behavior and rejecting client attempts to set timestamp fields; configure Jackson to fail on unknown properties.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
backend/src/test/kotlin/org/genspectrum/dashboardsbackend/controller/CollectionsPutTest.kt Adds update-time assertions and 400 tests when timestamps are provided in update bodies.
backend/src/test/kotlin/org/genspectrum/dashboardsbackend/controller/CollectionsPostTest.kt Adds creation-time assertions and 400 tests when timestamps are provided in create bodies.
backend/src/main/resources/db/migration/V1.2__add_timestamps_to_collections_and_variants.sql Adds timestamp columns + defaults for collections and variants tables.
backend/src/main/resources/application.properties Enables global Jackson “fail on unknown properties”.
backend/src/main/kotlin/org/genspectrum/dashboardsbackend/model/collection/VariantTable.kt Adds timestamp columns to the Exposed table/entity + maps them to API variants.
backend/src/main/kotlin/org/genspectrum/dashboardsbackend/model/collection/CollectionTable.kt Adds timestamp columns to the Exposed table/entity + maps them to API collections.
backend/src/main/kotlin/org/genspectrum/dashboardsbackend/model/collection/CollectionModel.kt Sets timestamps on create/update and updates updatedAt on collection/variant changes.
backend/src/main/kotlin/org/genspectrum/dashboardsbackend/config/InstantSerializer.kt Adds Jackson (de)serialization for kotlinx.datetime.Instant.
backend/src/main/kotlin/org/genspectrum/dashboardsbackend/api/Variant.kt Exposes createdAt/updatedAt on API variants.
backend/src/main/kotlin/org/genspectrum/dashboardsbackend/api/Collection.kt Exposes createdAt/updatedAt on API collections.
backend/build.gradle.kts Adds exposed-kotlin-datetime dependency for timestamp column support.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

feat(backend): add creation and update date to collections

3 participants