Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

## 0.1.1 - 2026-09-17

### Changed

- With `key_type` set to `uuid`, both package tables now receive time ordered UUID v7 keys instead of random UUID v4 keys. Existing keys stay valid, the column type does not change.

## 0.1.0 - 2026-09-08

First public release.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ The package ships English and Italian validation messages under the
| --- | --- | --- |
| `tables.fields` | `custom_fields` | Table holding the field definitions. |
| `tables.values` | `custom_field_values` | Table holding one row per field per record. |
| `key_type` | `id` | Primary key type of both package tables. Accepts `id`, `uuid`, `ulid`. Must be chosen before migrating. |
| `key_type` | `id` | Primary key type of both package tables. Accepts `id`, `uuid`, `ulid`. `uuid` generates UUID v7. Must be chosen before migrating. |
| `morph_key_type` | `id` | Key type of the models that own custom fields, used for the `valuable_id` column. Accepts `id`, `uuid`, `ulid`. Must be chosen before migrating. |
| `models.custom_field` | `PlinCode\CustomFields\Models\CustomField` | The definition model. Point it at your own subclass to add relations, casts, a global scope or a dedicated connection. |
| `models.custom_field_value` | `PlinCode\CustomFields\Models\CustomFieldValue` | The value model. Same rule. |
Expand Down
2 changes: 1 addition & 1 deletion src/Models/CustomField.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ protected static function booted(): void

$field->setAttribute($field->getKeyName(), config('laravel-custom-fields.key_type') === 'ulid'
? (string) Str::ulid()
: (string) Str::uuid());
: (string) Str::uuid7());
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/Models/CustomFieldValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected static function booted(): void

$value->setAttribute($value->getKeyName(), config('laravel-custom-fields.key_type') === 'ulid'
? (string) Str::ulid()
: (string) Str::uuid());
: (string) Str::uuid7());
});
}

Expand Down
2 changes: 2 additions & 0 deletions tests/Feature/KeyTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ function columnTypesOf(string $kind): array
->and(columnType('custom_field_values', 'valuable_id'))->toBeIn(columnTypesOf('uuid'))
->and(Str::isUuid((string) $field->getKey()))->toBeTrue()
->and(Str::isUuid((string) $row?->getKey()))->toBeTrue()
->and(substr((string) $field->getKey(), 14, 1))->toBe('7')
->and(substr((string) $row?->getKey(), 14, 1))->toBe('7')
->and($row?->getAttribute('valuable_id'))->toBe($document->getKey())
->and($document->getCustomField('rank'))->toBe(7);
});
Expand Down