Skip to content

Comments

Public trips - Rename fields in host request#7740

Open
nabramow wants to merge 4 commits intodevelopfrom
na/backend/naming-host-req
Open

Public trips - Rename fields in host request#7740
nabramow wants to merge 4 commits intodevelopfrom
na/backend/naming-host-req

Conversation

@nabramow
Copy link
Member

Describe briefly what this PR is doing and why.

Closes #7739

To prepare for public trips, we will first rename surfer_user_id and host_user_id to recipient and initiator. This is because public trips will allow us going both directions so the surfer initiates normally but host initiates with public trips.

Testing

Explain how you tested this PR and give clear steps so the reviewer can replicate.

  • Upgrade and downgrade migrations should work
  • Send a couple host requests and go through reference flow. Should still work exactly as before.

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

@vercel
Copy link

vercel bot commented Jan 25, 2026

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

Project Deployment Actions Updated (UTC)
couchers Ready Ready Preview Feb 22, 2026 3:58pm

Request Review

@couchersbot
Copy link
Contributor

couchersbot bot commented Feb 22, 2026

Claude finished @nabramow's task in 2m 3s —— View job


Migration Safety Review Complete

  • Get PR diff and identify migration files
  • Read migration file(s) in full
  • Check current production schema
  • Review model changes
  • Evaluate against safety checklist
  • Post review summary

Result: SAFE - The migration 0140_rename_host_request_user_columns_v2.py performs metadata-only column, index, and constraint renames on host_requests. No data modification, no type changes, no new constraints. Full details in the migration review comment.

@nabramow nabramow marked this pull request as ready for review February 22, 2026 04:07
@nabramow nabramow requested a review from aapeliv as a code owner February 22, 2026 04:07
@couchersbot
Copy link
Contributor

couchersbot bot commented Feb 22, 2026

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

  • 0140_rename_host_request_user_columns_v2.py - Renames 11 columns, 4 indexes, and 2 FK constraints on host_requests table from surfer/host naming to initiator/recipient naming.

Findings

No issues found. Column renames (ALTER COLUMN ... RENAME TO), index renames (ALTER INDEX ... RENAME TO), and constraint renames are all metadata-only operations in PostgreSQL - they do not rewrite the table or affect existing data. Dependent objects (materialized views like user_response_rates, other indexes) reference columns by internal attribute number (attnum), so they continue to work after renames.

The defensive inspect() checks for column/index existence before renaming add robustness (useful since this is "v2" of the migration).

Note: The downgrade raises NotImplementedError. This is acceptable for a rename migration but means rollback requires a new forward migration.

Summary

This is a safe, metadata-only migration. All 11 column renames, 4 index renames, and 2 FK constraint renames are correctly mapped and match the model changes in host_requests.py. No data modification, no type changes, no constraint additions - just naming updates.

@nabramow nabramow changed the title WIP DRAFT - Rename fields in host request Public trips - Rename fields in host request Feb 22, 2026
@couchersbot
Copy link
Contributor

couchersbot bot commented Feb 22, 2026

Claude finished @nabramow's task in 1m 49s —— View job


Migration Safety Review Complete

  • Get PR diff and identify migration files
  • Read migration file(s) in full
  • Check current production schema
  • Review model changes
  • Evaluate against safety checklist
  • Post review summary

Result: SAFE - The migration 0140_rename_host_request_user_columns_v2.py performs metadata-only column, index, and constraint renames on host_requests. No data modification, no type changes, no new constraints. Full details in the migration review comment.

Copy link
Member

@aapeliv aapeliv left a comment

Choose a reason for hiding this comment

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

some comments. let's just change the column names in the host request table in this PR

Comment on lines +20 to +33
conn = op.get_bind()
inspector = inspect(conn)
columns = {col["name"] for col in inspector.get_columns("host_requests")}
indexes = {idx["name"] for idx in inspector.get_indexes("host_requests")}

# Helper to rename column only if old name exists
def rename_column(old_name, new_name):
if old_name in columns:
op.alter_column("host_requests", old_name, new_column_name=new_name)

# Helper to rename index only if old name exists
def rename_index(old_name, new_name):
if old_name in indexes:
op.execute(f"ALTER INDEX {old_name} RENAME TO {new_name}")
Copy link
Member

Choose a reason for hiding this comment

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

Let's not do this; just normal renaming per-column please



def create_test_host_request_with_moderation(surfer_token, host_user_id):
def create_test_host_request_with_moderation(surfer_token, recipient_user_id):
Copy link
Member

Choose a reason for hiding this comment

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

let's not change this one

Comment on lines +41 to +42
initiator_user_id: int,
recipient_user_id: int,
Copy link
Member

Choose a reason for hiding this comment

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

here to keep as is

}

message CreateHostRequestReq {
int64 host_user_id = 1;
Copy link
Member

Choose a reason for hiding this comment

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

The API surface shouldn't change

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.

Change naming of host_user_id and surfer_user_id in HostRequest

2 participants