Skip to content

Commit 6f0ab0d

Browse files
committed
fix: Remove duplicate custom array id fields
Since v3.46.0, the default id field is no longer added if a custom id field exists. See payloadcms/payload#13064. The following error occurred because no defaultValue was specified: null value in column "id" of relation "users_accounts" violates not-null constraint.
1 parent 5d1d6a3 commit 6f0ab0d

File tree

6 files changed

+10
-24
lines changed

6 files changed

+10
-24
lines changed

examples/basic/src/payload-types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,10 @@ export interface User {
123123
image?: string | null;
124124
accounts?:
125125
| {
126-
id?: string | null;
127126
provider: string;
128127
providerAccountId: string;
129128
type: string;
129+
id?: string | null;
130130
}[]
131131
| null;
132132
updatedAt: string;
@@ -197,10 +197,10 @@ export interface UsersSelect<T extends boolean = true> {
197197
accounts?:
198198
| T
199199
| {
200-
id?: T;
201200
provider?: T;
202201
providerAccountId?: T;
203202
type?: T;
203+
id?: T;
204204
};
205205
updatedAt?: T;
206206
createdAt?: T;

examples/multiple-auth-collections/src/payload-types.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,10 @@ export interface Customer {
149149
customerNumber: string;
150150
accounts?:
151151
| {
152-
id?: string | null;
153152
provider: string;
154153
providerAccountId: string;
155154
type: string;
155+
id?: string | null;
156156
}[]
157157
| null;
158158
updatedAt: string;
@@ -170,10 +170,10 @@ export interface Admin {
170170
image?: string | null;
171171
accounts?:
172172
| {
173-
id?: string | null;
174173
provider: string;
175174
providerAccountId: string;
176175
type: string;
176+
id?: string | null;
177177
}[]
178178
| null;
179179
updatedAt: string;
@@ -260,10 +260,10 @@ export interface CustomersSelect<T extends boolean = true> {
260260
accounts?:
261261
| T
262262
| {
263-
id?: T;
264263
provider?: T;
265264
providerAccountId?: T;
266265
type?: T;
266+
id?: T;
267267
};
268268
updatedAt?: T;
269269
createdAt?: T;
@@ -281,10 +281,10 @@ export interface AdminsSelect<T extends boolean = true> {
281281
accounts?:
282282
| T
283283
| {
284-
id?: T;
285284
provider?: T;
286285
providerAccountId?: T;
287286
type?: T;
287+
id?: T;
288288
};
289289
updatedAt?: T;
290290
createdAt?: T;

examples/with-payload-local-strategy/src/payload-types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,10 @@ export interface User {
122122
image?: string | null;
123123
accounts?:
124124
| {
125-
id?: string | null;
126125
provider: string;
127126
providerAccountId: string;
128127
type: string;
128+
id?: string | null;
129129
}[]
130130
| null;
131131
updatedAt: string;
@@ -206,10 +206,10 @@ export interface UsersSelect<T extends boolean = true> {
206206
accounts?:
207207
| T
208208
| {
209-
id?: T;
210209
provider?: T;
211210
providerAccountId?: T;
212211
type?: T;
212+
id?: T;
213213
};
214214
updatedAt?: T;
215215
createdAt?: T;

packages/dev/src/payload-types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,12 @@ export interface User {
140140
roles?: string[];
141141
accounts?:
142142
| {
143-
id?: string | null;
144143
provider: string;
145144
providerAccountId: string;
146145
type: string;
147146
additionalAccountDatabaseField: string;
148147
createdAt: string;
148+
id?: string | null;
149149
}[]
150150
| null;
151151
currentAccount?: {
@@ -263,12 +263,12 @@ export interface UsersSelect<T extends boolean = true> {
263263
accounts?:
264264
| T
265265
| {
266-
id?: T;
267266
provider?: T;
268267
providerAccountId?: T;
269268
type?: T;
270269
additionalAccountDatabaseField?: T;
271270
createdAt?: T;
271+
id?: T;
272272
};
273273
currentAccount?:
274274
| T

packages/payload-authjs/src/payload/collection/fields/accounts.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,6 @@ export const accountsField: Field = {
99
name: "accounts",
1010
type: "array",
1111
fields: [
12-
{
13-
name: "id",
14-
type: "text",
15-
admin: {
16-
disabled: true,
17-
},
18-
},
1912
{
2013
type: "row",
2114
fields: [

packages/payload-authjs/src/payload/collection/fields/session.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,6 @@ export const sessionsField: Field = {
99
name: "sessions",
1010
type: "array",
1111
fields: [
12-
{
13-
name: "id",
14-
type: "text",
15-
admin: {
16-
disabled: true,
17-
},
18-
},
1912
{
2013
type: "row",
2114
fields: [

0 commit comments

Comments
 (0)