Skip to content

[13.x] put _type before _id for polymorphic table columns#11188

Merged
taylorotwell merged 1 commit into
laravel:13.xfrom
browner12:AB-morph-field-order
May 6, 2026
Merged

[13.x] put _type before _id for polymorphic table columns#11188
taylorotwell merged 1 commit into
laravel:13.xfrom
browner12:AB-morph-field-order

Conversation

@browner12
Copy link
Copy Markdown
Contributor

This commit orders all of our polymorphic table columns with *_type first and *_id second.

This matches how the columns are actually generated by the migration helper methods:

$table->nullableulidMorphs('nullableulidMorphs');
$table->ulidMorphs('ulidMorphs');
$table->uuidmorphs('uuidmorphs');
$table->nullableUuidMorphs('nullableUuidMorphs');
$table->morphs('morphs');
$table->nullableMorphs('nullableMorphs');

results in:

  • nullableulidMorphs_type
  • nullableulidMorphs_id
  • ulidMorphs_type
  • ulidMorphs_id
  • uuidmorphs_type
  • uuidmorphs_id
  • nullableUuidMorphs_type
  • nullableUuidMorphs_id
  • morphs_type
  • morphs_id
  • nullableMorphs_type
  • nullableMorphs_id

This will help encourage consistency between morph columns generated by the helpers, and any the user may manually define.

I think it also makes sense from a readability standpoint; Comment 5, Tag 17, etc.

This commit orders all of our polymorphic table columns with `*_type` first and `*_id` second.

This matches how the columns are actually generated by the migration helper methods:

```php
$table->nullableulidMorphs('nullableulidMorphs');
$table->ulidMorphs('ulidMorphs');
$table->uuidmorphs('uuidmorphs');
$table->nullableUuidMorphs('nullableUuidMorphs');
$table->morphs('morphs');
$table->nullableMorphs('nullableMorphs');
```

results in:

- nullableulidMorphs_type
- nullableulidMorphs_id
- ulidMorphs_type
- ulidMorphs_id
- uuidmorphs_type
- uuidmorphs_id
- nullableUuidMorphs_type
- nullableUuidMorphs_id
- morphs_type
- morphs_id
- nullableMorphs_type
- nullableMorphs_id

This will help encourage consistency between morph columns generated by the helpers, and any the user may manually define.

I think it also makes sense from a readability standpoint; Comment 5, Tag 17, etc.
@taylorotwell taylorotwell merged commit f966ff9 into laravel:13.x May 6, 2026
@browner12 browner12 deleted the AB-morph-field-order branch May 6, 2026 18:05
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.

2 participants