Skip to content

Give custom fields a public id - #254

Merged
roncodes merged 1 commit into
release/v1.6.62from
work/custom-field-public-id
Sep 14, 2026
Merged

roncodes merged 1 commit into
release/v1.6.62from
work/custom-field-public-id

Conversation

@roncodes

Copy link
Copy Markdown
Member

Every other resource in the platform is addressed by a prefixed public id. A custom field was addressed by its uuid, so any API that hands one out exposes an internal identifier.

FleetOps' inspection API is the case in point: a submission names the field each answer belongs to, and until now had nothing but a uuid to name it with. Fleetbase\Http\Resources\v1\InspectionForm::fieldToArray() carries the comment "A custom field has no public id, so the uuid is the id on both sides" — this removes that compromise.

What changed

  • CustomField takes HasPublicId with $publicIdType = 'custom_field', and public_id joins $fillable.
  • A migration adds the column and backfills existing rows. It is nullable()->index() rather than unique-and-required, following the groups precedent, so it is safe on an already-populated table.
  • HasCustomFields::setCustomField() creates a field with saveQuietly(), which skips the creating hook that mints the id — so that path now mints its own. Without this, a field created on the fly would be the only one without a public id.

Scope

CustomField is platform-wide, so this gives every custom field a public id — orders, vendors, drivers, not only inspections. Nothing reads the new column yet; withCustomFields()'s public projection emits field names and is unchanged.

Checks

  • vendor/bin/pest — 1434 passed, 0 failed.
  • php-cs-fixer --dry-run — clean.
  • New test: generates custom field public ids in tests/Unit/Models/RecordModelsTest.php.
  • Two in-memory test schemas gained the column, since the trait's uniqueness probe queries it on every save.

Targeted at release/v1.6.62, cut from main for this change. Left for review — not merging.

Every other resource in the platform is addressed by a prefixed public
id; a custom field was addressed by its uuid, so any API handing one out
exposed an internal identifier. FleetOps' inspection API is the case in
point — a submission names the field each answer belongs to, and had
nothing but a uuid to name it with.

Existing rows are backfilled, and the column is nullable and indexed
rather than unique-and-required so the migration is safe on a table that
is already populated. A field created on the fly through
setCustomField() is saved quietly, which skips the hook that mints the
id, so that path mints its own.
@codecov

codecov Bot commented Sep 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (4c763ce) to head (d73e044).

Additional details and impacted files
@@                 Coverage Diff                 @@
##             release/v1.6.62      #254   +/-   ##
===================================================
  Coverage             100.00%   100.00%           
  Complexity              6750      6750           
===================================================
  Files                    398       398           
  Lines                  22502     22505    +3     
===================================================
+ Hits                   22502     22505    +3     
Flag Coverage Δ
backend 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@roncodes
roncodes merged commit 00c872f into release/v1.6.62 Sep 14, 2026
5 checks passed
@roncodes
roncodes deleted the work/custom-field-public-id branch September 14, 2026 09:11
@roncodes roncodes mentioned this pull request Sep 14, 2026
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.

1 participant