Skip to content

Add last_updated field to PhotoGallery#8530

Merged
aapeliv merged 2 commits into
developfrom
backend/feature/gallery-last-updated
May 12, 2026
Merged

Add last_updated field to PhotoGallery#8530
aapeliv merged 2 commits into
developfrom
backend/feature/gallery-last-updated

Conversation

@aapeliv

@aapeliv aapeliv commented May 11, 2026

Copy link
Copy Markdown
Member

Adds a last_updated timestamp to PhotoGallery that is bumped whenever a gallery is mutated (photo added, removed, moved, or caption changed). Currently User.profile_last_updated is only updated via UpdateProfile, so changes to a user's profile photo gallery are not reflected anywhere; this gives gallery freshness its own timestamp on the gallery itself.

Testing

  • Existing gallery test suite (src/tests/test_galleries.py, 42 tests) still passes.
  • No new tests added for last_updated behavior yet — could add coverage that each mutation advances the timestamp and the no-op move does not.

Backend checklist

  • Added tests for any new code or added a regression test if fixing a bug
  • Run the backend locally and it works
  • Added migrations if there are any database changes, rebased onto develop if necessary for linear migration history

For maintainers

  • Maintainers can push commits to my branch
  • Maintainers can merge this PR for me

This PR was created with the Couchers PR skill.

@vercel

vercel Bot commented May 11, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
couchers Ready Ready Preview May 11, 2026 4:33am

Request Review

@couchersbot

couchersbot Bot commented May 11, 2026

Copy link
Copy Markdown
Contributor

Claude finished @CouchersBot[bot]'s task in 41s —— View job


Migration safety review

  • Read PR diff
  • Read migration 0150_add_last_updated_field_to_photogallery.py
  • Check photo_galleries schema in schema.sql and model in models/uploads.py
  • Verify revision chain (01490150)
  • Evaluate against migration review checklist
  • Post review comment

Result: SAFE. The migration adds last_updated with server_default=now() and NOT NULL, which safely backfills existing rows via a metadata-only ALTER TABLE on PG11+. Revision chain is correct, downgrade is clean, and photo_galleries is not a hot-path table. Full review posted here.
• Branch: backend/feature/gallery-last-updated

@couchersbot

couchersbot Bot commented May 11, 2026

Copy link
Copy Markdown
Contributor

Migration Review

One of our most common issues is migrations that don't work with existing data in production. This is very hard to catch with CI, so we have this bot to check for potential problems.

Overall Risk: SAFE

Files Reviewed

  • 0150_add_last_updated_field_to_photogallery.py — adds a last_updated timestamp column to photo_galleries with server_default=now() and NOT NULL.

Findings

No issues found.

  • Revision chain is correct (01490150).
  • The NOT NULL column is safe because server_default=now() backfills all existing rows in a single metadata-friendly ALTER TABLE (PG11+ stores the default once and applies it to existing rows without a table rewrite).
  • photo_galleries is a small table and not in the hot-path of the schema, so lock contention is not a concern.
  • server_default=sa.text("now()") matches the project convention for UTC timestamps, and is consistent with the existing created column on the same table.
  • Downgrade correctly drops the column (data loss on downgrade is expected and acceptable for a freshness timestamp).

One minor (non-blocking) observation: every existing gallery row will be backfilled with the same migration-time timestamp, which means existing galleries will all look "freshly updated" right after deploy. This is almost certainly the intended/acceptable behavior, but worth noting if last_updated is used for cache invalidation or sort ordering.

Summary

A clean, low-risk additive migration with a server-side default that safely backfills existing rows. No action required.

@nabramow nabramow left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM!

@nabramow

Copy link
Copy Markdown
Member

@aapeliv Does it need to be added to the protos?

@aapeliv
aapeliv merged commit a6ffb34 into develop May 12, 2026
8 checks passed
@aapeliv
aapeliv deleted the backend/feature/gallery-last-updated branch May 12, 2026 01:24
@github-actions

Copy link
Copy Markdown
Contributor

📝 Release Notes

This PR does not need to be included in release notes.

Reason: This is a backend data-model change adding a freshness timestamp for photo galleries. The PR does not expose any new user-facing feature, visible UX improvement, or clearly described reliability/performance benefit for end users on its own. It appears to enable future functionality rather than deliver a noticeable change now.

🤖 Bot Debug Information

Model: couchers.openai.gpt-5.4
Decision: exclude
Reasoning: This is a backend data-model change adding a freshness timestamp for photo galleries. The PR does not expose any new user-facing feature, visible UX improvement, or clearly described reliability/performance benefit for end users on its own. It appears to enable future functionality rather than deliver a noticeable change now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants