fix: orderable with groups and tabs requires migration (#12422)

⚠️ `orderable` fields will no longer be `required` and `unique`, so your
database may prompt you to accept an automatic migration if you're using
[this
feature](https://payloadcms.com/docs/configuration/collections#config-options).
Note that the `orderable` feature is still experimental, so it may still
receive breaking changes without a major upgrade or contain bugs. Use it
with caution.
___

The `orderable` fields will not have `required` and `unique` constraints
at the database schema level, in order to automatically migrate
collections that incorporate this property.

Now, when a user adds the `orderable` property to a collection or join
field, existing documents will have the order field set to undefined.
The first time you try to reorder them, the documents will be
automatically assigned an initial order, and you will be prompted to
refresh the page.

We believe this provides a better development experience than having to
manually migrate data with a script.

Additionally, it fixes a bug that occurred when using `orderable` in
conjunction with groups and tabs fields.

Closes:
- #12129
- #12331
- #12212

---------

Co-authored-by: Dan Ribbens <dan.ribbens@gmail.com>
This commit is contained in:
Germán Jabloñski
2025-05-16 19:21:46 -03:00
committed by GitHub
parent 18f2f899c5
commit 529bfe149e
4 changed files with 86 additions and 27 deletions

View File

@@ -151,6 +151,7 @@ export interface Post {
*/
export interface Draft {
id: string;
_order?: string | null;
text?: string | null;
number?: number | null;
number2?: number | null;
@@ -191,9 +192,9 @@ export interface Localized {
*/
export interface Orderable {
id: string;
_orderable_orderableJoinField2_order?: string;
_orderable_orderableJoinField1_order?: string;
_order?: string;
_orderable_orderableJoinField2_order?: string | null;
_orderable_orderableJoinField1_order?: string | null;
_order?: string | null;
title?: string | null;
orderableField?: (string | null) | OrderableJoin;
updatedAt: string;
@@ -340,6 +341,7 @@ export interface PostsSelect<T extends boolean = true> {
* via the `definition` "drafts_select".
*/
export interface DraftsSelect<T extends boolean = true> {
_order?: T;
text?: T;
number?: T;
number2?: T;