fix(db): remove role_key column alias breaking every ProfessionalRepository query
All checks were successful
build-and-release / build (cron) (push) Successful in 4m33s
build-and-release / build (companies) (push) Successful in 7m12s
build-and-release / build (developers) (push) Successful in 8m44s
build-and-release / build (catering-services) (push) Successful in 9m18s
build-and-release / build (customers) (push) Successful in 9m24s
build-and-release / build (gateway) (push) Successful in 3m5s
build-and-release / build (employees) (push) Successful in 8m10s
build-and-release / build (fitness-trainers) (push) Successful in 8m16s
build-and-release / build (jobs) (push) Successful in 4m27s
build-and-release / build (graphic-designers) (push) Successful in 7m55s
build-and-release / build (job-seekers) (push) Successful in 9m43s
build-and-release / build (leads) (push) Successful in 8m49s
build-and-release / build (makeup-artists) (push) Successful in 8m3s
build-and-release / build (payments) (push) Successful in 8m35s
build-and-release / build (photographers) (push) Successful in 8m43s
build-and-release / build (social-media-managers) (push) Successful in 7m57s
build-and-release / build (tutors) (push) Successful in 6m55s
build-and-release / build (ugc-content-creators) (push) Successful in 8m49s
build-and-release / build (video-editors) (push) Successful in 8m4s
build-and-release / build (users) (push) Successful in 9m11s

All three queries selected role_key AS profession_key, but the Professional
struct's field is named role_key — sqlx's FromRow derive matches by column
name, so every call (get_by_user_id, submit_for_verification, and its
UPDATE...RETURNING) failed at runtime with "no column found for name:
role_key". This is the professional-profile existence check used by
document upload, portfolio, and submission endpoints across all 10
profession services — document upload was 500ing for every professional
role because of this.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Ashwin Kumar Sivakumar 2026-07-15 01:30:45 +05:30
parent fb681accc3
commit 03d761f0f3

View file

@ -110,7 +110,7 @@ pub struct ProfessionalRepository;
impl ProfessionalRepository {
pub async fn get_by_user_id(pool: &PgPool, user_id: Uuid) -> Result<Professional, sqlx::Error> {
sqlx::query_as::<_, Professional>(
"SELECT id, user_id, role_key as profession_key, status, created_at, updated_at FROM user_role_profiles WHERE user_id = $1 AND role_key != 'CUSTOMER' AND role_key != 'COMPANY'",
"SELECT id, user_id, role_key, status, created_at, updated_at FROM user_role_profiles WHERE user_id = $1 AND role_key != 'CUSTOMER' AND role_key != 'COMPANY'",
)
.bind(user_id)
.fetch_one(pool)
@ -556,7 +556,7 @@ impl ProfessionalRepository {
profession_key: &str,
) -> Result<Professional, sqlx::Error> {
let prof = sqlx::query_as::<_, Professional>(
"SELECT id, user_id, role_key as profession_key, status, created_at, updated_at FROM user_role_profiles WHERE user_id = $1 AND role_key = $2",
"SELECT id, user_id, role_key, status, created_at, updated_at FROM user_role_profiles WHERE user_id = $1 AND role_key = $2",
)
.bind(user_id)
.bind(profession_key)
@ -572,7 +572,7 @@ impl ProfessionalRepository {
UPDATE user_role_profiles
SET status = 'PENDING_REVIEW', updated_at = NOW()
WHERE user_id = $1 AND role_key = $2
RETURNING id, user_id, role_key as profession_key, status, created_at, updated_at
RETURNING id, user_id, role_key, status, created_at, updated_at
"#,
)
.bind(user_id)