feat(collections): add created_at and updated_at timestamps to collections and variants tables#1119
Open
feat(collections): add created_at and updated_at timestamps to collections and variants tables#1119
Conversation
…tions and variants tables Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
d06249d to
e213524
Compare
…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>
Contributor
There was a problem hiding this comment.
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_atcolumns tocollections_tableandvariants_tablevia a new DB migration. - Plumb timestamps through Exposed entities/model logic into the
CollectionandVariantAPI 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.
backend/src/main/resources/db/migration/V1.2__add_timestamps_to_collections_and_variants.sql
Outdated
Show resolved
Hide resolved
backend/src/main/resources/db/migration/V1.2__add_timestamps_to_collections_and_variants.sql
Outdated
Show resolved
Hide resolved
backend/src/main/kotlin/org/genspectrum/dashboardsbackend/model/collection/CollectionModel.kt
Show resolved
Hide resolved
backend/src/main/kotlin/org/genspectrum/dashboardsbackend/model/collection/CollectionModel.kt
Outdated
Show resolved
Hide resolved
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.
resolves #1113
Summary
Add
created_atandupdated_atfields 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
Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com