@payloadcms/db-postgres 3.0.0-beta.12 → 3.0.0-beta.13
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/destroy.d.ts.map +1 -1
- package/dist/destroy.js +8 -7
- package/dist/destroy.js.map +1 -1
- package/dist/schema/build.d.ts +3 -2
- package/dist/schema/build.d.ts.map +1 -1
- package/dist/schema/build.js +72 -31
- package/dist/schema/build.js.map +1 -1
- package/dist/schema/traverseFields.d.ts.map +1 -1
- package/dist/schema/traverseFields.js +31 -10
- package/dist/schema/traverseFields.js.map +1 -1
- package/package.json +3 -3
package/dist/destroy.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"destroy.d.ts","sourceRoot":"","sources":["../src/destroy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;
|
1
|
+
{"version":3,"file":"destroy.d.ts","sourceRoot":"","sources":["../src/destroy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAK/C,eAAO,MAAM,OAAO,EAAE,OAQrB,CAAA"}
|
package/dist/destroy.js
CHANGED
@@ -1,11 +1,12 @@
|
|
1
|
-
|
1
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
2
2
|
export const destroy = async function destroy() {
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
}
|
3
|
+
this.enums = {};
|
4
|
+
this.schema = {};
|
5
|
+
this.tables = {};
|
6
|
+
this.relations = {};
|
7
|
+
this.blockTableNames = {};
|
8
|
+
this.fieldConstraints = {};
|
9
|
+
this.drizzle = undefined;
|
9
10
|
};
|
10
11
|
|
11
12
|
//# sourceMappingURL=destroy.js.map
|
package/dist/destroy.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/destroy.ts"],"sourcesContent":["import type { Destroy } from 'payload/database'\n\nimport type { PostgresAdapter } from './types.js'\n\
|
1
|
+
{"version":3,"sources":["../src/destroy.ts"],"sourcesContent":["import type { Destroy } from 'payload/database'\n\nimport type { PostgresAdapter } from './types.js'\n\n// eslint-disable-next-line @typescript-eslint/require-await\nexport const destroy: Destroy = async function destroy(this: PostgresAdapter) {\n this.enums = {}\n this.schema = {}\n this.tables = {}\n this.relations = {}\n this.blockTableNames = {}\n this.fieldConstraints = {}\n this.drizzle = undefined\n}\n"],"names":["destroy","enums","schema","tables","relations","blockTableNames","fieldConstraints","drizzle","undefined"],"rangeMappings":";;;;;;;;;","mappings":"AAIA,4DAA4D;AAC5D,OAAO,MAAMA,UAAmB,eAAeA;IAC7C,IAAI,CAACC,KAAK,GAAG,CAAC;IACd,IAAI,CAACC,MAAM,GAAG,CAAC;IACf,IAAI,CAACC,MAAM,GAAG,CAAC;IACf,IAAI,CAACC,SAAS,GAAG,CAAC;IAClB,IAAI,CAACC,eAAe,GAAG,CAAC;IACxB,IAAI,CAACC,gBAAgB,GAAG,CAAC;IACzB,IAAI,CAACC,OAAO,GAAGC;AACjB,EAAC"}
|
package/dist/schema/build.d.ts
CHANGED
@@ -1,10 +1,11 @@
|
|
1
|
-
import type { IndexBuilder, PgColumnBuilder, UniqueConstraintBuilder } from 'drizzle-orm/pg-core';
|
1
|
+
import type { ForeignKeyBuilder, IndexBuilder, PgColumnBuilder, UniqueConstraintBuilder } from 'drizzle-orm/pg-core';
|
2
2
|
import type { Field } from 'payload/types';
|
3
3
|
import type { GenericColumns, PostgresAdapter } from '../types.js';
|
4
|
+
export type BaseExtraConfig = Record<string, (cols: GenericColumns) => ForeignKeyBuilder | IndexBuilder | UniqueConstraintBuilder>;
|
4
5
|
type Args = {
|
5
6
|
adapter: PostgresAdapter;
|
6
7
|
baseColumns?: Record<string, PgColumnBuilder>;
|
7
|
-
baseExtraConfig?:
|
8
|
+
baseExtraConfig?: BaseExtraConfig;
|
8
9
|
buildNumbers?: boolean;
|
9
10
|
buildRelationships?: boolean;
|
10
11
|
buildTexts?: boolean;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/schema/build.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,YAAY,EACZ,eAAe,EAEf,uBAAuB,EACxB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/schema/build.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,iBAAiB,EACjB,YAAY,EACZ,eAAe,EAEf,uBAAuB,EACxB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAe1C,OAAO,KAAK,EAAE,cAAc,EAAwB,eAAe,EAAE,MAAM,aAAa,CAAA;AAOxF,MAAM,MAAM,eAAe,GAAG,MAAM,CAClC,MAAM,EACN,CAAC,IAAI,EAAE,cAAc,KAAK,iBAAiB,GAAG,YAAY,GAAG,uBAAuB,CACrF,CAAA;AAED,KAAK,IAAI,GAAG;IACV,OAAO,EAAE,eAAe,CAAA;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;IAC7C,eAAe,CAAC,EAAE,eAAe,CAAA;IACjC,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,cAAc,EAAE,OAAO,CAAA;IACvB,aAAa,EAAE,OAAO,CAAA;IACtB,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,oBAAoB,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC1C,iBAAiB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IAC/B,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,QAAQ,EAAE,OAAO,CAAA;CAClB,CAAA;AAED,KAAK,MAAM,GAAG;IACZ,kBAAkB,EAAE,OAAO,GAAG,OAAO,CAAA;IACrC,gBAAgB,EAAE,OAAO,GAAG,OAAO,CAAA;IACnC,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACtC,CAAA;AAED,eAAO,MAAM,UAAU,wQAiBpB,IAAI,KAAG,MAkWT,CAAA"}
|
package/dist/schema/build.js
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
/* eslint-disable no-param-reassign */ import { relations } from 'drizzle-orm';
|
2
|
-
import { index, integer, numeric, serial, timestamp, unique, varchar } from 'drizzle-orm/pg-core';
|
2
|
+
import { foreignKey, index, integer, numeric, serial, timestamp, unique, varchar } from 'drizzle-orm/pg-core';
|
3
|
+
import toSnakeCase from 'to-snake-case';
|
3
4
|
import { getTableName } from './getTableName.js';
|
4
5
|
import { parentIDColumnMap } from './parentIDColumnMap.js';
|
5
6
|
import { setColumnID } from './setColumnID.js';
|
@@ -61,25 +62,33 @@ export const buildTable = ({ adapter, baseColumns = {}, baseExtraConfig = {}, bu
|
|
61
62
|
config[key] = func(cols);
|
62
63
|
return config;
|
63
64
|
}, {});
|
64
|
-
|
65
|
+
const result = Object.entries(indexes).reduce((acc, [colName, func])=>{
|
65
66
|
acc[colName] = func(cols);
|
66
67
|
return acc;
|
67
68
|
}, extraConfig);
|
69
|
+
return result;
|
68
70
|
});
|
69
71
|
adapter.tables[tableName] = table;
|
70
72
|
if (hasLocalizedField) {
|
71
73
|
const localeTableName = `${tableName}${adapter.localesSuffix}`;
|
72
74
|
localesColumns.id = serial('id').primaryKey();
|
73
75
|
localesColumns._locale = adapter.enums.enum__locales('_locale').notNull();
|
74
|
-
localesColumns._parentID = parentIDColumnMap[idColType]('_parent_id').
|
75
|
-
onDelete: 'cascade'
|
76
|
-
}).notNull();
|
76
|
+
localesColumns._parentID = parentIDColumnMap[idColType]('_parent_id').notNull();
|
77
77
|
localesTable = adapter.pgSchema.table(localeTableName, localesColumns, (cols)=>{
|
78
78
|
return Object.entries(localesIndexes).reduce((acc, [colName, func])=>{
|
79
79
|
acc[colName] = func(cols);
|
80
80
|
return acc;
|
81
81
|
}, {
|
82
|
-
_localeParent: unique(`${localeTableName}_locale_parent_id_unique`).on(cols._locale, cols._parentID)
|
82
|
+
_localeParent: unique(`${localeTableName}_locale_parent_id_unique`).on(cols._locale, cols._parentID),
|
83
|
+
_parentIdFk: foreignKey({
|
84
|
+
name: `${localeTableName}_parent_id_fk`,
|
85
|
+
columns: [
|
86
|
+
cols._parentID
|
87
|
+
],
|
88
|
+
foreignColumns: [
|
89
|
+
table.id
|
90
|
+
]
|
91
|
+
}).onDelete('cascade')
|
83
92
|
});
|
84
93
|
});
|
85
94
|
adapter.tables[localeTableName] = localesTable;
|
@@ -100,9 +109,7 @@ export const buildTable = ({ adapter, baseColumns = {}, baseExtraConfig = {}, bu
|
|
100
109
|
const columns = {
|
101
110
|
id: serial('id').primaryKey(),
|
102
111
|
order: integer('order').notNull(),
|
103
|
-
parent: parentIDColumnMap[idColType]('parent_id').
|
104
|
-
onDelete: 'cascade'
|
105
|
-
}).notNull(),
|
112
|
+
parent: parentIDColumnMap[idColType]('parent_id').notNull(),
|
106
113
|
path: varchar('path').notNull(),
|
107
114
|
text: varchar('text')
|
108
115
|
};
|
@@ -110,16 +117,25 @@ export const buildTable = ({ adapter, baseColumns = {}, baseExtraConfig = {}, bu
|
|
110
117
|
columns.locale = adapter.enums.enum__locales('locale');
|
111
118
|
}
|
112
119
|
textsTable = adapter.pgSchema.table(textsTableName, columns, (cols)=>{
|
113
|
-
const
|
114
|
-
orderParentIdx: index(`${textsTableName}_order_parent_idx`).on(cols.order, cols.parent)
|
120
|
+
const config = {
|
121
|
+
orderParentIdx: index(`${textsTableName}_order_parent_idx`).on(cols.order, cols.parent),
|
122
|
+
parentFk: foreignKey({
|
123
|
+
name: `${textsTableName}_parent_fk`,
|
124
|
+
columns: [
|
125
|
+
cols.parent
|
126
|
+
],
|
127
|
+
foreignColumns: [
|
128
|
+
table.id
|
129
|
+
]
|
130
|
+
}).onDelete('cascade')
|
115
131
|
};
|
116
132
|
if (hasManyTextField === 'index') {
|
117
|
-
|
133
|
+
config.text_idx = index(`${textsTableName}_text_idx`).on(cols.text);
|
118
134
|
}
|
119
135
|
if (hasLocalizedManyTextField) {
|
120
|
-
|
136
|
+
config.localeParent = index(`${textsTableName}_locale_parent`).on(cols.locale, cols.parent);
|
121
137
|
}
|
122
|
-
return
|
138
|
+
return config;
|
123
139
|
});
|
124
140
|
adapter.tables[textsTableName] = textsTable;
|
125
141
|
const textsTableRelations = relations(textsTable, ({ one })=>({
|
@@ -140,25 +156,32 @@ export const buildTable = ({ adapter, baseColumns = {}, baseExtraConfig = {}, bu
|
|
140
156
|
id: serial('id').primaryKey(),
|
141
157
|
number: numeric('number'),
|
142
158
|
order: integer('order').notNull(),
|
143
|
-
parent: parentIDColumnMap[idColType]('parent_id').
|
144
|
-
onDelete: 'cascade'
|
145
|
-
}).notNull(),
|
159
|
+
parent: parentIDColumnMap[idColType]('parent_id').notNull(),
|
146
160
|
path: varchar('path').notNull()
|
147
161
|
};
|
148
162
|
if (hasLocalizedManyNumberField) {
|
149
163
|
columns.locale = adapter.enums.enum__locales('locale');
|
150
164
|
}
|
151
165
|
numbersTable = adapter.pgSchema.table(numbersTableName, columns, (cols)=>{
|
152
|
-
const
|
153
|
-
orderParentIdx: index(`${numbersTableName}_order_parent_idx`).on(cols.order, cols.parent)
|
166
|
+
const config = {
|
167
|
+
orderParentIdx: index(`${numbersTableName}_order_parent_idx`).on(cols.order, cols.parent),
|
168
|
+
parentFk: foreignKey({
|
169
|
+
name: `${numbersTableName}_parent_fk`,
|
170
|
+
columns: [
|
171
|
+
cols.parent
|
172
|
+
],
|
173
|
+
foreignColumns: [
|
174
|
+
table.id
|
175
|
+
]
|
176
|
+
}).onDelete('cascade')
|
154
177
|
};
|
155
178
|
if (hasManyNumberField === 'index') {
|
156
|
-
|
179
|
+
config.numberIdx = index(`${numbersTableName}_number_idx`).on(cols.number);
|
157
180
|
}
|
158
181
|
if (hasLocalizedManyNumberField) {
|
159
|
-
|
182
|
+
config.localeParent = index(`${numbersTableName}_locale_parent`).on(cols.locale, cols.parent);
|
160
183
|
}
|
161
|
-
return
|
184
|
+
return config;
|
162
185
|
});
|
163
186
|
adapter.tables[numbersTableName] = numbersTable;
|
164
187
|
const numbersTableRelations = relations(numbersTable, ({ one })=>({
|
@@ -178,14 +201,14 @@ export const buildTable = ({ adapter, baseColumns = {}, baseExtraConfig = {}, bu
|
|
178
201
|
const relationshipColumns = {
|
179
202
|
id: serial('id').primaryKey(),
|
180
203
|
order: integer('order'),
|
181
|
-
parent: parentIDColumnMap[idColType]('parent_id').
|
182
|
-
onDelete: 'cascade'
|
183
|
-
}).notNull(),
|
204
|
+
parent: parentIDColumnMap[idColType]('parent_id').notNull(),
|
184
205
|
path: varchar('path').notNull()
|
185
206
|
};
|
186
207
|
if (hasLocalizedRelationshipField) {
|
187
208
|
relationshipColumns.locale = adapter.enums.enum__locales('locale');
|
188
209
|
}
|
210
|
+
const relationExtraConfig = {};
|
211
|
+
const relationshipsTableName = `${tableName}${adapter.relationshipsSuffix}`;
|
189
212
|
relationships.forEach((relationTo)=>{
|
190
213
|
const relationshipConfig = adapter.payload.collections[relationTo].config;
|
191
214
|
const formattedRelationTo = getTableName({
|
@@ -197,17 +220,35 @@ export const buildTable = ({ adapter, baseColumns = {}, baseExtraConfig = {}, bu
|
|
197
220
|
const relatedCollectionCustomIDType = adapter.payload.collections[relationshipConfig.slug]?.customIDType;
|
198
221
|
if (relatedCollectionCustomIDType === 'number') colType = 'numeric';
|
199
222
|
if (relatedCollectionCustomIDType === 'text') colType = 'varchar';
|
200
|
-
relationshipColumns[`${relationTo}ID`] = parentIDColumnMap[colType](`${formattedRelationTo}_id`)
|
201
|
-
|
202
|
-
|
223
|
+
relationshipColumns[`${relationTo}ID`] = parentIDColumnMap[colType](`${formattedRelationTo}_id`);
|
224
|
+
relationExtraConfig[`${relationTo}IdFk`] = (cols)=>foreignKey({
|
225
|
+
name: `${relationshipsTableName}_${toSnakeCase(relationTo)}_fk`,
|
226
|
+
columns: [
|
227
|
+
cols[`${relationTo}ID`]
|
228
|
+
],
|
229
|
+
foreignColumns: [
|
230
|
+
adapter.tables[formattedRelationTo].id
|
231
|
+
]
|
232
|
+
}).onDelete('cascade');
|
203
233
|
});
|
204
|
-
const relationshipsTableName = `${tableName}${adapter.relationshipsSuffix}`;
|
205
234
|
relationshipsTable = adapter.pgSchema.table(relationshipsTableName, relationshipColumns, (cols)=>{
|
206
|
-
const result = {
|
235
|
+
const result = Object.entries(relationExtraConfig).reduce((config, [key, func])=>{
|
236
|
+
config[key] = func(cols);
|
237
|
+
return config;
|
238
|
+
}, {
|
207
239
|
order: index(`${relationshipsTableName}_order_idx`).on(cols.order),
|
240
|
+
parentFk: foreignKey({
|
241
|
+
name: `${relationshipsTableName}_parent_fk`,
|
242
|
+
columns: [
|
243
|
+
cols.parent
|
244
|
+
],
|
245
|
+
foreignColumns: [
|
246
|
+
table.id
|
247
|
+
]
|
248
|
+
}).onDelete('cascade'),
|
208
249
|
parentIdx: index(`${relationshipsTableName}_parent_idx`).on(cols.parent),
|
209
250
|
pathIdx: index(`${relationshipsTableName}_path_idx`).on(cols.path)
|
210
|
-
};
|
251
|
+
});
|
211
252
|
if (hasLocalizedRelationshipField) {
|
212
253
|
result.localeIdx = index(`${relationshipsTableName}_locale_idx`).on(cols.locale);
|
213
254
|
}
|
package/dist/schema/build.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/schema/build.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport type { Relation } from 'drizzle-orm'\nimport type {\n IndexBuilder,\n PgColumnBuilder,\n PgTableWithColumns,\n UniqueConstraintBuilder,\n} from 'drizzle-orm/pg-core'\nimport type { Field } from 'payload/types'\n\nimport { relations } from 'drizzle-orm'\nimport { index, integer, numeric, serial, timestamp, unique, varchar } from 'drizzle-orm/pg-core'\nimport { fieldAffectsData } from 'payload/types'\n\nimport type { GenericColumns, GenericTable, IDType, PostgresAdapter } from '../types.js'\n\nimport { getTableName } from './getTableName.js'\nimport { parentIDColumnMap } from './parentIDColumnMap.js'\nimport { setColumnID } from './setColumnID.js'\nimport { traverseFields } from './traverseFields.js'\n\ntype Args = {\n adapter: PostgresAdapter\n baseColumns?: Record<string, PgColumnBuilder>\n baseExtraConfig?: Record<string, (cols: GenericColumns) => IndexBuilder | UniqueConstraintBuilder>\n buildNumbers?: boolean\n buildRelationships?: boolean\n buildTexts?: boolean\n disableNotNull: boolean\n disableUnique: boolean\n fields: Field[]\n rootRelationsToBuild?: Map<string, string>\n rootRelationships?: Set<string>\n rootTableIDColType?: string\n rootTableName?: string\n tableName: string\n timestamps?: boolean\n versions: boolean\n}\n\ntype Result = {\n hasManyNumberField: 'index' | boolean\n hasManyTextField: 'index' | boolean\n relationsToBuild: Map<string, string>\n}\n\nexport const buildTable = ({\n adapter,\n baseColumns = {},\n baseExtraConfig = {},\n buildNumbers,\n buildRelationships,\n buildTexts,\n disableNotNull,\n disableUnique = false,\n fields,\n rootRelationsToBuild,\n rootRelationships,\n rootTableIDColType,\n rootTableName: incomingRootTableName,\n tableName,\n timestamps,\n versions,\n}: Args): Result => {\n const rootTableName = incomingRootTableName || tableName\n const columns: Record<string, PgColumnBuilder> = baseColumns\n const indexes: Record<string, (cols: GenericColumns) => IndexBuilder> = {}\n\n const localesColumns: Record<string, PgColumnBuilder> = {}\n const localesIndexes: Record<string, (cols: GenericColumns) => IndexBuilder> = {}\n let localesTable: GenericTable | PgTableWithColumns<any>\n let textsTable: GenericTable | PgTableWithColumns<any>\n let numbersTable: GenericTable | PgTableWithColumns<any>\n\n // Relationships to the base collection\n const relationships: Set<string> = rootRelationships || new Set()\n\n let relationshipsTable: GenericTable | PgTableWithColumns<any>\n\n // Drizzle relations\n const relationsToBuild: Map<string, string> = new Map()\n\n const idColType: IDType = setColumnID({ adapter, columns, fields })\n\n const {\n hasLocalizedField,\n hasLocalizedManyNumberField,\n hasLocalizedManyTextField,\n hasLocalizedRelationshipField,\n hasManyNumberField,\n hasManyTextField,\n } = traverseFields({\n adapter,\n buildNumbers,\n buildRelationships,\n buildTexts,\n columns,\n disableNotNull,\n disableUnique,\n fields,\n indexes,\n localesColumns,\n localesIndexes,\n newTableName: tableName,\n parentTableName: tableName,\n relationsToBuild,\n relationships,\n rootRelationsToBuild: rootRelationsToBuild || relationsToBuild,\n rootTableIDColType: rootTableIDColType || idColType,\n rootTableName,\n versions,\n })\n\n if (timestamps) {\n columns.createdAt = timestamp('created_at', {\n mode: 'string',\n precision: 3,\n withTimezone: true,\n })\n .defaultNow()\n .notNull()\n columns.updatedAt = timestamp('updated_at', {\n mode: 'string',\n precision: 3,\n withTimezone: true,\n })\n .defaultNow()\n .notNull()\n }\n\n const table = adapter.pgSchema.table(tableName, columns, (cols) => {\n const extraConfig = Object.entries(baseExtraConfig).reduce((config, [key, func]) => {\n config[key] = func(cols)\n return config\n }, {})\n\n return Object.entries(indexes).reduce((acc, [colName, func]) => {\n acc[colName] = func(cols)\n return acc\n }, extraConfig)\n })\n\n adapter.tables[tableName] = table\n\n if (hasLocalizedField) {\n const localeTableName = `${tableName}${adapter.localesSuffix}`\n localesColumns.id = serial('id').primaryKey()\n localesColumns._locale = adapter.enums.enum__locales('_locale').notNull()\n localesColumns._parentID = parentIDColumnMap[idColType]('_parent_id')\n .references(() => table.id, { onDelete: 'cascade' })\n .notNull()\n\n localesTable = adapter.pgSchema.table(localeTableName, localesColumns, (cols) => {\n return Object.entries(localesIndexes).reduce(\n (acc, [colName, func]) => {\n acc[colName] = func(cols)\n return acc\n },\n {\n _localeParent: unique(`${localeTableName}_locale_parent_id_unique`).on(\n cols._locale,\n cols._parentID,\n ),\n },\n )\n })\n\n adapter.tables[localeTableName] = localesTable\n\n const localesTableRelations = relations(localesTable, ({ one }) => ({\n _parentID: one(table, {\n fields: [localesTable._parentID],\n references: [table.id],\n }),\n }))\n\n adapter.relations[`relations_${localeTableName}`] = localesTableRelations\n }\n\n if (hasManyTextField && buildTexts) {\n const textsTableName = `${rootTableName}_texts`\n const columns: Record<string, PgColumnBuilder> = {\n id: serial('id').primaryKey(),\n order: integer('order').notNull(),\n parent: parentIDColumnMap[idColType]('parent_id')\n .references(() => table.id, { onDelete: 'cascade' })\n .notNull(),\n path: varchar('path').notNull(),\n text: varchar('text'),\n }\n\n if (hasLocalizedManyTextField) {\n columns.locale = adapter.enums.enum__locales('locale')\n }\n\n textsTable = adapter.pgSchema.table(textsTableName, columns, (cols) => {\n const indexes: Record<string, IndexBuilder> = {\n orderParentIdx: index(`${textsTableName}_order_parent_idx`).on(cols.order, cols.parent),\n }\n\n if (hasManyTextField === 'index') {\n indexes.text_idx = index(`${textsTableName}_text_idx`).on(cols.text)\n }\n\n if (hasLocalizedManyTextField) {\n indexes.localeParent = index(`${textsTableName}_locale_parent`).on(cols.locale, cols.parent)\n }\n\n return indexes\n })\n\n adapter.tables[textsTableName] = textsTable\n\n const textsTableRelations = relations(textsTable, ({ one }) => ({\n parent: one(table, {\n fields: [textsTable.parent],\n references: [table.id],\n }),\n }))\n\n adapter.relations[`relations_${textsTableName}`] = textsTableRelations\n }\n\n if (hasManyNumberField && buildNumbers) {\n const numbersTableName = `${rootTableName}_numbers`\n const columns: Record<string, PgColumnBuilder> = {\n id: serial('id').primaryKey(),\n number: numeric('number'),\n order: integer('order').notNull(),\n parent: parentIDColumnMap[idColType]('parent_id')\n .references(() => table.id, { onDelete: 'cascade' })\n .notNull(),\n path: varchar('path').notNull(),\n }\n\n if (hasLocalizedManyNumberField) {\n columns.locale = adapter.enums.enum__locales('locale')\n }\n\n numbersTable = adapter.pgSchema.table(numbersTableName, columns, (cols) => {\n const indexes: Record<string, IndexBuilder> = {\n orderParentIdx: index(`${numbersTableName}_order_parent_idx`).on(cols.order, cols.parent),\n }\n\n if (hasManyNumberField === 'index') {\n indexes.numberIdx = index(`${numbersTableName}_number_idx`).on(cols.number)\n }\n\n if (hasLocalizedManyNumberField) {\n indexes.localeParent = index(`${numbersTableName}_locale_parent`).on(\n cols.locale,\n cols.parent,\n )\n }\n\n return indexes\n })\n\n adapter.tables[numbersTableName] = numbersTable\n\n const numbersTableRelations = relations(numbersTable, ({ one }) => ({\n parent: one(table, {\n fields: [numbersTable.parent],\n references: [table.id],\n }),\n }))\n\n adapter.relations[`relations_${numbersTableName}`] = numbersTableRelations\n }\n\n if (buildRelationships) {\n if (relationships.size) {\n const relationshipColumns: Record<string, PgColumnBuilder> = {\n id: serial('id').primaryKey(),\n order: integer('order'),\n parent: parentIDColumnMap[idColType]('parent_id')\n .references(() => table.id, { onDelete: 'cascade' })\n .notNull(),\n path: varchar('path').notNull(),\n }\n\n if (hasLocalizedRelationshipField) {\n relationshipColumns.locale = adapter.enums.enum__locales('locale')\n }\n\n relationships.forEach((relationTo) => {\n const relationshipConfig = adapter.payload.collections[relationTo].config\n const formattedRelationTo = getTableName({\n adapter,\n config: relationshipConfig,\n throwValidationError: true,\n })\n let colType = adapter.idType === 'uuid' ? 'uuid' : 'integer'\n\n const relatedCollectionCustomIDType =\n adapter.payload.collections[relationshipConfig.slug]?.customIDType\n\n if (relatedCollectionCustomIDType === 'number') colType = 'numeric'\n if (relatedCollectionCustomIDType === 'text') colType = 'varchar'\n\n relationshipColumns[`${relationTo}ID`] = parentIDColumnMap[colType](\n `${formattedRelationTo}_id`,\n ).references(() => adapter.tables[formattedRelationTo].id, { onDelete: 'cascade' })\n })\n\n const relationshipsTableName = `${tableName}${adapter.relationshipsSuffix}`\n\n relationshipsTable = adapter.pgSchema.table(\n relationshipsTableName,\n relationshipColumns,\n (cols) => {\n const result: Record<string, unknown> = {\n order: index(`${relationshipsTableName}_order_idx`).on(cols.order),\n parentIdx: index(`${relationshipsTableName}_parent_idx`).on(cols.parent),\n pathIdx: index(`${relationshipsTableName}_path_idx`).on(cols.path),\n }\n\n if (hasLocalizedRelationshipField) {\n result.localeIdx = index(`${relationshipsTableName}_locale_idx`).on(cols.locale)\n }\n\n return result\n },\n )\n\n adapter.tables[relationshipsTableName] = relationshipsTable\n\n const relationshipsTableRelations = relations(relationshipsTable, ({ one }) => {\n const result: Record<string, Relation<string>> = {\n parent: one(table, {\n fields: [relationshipsTable.parent],\n references: [table.id],\n relationName: '_rels',\n }),\n }\n\n relationships.forEach((relationTo) => {\n const relatedTableName = getTableName({\n adapter,\n config: adapter.payload.collections[relationTo].config,\n throwValidationError: true,\n })\n const idColumnName = `${relationTo}ID`\n result[idColumnName] = one(adapter.tables[relatedTableName], {\n fields: [relationshipsTable[idColumnName]],\n references: [adapter.tables[relatedTableName].id],\n })\n })\n\n return result\n })\n\n adapter.relations[`relations_${relationshipsTableName}`] = relationshipsTableRelations\n }\n }\n\n const tableRelations = relations(table, ({ many }) => {\n const result: Record<string, Relation<string>> = {}\n\n relationsToBuild.forEach((val, key) => {\n result[key] = many(adapter.tables[val])\n })\n\n if (hasLocalizedField) {\n result._locales = many(localesTable)\n }\n\n if (hasManyTextField) {\n result._texts = many(textsTable)\n }\n if (hasManyNumberField) {\n result._numbers = many(numbersTable)\n }\n\n if (relationships.size && relationshipsTable) {\n result._rels = many(relationshipsTable, {\n relationName: '_rels',\n })\n }\n\n return result\n })\n\n adapter.relations[`relations_${tableName}`] = tableRelations\n\n return { hasManyNumberField, hasManyTextField, relationsToBuild }\n}\n"],"names":["relations","index","integer","numeric","serial","timestamp","unique","varchar","getTableName","parentIDColumnMap","setColumnID","traverseFields","buildTable","adapter","baseColumns","baseExtraConfig","buildNumbers","buildRelationships","buildTexts","disableNotNull","disableUnique","fields","rootRelationsToBuild","rootRelationships","rootTableIDColType","rootTableName","incomingRootTableName","tableName","timestamps","versions","columns","indexes","localesColumns","localesIndexes","localesTable","textsTable","numbersTable","relationships","Set","relationshipsTable","relationsToBuild","Map","idColType","hasLocalizedField","hasLocalizedManyNumberField","hasLocalizedManyTextField","hasLocalizedRelationshipField","hasManyNumberField","hasManyTextField","newTableName","parentTableName","createdAt","mode","precision","withTimezone","defaultNow","notNull","updatedAt","table","pgSchema","cols","extraConfig","Object","entries","reduce","config","key","func","acc","colName","tables","localeTableName","localesSuffix","id","primaryKey","_locale","enums","enum__locales","_parentID","references","onDelete","_localeParent","on","localesTableRelations","one","textsTableName","order","parent","path","text","locale","orderParentIdx","text_idx","localeParent","textsTableRelations","numbersTableName","number","numberIdx","numbersTableRelations","size","relationshipColumns","forEach","relationTo","relationshipConfig","payload","collections","formattedRelationTo","throwValidationError","colType","idType","relatedCollectionCustomIDType","slug","customIDType","relationshipsTableName","relationshipsSuffix","result","parentIdx","pathIdx","localeIdx","relationshipsTableRelations","relationName","relatedTableName","idColumnName","tableRelations","many","val","_locales","_texts","_numbers","_rels"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,oCAAoC,GAUpC,SAASA,SAAS,QAAQ,cAAa;AACvC,SAASC,KAAK,EAAEC,OAAO,EAAEC,OAAO,EAAEC,MAAM,EAAEC,SAAS,EAAEC,MAAM,EAAEC,OAAO,QAAQ,sBAAqB;AAKjG,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SAASC,iBAAiB,QAAQ,yBAAwB;AAC1D,SAASC,WAAW,QAAQ,mBAAkB;AAC9C,SAASC,cAAc,QAAQ,sBAAqB;AA2BpD,OAAO,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B,UAAU,CAAC,CAAC,GAAGgG;IAE9C,OAAO;QAAE5E;QAAoBC;QAAkBR;IAAiB;AAClE,EAAC"}
|
1
|
+
{"version":3,"sources":["../../src/schema/build.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport type { Relation } from 'drizzle-orm'\nimport type {\n ForeignKeyBuilder,\n IndexBuilder,\n PgColumnBuilder,\n PgTableWithColumns,\n UniqueConstraintBuilder,\n} from 'drizzle-orm/pg-core'\nimport type { Field } from 'payload/types'\n\nimport { relations } from 'drizzle-orm'\nimport {\n foreignKey,\n index,\n integer,\n numeric,\n serial,\n timestamp,\n unique,\n varchar,\n} from 'drizzle-orm/pg-core'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { GenericColumns, GenericTable, IDType, PostgresAdapter } from '../types.js'\n\nimport { getTableName } from './getTableName.js'\nimport { parentIDColumnMap } from './parentIDColumnMap.js'\nimport { setColumnID } from './setColumnID.js'\nimport { traverseFields } from './traverseFields.js'\n\nexport type BaseExtraConfig = Record<\n string,\n (cols: GenericColumns) => ForeignKeyBuilder | IndexBuilder | UniqueConstraintBuilder\n>\n\ntype Args = {\n adapter: PostgresAdapter\n baseColumns?: Record<string, PgColumnBuilder>\n baseExtraConfig?: BaseExtraConfig\n buildNumbers?: boolean\n buildRelationships?: boolean\n buildTexts?: boolean\n disableNotNull: boolean\n disableUnique: boolean\n fields: Field[]\n rootRelationsToBuild?: Map<string, string>\n rootRelationships?: Set<string>\n rootTableIDColType?: string\n rootTableName?: string\n tableName: string\n timestamps?: boolean\n versions: boolean\n}\n\ntype Result = {\n hasManyNumberField: 'index' | boolean\n hasManyTextField: 'index' | boolean\n relationsToBuild: Map<string, string>\n}\n\nexport const buildTable = ({\n adapter,\n baseColumns = {},\n baseExtraConfig = {},\n buildNumbers,\n buildRelationships,\n buildTexts,\n disableNotNull,\n disableUnique = false,\n fields,\n rootRelationsToBuild,\n rootRelationships,\n rootTableIDColType,\n rootTableName: incomingRootTableName,\n tableName,\n timestamps,\n versions,\n}: Args): Result => {\n const rootTableName = incomingRootTableName || tableName\n const columns: Record<string, PgColumnBuilder> = baseColumns\n const indexes: Record<string, (cols: GenericColumns) => IndexBuilder> = {}\n\n const localesColumns: Record<string, PgColumnBuilder> = {}\n const localesIndexes: Record<string, (cols: GenericColumns) => IndexBuilder> = {}\n let localesTable: GenericTable | PgTableWithColumns<any>\n let textsTable: GenericTable | PgTableWithColumns<any>\n let numbersTable: GenericTable | PgTableWithColumns<any>\n\n // Relationships to the base collection\n const relationships: Set<string> = rootRelationships || new Set()\n\n let relationshipsTable: GenericTable | PgTableWithColumns<any>\n\n // Drizzle relations\n const relationsToBuild: Map<string, string> = new Map()\n\n const idColType: IDType = setColumnID({ adapter, columns, fields })\n\n const {\n hasLocalizedField,\n hasLocalizedManyNumberField,\n hasLocalizedManyTextField,\n hasLocalizedRelationshipField,\n hasManyNumberField,\n hasManyTextField,\n } = traverseFields({\n adapter,\n buildNumbers,\n buildRelationships,\n buildTexts,\n columns,\n disableNotNull,\n disableUnique,\n fields,\n indexes,\n localesColumns,\n localesIndexes,\n newTableName: tableName,\n parentTableName: tableName,\n relationsToBuild,\n relationships,\n rootRelationsToBuild: rootRelationsToBuild || relationsToBuild,\n rootTableIDColType: rootTableIDColType || idColType,\n rootTableName,\n versions,\n })\n\n if (timestamps) {\n columns.createdAt = timestamp('created_at', {\n mode: 'string',\n precision: 3,\n withTimezone: true,\n })\n .defaultNow()\n .notNull()\n columns.updatedAt = timestamp('updated_at', {\n mode: 'string',\n precision: 3,\n withTimezone: true,\n })\n .defaultNow()\n .notNull()\n }\n\n const table = adapter.pgSchema.table(tableName, columns, (cols) => {\n const extraConfig = Object.entries(baseExtraConfig).reduce((config, [key, func]) => {\n config[key] = func(cols)\n return config\n }, {})\n\n const result = Object.entries(indexes).reduce((acc, [colName, func]) => {\n acc[colName] = func(cols)\n return acc\n }, extraConfig)\n\n return result\n })\n\n adapter.tables[tableName] = table\n\n if (hasLocalizedField) {\n const localeTableName = `${tableName}${adapter.localesSuffix}`\n localesColumns.id = serial('id').primaryKey()\n localesColumns._locale = adapter.enums.enum__locales('_locale').notNull()\n localesColumns._parentID = parentIDColumnMap[idColType]('_parent_id').notNull()\n\n localesTable = adapter.pgSchema.table(localeTableName, localesColumns, (cols) => {\n return Object.entries(localesIndexes).reduce(\n (acc, [colName, func]) => {\n acc[colName] = func(cols)\n return acc\n },\n {\n _localeParent: unique(`${localeTableName}_locale_parent_id_unique`).on(\n cols._locale,\n cols._parentID,\n ),\n _parentIdFk: foreignKey({\n name: `${localeTableName}_parent_id_fk`,\n columns: [cols._parentID],\n foreignColumns: [table.id],\n }).onDelete('cascade'),\n },\n )\n })\n\n adapter.tables[localeTableName] = localesTable\n\n const localesTableRelations = relations(localesTable, ({ one }) => ({\n _parentID: one(table, {\n fields: [localesTable._parentID],\n references: [table.id],\n }),\n }))\n\n adapter.relations[`relations_${localeTableName}`] = localesTableRelations\n }\n\n if (hasManyTextField && buildTexts) {\n const textsTableName = `${rootTableName}_texts`\n const columns: Record<string, PgColumnBuilder> = {\n id: serial('id').primaryKey(),\n order: integer('order').notNull(),\n parent: parentIDColumnMap[idColType]('parent_id').notNull(),\n path: varchar('path').notNull(),\n text: varchar('text'),\n }\n\n if (hasLocalizedManyTextField) {\n columns.locale = adapter.enums.enum__locales('locale')\n }\n\n textsTable = adapter.pgSchema.table(textsTableName, columns, (cols) => {\n const config: Record<string, ForeignKeyBuilder | IndexBuilder> = {\n orderParentIdx: index(`${textsTableName}_order_parent_idx`).on(cols.order, cols.parent),\n parentFk: foreignKey({\n name: `${textsTableName}_parent_fk`,\n columns: [cols.parent],\n foreignColumns: [table.id],\n }).onDelete('cascade'),\n }\n\n if (hasManyTextField === 'index') {\n config.text_idx = index(`${textsTableName}_text_idx`).on(cols.text)\n }\n\n if (hasLocalizedManyTextField) {\n config.localeParent = index(`${textsTableName}_locale_parent`).on(cols.locale, cols.parent)\n }\n\n return config\n })\n\n adapter.tables[textsTableName] = textsTable\n\n const textsTableRelations = relations(textsTable, ({ one }) => ({\n parent: one(table, {\n fields: [textsTable.parent],\n references: [table.id],\n }),\n }))\n\n adapter.relations[`relations_${textsTableName}`] = textsTableRelations\n }\n\n if (hasManyNumberField && buildNumbers) {\n const numbersTableName = `${rootTableName}_numbers`\n const columns: Record<string, PgColumnBuilder> = {\n id: serial('id').primaryKey(),\n number: numeric('number'),\n order: integer('order').notNull(),\n parent: parentIDColumnMap[idColType]('parent_id').notNull(),\n path: varchar('path').notNull(),\n }\n\n if (hasLocalizedManyNumberField) {\n columns.locale = adapter.enums.enum__locales('locale')\n }\n\n numbersTable = adapter.pgSchema.table(numbersTableName, columns, (cols) => {\n const config: Record<string, ForeignKeyBuilder | IndexBuilder> = {\n orderParentIdx: index(`${numbersTableName}_order_parent_idx`).on(cols.order, cols.parent),\n parentFk: foreignKey({\n name: `${numbersTableName}_parent_fk`,\n columns: [cols.parent],\n foreignColumns: [table.id],\n }).onDelete('cascade'),\n }\n\n if (hasManyNumberField === 'index') {\n config.numberIdx = index(`${numbersTableName}_number_idx`).on(cols.number)\n }\n\n if (hasLocalizedManyNumberField) {\n config.localeParent = index(`${numbersTableName}_locale_parent`).on(\n cols.locale,\n cols.parent,\n )\n }\n\n return config\n })\n\n adapter.tables[numbersTableName] = numbersTable\n\n const numbersTableRelations = relations(numbersTable, ({ one }) => ({\n parent: one(table, {\n fields: [numbersTable.parent],\n references: [table.id],\n }),\n }))\n\n adapter.relations[`relations_${numbersTableName}`] = numbersTableRelations\n }\n\n if (buildRelationships) {\n if (relationships.size) {\n const relationshipColumns: Record<string, PgColumnBuilder> = {\n id: serial('id').primaryKey(),\n order: integer('order'),\n parent: parentIDColumnMap[idColType]('parent_id').notNull(),\n path: varchar('path').notNull(),\n }\n\n if (hasLocalizedRelationshipField) {\n relationshipColumns.locale = adapter.enums.enum__locales('locale')\n }\n\n const relationExtraConfig: BaseExtraConfig = {}\n\n const relationshipsTableName = `${tableName}${adapter.relationshipsSuffix}`\n\n relationships.forEach((relationTo) => {\n const relationshipConfig = adapter.payload.collections[relationTo].config\n const formattedRelationTo = getTableName({\n adapter,\n config: relationshipConfig,\n throwValidationError: true,\n })\n let colType = adapter.idType === 'uuid' ? 'uuid' : 'integer'\n\n const relatedCollectionCustomIDType =\n adapter.payload.collections[relationshipConfig.slug]?.customIDType\n\n if (relatedCollectionCustomIDType === 'number') colType = 'numeric'\n if (relatedCollectionCustomIDType === 'text') colType = 'varchar'\n\n relationshipColumns[`${relationTo}ID`] = parentIDColumnMap[colType](\n `${formattedRelationTo}_id`,\n )\n\n relationExtraConfig[`${relationTo}IdFk`] = (cols) =>\n foreignKey({\n name: `${relationshipsTableName}_${toSnakeCase(relationTo)}_fk`,\n columns: [cols[`${relationTo}ID`]],\n foreignColumns: [adapter.tables[formattedRelationTo].id],\n }).onDelete('cascade')\n })\n\n relationshipsTable = adapter.pgSchema.table(\n relationshipsTableName,\n relationshipColumns,\n (cols) => {\n const result: Record<string, ForeignKeyBuilder | IndexBuilder> = Object.entries(\n relationExtraConfig,\n ).reduce(\n (config, [key, func]) => {\n config[key] = func(cols)\n return config\n },\n {\n order: index(`${relationshipsTableName}_order_idx`).on(cols.order),\n parentFk: foreignKey({\n name: `${relationshipsTableName}_parent_fk`,\n columns: [cols.parent],\n foreignColumns: [table.id],\n }).onDelete('cascade'),\n parentIdx: index(`${relationshipsTableName}_parent_idx`).on(cols.parent),\n pathIdx: index(`${relationshipsTableName}_path_idx`).on(cols.path),\n },\n )\n\n if (hasLocalizedRelationshipField) {\n result.localeIdx = index(`${relationshipsTableName}_locale_idx`).on(cols.locale)\n }\n\n return result\n },\n )\n\n adapter.tables[relationshipsTableName] = relationshipsTable\n\n const relationshipsTableRelations = relations(relationshipsTable, ({ one }) => {\n const result: Record<string, Relation<string>> = {\n parent: one(table, {\n fields: [relationshipsTable.parent],\n references: [table.id],\n relationName: '_rels',\n }),\n }\n\n relationships.forEach((relationTo) => {\n const relatedTableName = getTableName({\n adapter,\n config: adapter.payload.collections[relationTo].config,\n throwValidationError: true,\n })\n const idColumnName = `${relationTo}ID`\n result[idColumnName] = one(adapter.tables[relatedTableName], {\n fields: [relationshipsTable[idColumnName]],\n references: [adapter.tables[relatedTableName].id],\n })\n })\n\n return result\n })\n\n adapter.relations[`relations_${relationshipsTableName}`] = relationshipsTableRelations\n }\n }\n\n const tableRelations = relations(table, ({ many }) => {\n const result: Record<string, Relation<string>> = {}\n\n relationsToBuild.forEach((val, key) => {\n result[key] = many(adapter.tables[val])\n })\n\n if (hasLocalizedField) {\n result._locales = many(localesTable)\n }\n\n if (hasManyTextField) {\n result._texts = many(textsTable)\n }\n if (hasManyNumberField) {\n result._numbers = many(numbersTable)\n }\n\n if (relationships.size && relationshipsTable) {\n result._rels = many(relationshipsTable, {\n relationName: '_rels',\n })\n }\n\n return result\n })\n\n adapter.relations[`relations_${tableName}`] = tableRelations\n\n return { hasManyNumberField, hasManyTextField, relationsToBuild }\n}\n"],"names":["relations","foreignKey","index","integer","numeric","serial","timestamp","unique","varchar","toSnakeCase","getTableName","parentIDColumnMap","setColumnID","traverseFields","buildTable","adapter","baseColumns","baseExtraConfig","buildNumbers","buildRelationships","buildTexts","disableNotNull","disableUnique","fields","rootRelationsToBuild","rootRelationships","rootTableIDColType","rootTableName","incomingRootTableName","tableName","timestamps","versions","columns","indexes","localesColumns","localesIndexes","localesTable","textsTable","numbersTable","relationships","Set","relationshipsTable","relationsToBuild","Map","idColType","hasLocalizedField","hasLocalizedManyNumberField","hasLocalizedManyTextField","hasLocalizedRelationshipField","hasManyNumberField","hasManyTextField","newTableName","parentTableName","createdAt","mode","precision","withTimezone","defaultNow","notNull","updatedAt","table","pgSchema","cols","extraConfig","Object","entries","reduce","config","key","func","result","acc","colName","tables","localeTableName","localesSuffix","id","primaryKey","_locale","enums","enum__locales","_parentID","_localeParent","on","_parentIdFk","name","foreignColumns","onDelete","localesTableRelations","one","references","textsTableName","order","parent","path","text","locale","orderParentIdx","parentFk","text_idx","localeParent","textsTableRelations","numbersTableName","number","numberIdx","numbersTableRelations","size","relationshipColumns","relationExtraConfig","relationshipsTableName","relationshipsSuffix","forEach","relationTo","relationshipConfig","payload","collections","formattedRelationTo","throwValidationError","colType","idType","relatedCollectionCustomIDType","slug","customIDType","parentIdx","pathIdx","localeIdx","relationshipsTableRelations","relationName","relatedTableName","idColumnName","tableRelations","many","val","_locales","_texts","_numbers","_rels"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,oCAAoC,GAWpC,SAASA,SAAS,QAAQ,cAAa;AACvC,SACEC,UAAU,EACVC,KAAK,EACLC,OAAO,EACPC,OAAO,EACPC,MAAM,EACNC,SAAS,EACTC,MAAM,EACNC,OAAO,QACF,sBAAqB;AAC5B,OAAOC,iBAAiB,gBAAe;AAIvC,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SAASC,iBAAiB,QAAQ,yBAAwB;AAC1D,SAASC,WAAW,QAAQ,mBAAkB;AAC9C,SAASC,cAAc,QAAQ,sBAAqB;AAgCpD,OAAO,MAAMC,aAAa,CAAC,EACzBC,OAAO,EACPC,cAAc,CAAC,CAAC,EAChBC,kBAAkB,CAAC,CAAC,EACpBC,YAAY,EACZC,kBAAkB,EAClBC,UAAU,EACVC,cAAc,EACdC,gBAAgB,KAAK,EACrBC,MAAM,EACNC,oBAAoB,EACpBC,iBAAiB,EACjBC,kBAAkB,EAClBC,eAAeC,qBAAqB,EACpCC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BACF;gBAEA,OAAON;YACT;YAEAvD,QAAQf,SAAS,CAAC,CAAC,UAAU,EAAE6G,uBAAuB,CAAC,CAAC,GAAGiB;QAC7D;IACF;IAEA,MAAMI,iBAAiBlI,UAAU4D,OAAO,CAAC,EAAEuE,IAAI,EAAE;QAC/C,MAAM7D,SAA2C,CAAC;QAElD5B,iBAAiBqE,OAAO,CAAC,CAACqB,KAAKhE;YAC7BE,MAAM,CAACF,IAAI,GAAG+D,KAAKpH,QAAQ0D,MAAM,CAAC2D,IAAI;QACxC;QAEA,IAAIvF,mBAAmB;YACrByB,OAAO+D,QAAQ,GAAGF,KAAK/F;QACzB;QAEA,IAAIc,kBAAkB;YACpBoB,OAAOgE,MAAM,GAAGH,KAAK9F;QACvB;QACA,IAAIY,oBAAoB;YACtBqB,OAAOiE,QAAQ,GAAGJ,KAAK7F;QACzB;QAEA,IAAIC,cAAcmE,IAAI,IAAIjE,oBAAoB;YAC5C6B,OAAOkE,KAAK,GAAGL,KAAK1F,oBAAoB;gBACtCsF,cAAc;YAChB;QACF;QAEA,OAAOzD;IACT;IAEAvD,QAAQf,SAAS,CAAC,CAAC,UAAU,EAAE6B,UAAU,CAAC,CAAC,GAAGqG;IAE9C,OAAO;QAAEjF;QAAoBC;QAAkBR;IAAiB;AAClE,EAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"traverseFields.d.ts","sourceRoot":"","sources":["../../src/schema/traverseFields.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,
|
1
|
+
{"version":3,"file":"traverseFields.d.ts","sourceRoot":"","sources":["../../src/schema/traverseFields.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACxE,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAsBtD,OAAO,KAAK,EAAE,cAAc,EAAU,eAAe,EAAE,MAAM,aAA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AAO,CAAA;IACrC,gBAAgB,EAAE,OAAO,GAAG,OAAO,CAAA;CACpC,CAAA;AAED,eAAO,MAAM,cAAc,sUAuBxB,IAAI,KAAG,MAqnBT,CAAA"}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/* eslint-disable no-param-reassign */ import { relations } from 'drizzle-orm';
|
2
|
-
import { PgNumericBuilder, PgUUIDBuilder, PgVarcharBuilder, boolean, index, integer, jsonb, numeric, pgEnum, text, timestamp, varchar } from 'drizzle-orm/pg-core';
|
2
|
+
import { PgNumericBuilder, PgUUIDBuilder, PgVarcharBuilder, boolean, foreignKey, index, integer, jsonb, numeric, pgEnum, text, timestamp, varchar } from 'drizzle-orm/pg-core';
|
3
3
|
import { InvalidConfiguration } from 'payload/errors';
|
4
4
|
import { fieldAffectsData, optionIsObject } from 'payload/types';
|
5
5
|
import toSnakeCase from 'to-snake-case';
|
@@ -154,13 +154,20 @@ export const traverseFields = ({ adapter, buildNumbers, buildRelationships, buil
|
|
154
154
|
});
|
155
155
|
const baseColumns = {
|
156
156
|
order: integer('order').notNull(),
|
157
|
-
parent: parentIDColumnMap[parentIDColType]('parent_id').
|
158
|
-
onDelete: 'cascade'
|
159
|
-
}).notNull(),
|
157
|
+
parent: parentIDColumnMap[parentIDColType]('parent_id').notNull(),
|
160
158
|
value: adapter.enums[enumName]('value')
|
161
159
|
};
|
162
160
|
const baseExtraConfig = {
|
163
161
|
orderIdx: (cols)=>index(`${selectTableName}_order_idx`).on(cols.order),
|
162
|
+
parentFk: (cols)=>foreignKey({
|
163
|
+
name: `${selectTableName}_parent_fk`,
|
164
|
+
columns: [
|
165
|
+
cols.parent
|
166
|
+
],
|
167
|
+
foreignColumns: [
|
168
|
+
adapter.tables[parentTableName].id
|
169
|
+
]
|
170
|
+
}),
|
164
171
|
parentIdx: (cols)=>index(`${selectTableName}_parent_idx`).on(cols.parent)
|
165
172
|
};
|
166
173
|
if (field.localized) {
|
@@ -217,12 +224,19 @@ export const traverseFields = ({ adapter, buildNumbers, buildRelationships, buil
|
|
217
224
|
});
|
218
225
|
const baseColumns = {
|
219
226
|
_order: integer('_order').notNull(),
|
220
|
-
_parentID: parentIDColumnMap[parentIDColType]('_parent_id').
|
221
|
-
onDelete: 'cascade'
|
222
|
-
}).notNull()
|
227
|
+
_parentID: parentIDColumnMap[parentIDColType]('_parent_id').notNull()
|
223
228
|
};
|
224
229
|
const baseExtraConfig = {
|
225
230
|
_orderIdx: (cols)=>index(`${arrayTableName}_order_idx`).on(cols._order),
|
231
|
+
_parentIDFk: (cols)=>foreignKey({
|
232
|
+
name: `${arrayTableName}_parent_id_fk`,
|
233
|
+
columns: [
|
234
|
+
cols['_parentID']
|
235
|
+
],
|
236
|
+
foreignColumns: [
|
237
|
+
adapter.tables[parentTableName].id
|
238
|
+
]
|
239
|
+
}).onDelete('cascade'),
|
226
240
|
_parentIDIdx: (cols)=>index(`${arrayTableName}_parent_id_idx`).on(cols._parentID)
|
227
241
|
};
|
228
242
|
if (field.localized && adapter.payload.config.localization) {
|
@@ -286,14 +300,21 @@ export const traverseFields = ({ adapter, buildNumbers, buildRelationships, buil
|
|
286
300
|
if (!adapter.tables[blockTableName]) {
|
287
301
|
const baseColumns = {
|
288
302
|
_order: integer('_order').notNull(),
|
289
|
-
_parentID: parentIDColumnMap[rootTableIDColType]('_parent_id').
|
290
|
-
onDelete: 'cascade'
|
291
|
-
}).notNull(),
|
303
|
+
_parentID: parentIDColumnMap[rootTableIDColType]('_parent_id').notNull(),
|
292
304
|
_path: text('_path').notNull()
|
293
305
|
};
|
294
306
|
const baseExtraConfig = {
|
295
307
|
_orderIdx: (cols)=>index(`${blockTableName}_order_idx`).on(cols._order),
|
296
308
|
_parentIDIdx: (cols)=>index(`${blockTableName}_parent_id_idx`).on(cols._parentID),
|
309
|
+
_parentIdFk: (cols)=>foreignKey({
|
310
|
+
name: `${blockTableName}_parent_id_fk`,
|
311
|
+
columns: [
|
312
|
+
cols._parentID
|
313
|
+
],
|
314
|
+
foreignColumns: [
|
315
|
+
adapter.tables[rootTableName].id
|
316
|
+
]
|
317
|
+
}).onDelete('cascade'),
|
297
318
|
_pathIdx: (cols)=>index(`${blockTableName}_path_idx`).on(cols._path)
|
298
319
|
};
|
299
320
|
if (field.localized && adapter.payload.config.localization) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/schema/traverseFields.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport type { Relation } from 'drizzle-orm'\nimport type { IndexBuilder, PgColumnBuilder, UniqueConstraintBuilder } from 'drizzle-orm/pg-core'\nimport type { Field, TabAsField } from 'payload/types'\n\nimport { relations } from 'drizzle-orm'\nimport {\n PgNumericBuilder,\n PgUUIDBuilder,\n PgVarcharBuilder,\n boolean,\n index,\n integer,\n jsonb,\n numeric,\n pgEnum,\n text,\n timestamp,\n varchar,\n} from 'drizzle-orm/pg-core'\nimport { InvalidConfiguration } from 'payload/errors'\nimport { fieldAffectsData, optionIsObject } from 'payload/types'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { GenericColumns, IDType, PostgresAdapter } from '../types.js'\n\nimport { hasLocalesTable } from '../utilities/hasLocalesTable.js'\nimport { buildTable } from './build.js'\nimport { createIndex } from './createIndex.js'\nimport { getTableName } from './getTableName.js'\nimport { idToUUID } from './idToUUID.js'\nimport { parentIDColumnMap } from './parentIDColumnMap.js'\nimport { validateExistingBlockIsIdentical } from './validateExistingBlockIsIdentical.js'\n\ntype Args = {\n adapter: PostgresAdapter\n buildNumbers: boolean\n buildRelationships: boolean\n buildTexts: boolean\n columnPrefix?: string\n columns: Record<string, PgColumnBuilder>\n disableNotNull: boolean\n disableUnique?: boolean\n fieldPrefix?: string\n fields: (Field | TabAsField)[]\n forceLocalized?: boolean\n indexes: Record<string, (cols: GenericColumns) => IndexBuilder>\n localesColumns: Record<string, PgColumnBuilder>\n localesIndexes: Record<string, (cols: GenericColumns) => IndexBuilder>\n newTableName: string\n parentTableName: string\n relationsToBuild: Map<string, string>\n relationships: Set<string>\n rootRelationsToBuild?: Map<string, string>\n rootTableIDColType: string\n rootTableName: string\n versions: boolean\n}\n\ntype Result = {\n hasLocalizedField: boolean\n hasLocalizedManyNumberField: boolean\n hasLocalizedManyTextField: boolean\n hasLocalizedRelationshipField: boolean\n hasManyNumberField: 'index' | boolean\n hasManyTextField: 'index' | boolean\n}\n\nexport const traverseFields = ({\n adapter,\n buildNumbers,\n buildRelationships,\n buildTexts,\n columnPrefix,\n columns,\n disableNotNull,\n disableUnique = false,\n fieldPrefix,\n fields,\n forceLocalized,\n indexes,\n localesColumns,\n localesIndexes,\n newTableName,\n parentTableName,\n relationsToBuild,\n relationships,\n rootRelationsToBuild,\n rootTableIDColType,\n rootTableName,\n versions,\n}: Args): Result => {\n const throwValidationError = true\n let hasLocalizedField = false\n let hasLocalizedRelationshipField = false\n let hasManyTextField: 'index' | boolean = false\n let hasLocalizedManyTextField = false\n let hasManyNumberField: 'index' | boolean = false\n let hasLocalizedManyNumberField = false\n\n let parentIDColType: IDType = 'integer'\n if (columns.id instanceof PgUUIDBuilder) parentIDColType = 'uuid'\n if (columns.id instanceof PgNumericBuilder) parentIDColType = 'numeric'\n if (columns.id instanceof PgVarcharBuilder) parentIDColType = 'varchar'\n\n fields.forEach((field) => {\n if ('name' in field && field.name === 'id') return\n let columnName: string\n let fieldName: string\n\n let targetTable = columns\n let targetIndexes = indexes\n\n if (fieldAffectsData(field)) {\n columnName = `${columnPrefix || ''}${field.name[0] === '_' ? '_' : ''}${toSnakeCase(\n field.name,\n )}`\n fieldName = `${fieldPrefix?.replace('.', '_') || ''}${field.name}`\n\n // If field is localized,\n // add the column to the locale table instead of main table\n if (adapter.payload.config.localization && (field.localized || forceLocalized)) {\n hasLocalizedField = true\n targetTable = localesColumns\n targetIndexes = localesIndexes\n }\n\n if (\n (field.unique || field.index) &&\n !['array', 'blocks', 'group', 'point', 'relationship', 'upload'].includes(field.type) &&\n !('hasMany' in field && field.hasMany === true)\n ) {\n const unique = disableUnique !== true && field.unique\n if (unique) {\n const constraintValue = `${fieldPrefix || ''}${field.name}`\n if (!adapter.fieldConstraints?.[rootTableName]) {\n adapter.fieldConstraints[rootTableName] = {}\n }\n adapter.fieldConstraints[rootTableName][`${columnName}_idx`] = constraintValue\n }\n targetIndexes[`${newTableName}_${field.name}Idx`] = createIndex({\n name: fieldName,\n columnName,\n tableName: newTableName,\n unique,\n })\n }\n }\n\n switch (field.type) {\n case 'text': {\n if (field.hasMany) {\n if (field.localized) {\n hasLocalizedManyTextField = true\n }\n\n if (field.index) {\n hasManyTextField = 'index'\n } else if (!hasManyTextField) {\n hasManyTextField = true\n }\n\n if (field.unique) {\n throw new InvalidConfiguration(\n 'Unique is not supported in Postgres for hasMany text fields.',\n )\n }\n } else {\n targetTable[fieldName] = varchar(columnName)\n }\n break\n }\n case 'email':\n case 'code':\n case 'textarea': {\n targetTable[fieldName] = varchar(columnName)\n break\n }\n\n case 'number': {\n if (field.hasMany) {\n if (field.localized) {\n hasLocalizedManyNumberField = true\n }\n\n if (field.index) {\n hasManyNumberField = 'index'\n } else if (!hasManyNumberField) {\n hasManyNumberField = true\n }\n\n if (field.unique) {\n throw new InvalidConfiguration(\n 'Unique is not supported in Postgres for hasMany number fields.',\n )\n }\n } else {\n targetTable[fieldName] = numeric(columnName)\n }\n break\n }\n\n case 'richText':\n case 'json': {\n targetTable[fieldName] = jsonb(columnName)\n break\n }\n\n case 'date': {\n targetTable[fieldName] = timestamp(columnName, {\n mode: 'string',\n precision: 3,\n withTimezone: true,\n })\n break\n }\n\n case 'point': {\n break\n }\n\n case 'radio':\n case 'select': {\n const enumName = getTableName({\n adapter,\n config: field,\n parentTableName: newTableName,\n prefix: `enum_${newTableName}_`,\n target: 'enumName',\n throwValidationError,\n })\n\n adapter.enums[enumName] = pgEnum(\n enumName,\n field.options.map((option) => {\n if (optionIsObject(option)) {\n return option.value\n }\n\n return option\n }) as [string, ...string[]],\n )\n\n if (field.type === 'select' && field.hasMany) {\n const selectTableName = getTableName({\n adapter,\n config: field,\n parentTableName: newTableName,\n prefix: `${newTableName}_`,\n throwValidationError,\n })\n const baseColumns: Record<string, PgColumnBuilder> = {\n order: integer('order').notNull(),\n parent: parentIDColumnMap[parentIDColType]('parent_id')\n .references(() => adapter.tables[parentTableName].id, { onDelete: 'cascade' })\n .notNull(),\n value: adapter.enums[enumName]('value'),\n }\n\n const baseExtraConfig: Record<\n string,\n (cols: GenericColumns) => IndexBuilder | UniqueConstraintBuilder\n > = {\n orderIdx: (cols) => index(`${selectTableName}_order_idx`).on(cols.order),\n parentIdx: (cols) => index(`${selectTableName}_parent_idx`).on(cols.parent),\n }\n\n if (field.localized) {\n baseColumns.locale = adapter.enums.enum__locales('locale').notNull()\n baseExtraConfig.localeIdx = (cols) =>\n index(`${selectTableName}_locale_idx`).on(cols.locale)\n }\n\n if (field.index) {\n baseExtraConfig.value = (cols) => index(`${selectTableName}_value_idx`).on(cols.value)\n }\n\n buildTable({\n adapter,\n baseColumns,\n baseExtraConfig,\n disableNotNull,\n disableUnique,\n fields: [],\n tableName: selectTableName,\n versions,\n })\n\n relationsToBuild.set(fieldName, selectTableName)\n\n const selectTableRelations = relations(adapter.tables[selectTableName], ({ one }) => {\n const result: Record<string, Relation<string>> = {\n parent: one(adapter.tables[parentTableName], {\n fields: [adapter.tables[selectTableName].parent],\n references: [adapter.tables[parentTableName].id],\n }),\n }\n\n return result\n })\n\n adapter.relations[`relation_${selectTableName}`] = selectTableRelations\n } else {\n targetTable[fieldName] = adapter.enums[enumName](fieldName)\n }\n break\n }\n\n case 'checkbox': {\n targetTable[fieldName] = boolean(columnName)\n break\n }\n\n case 'array': {\n const disableNotNullFromHere = Boolean(field.admin?.condition) || disableNotNull\n\n const arrayTableName = getTableName({\n adapter,\n config: field,\n parentTableName: newTableName,\n prefix: `${newTableName}_`,\n throwValidationError,\n })\n const baseColumns: Record<string, PgColumnBuilder> = {\n _order: integer('_order').notNull(),\n _parentID: parentIDColumnMap[parentIDColType]('_parent_id')\n .references(() => adapter.tables[parentTableName].id, { onDelete: 'cascade' })\n .notNull(),\n }\n\n const baseExtraConfig: Record<\n string,\n (cols: GenericColumns) => IndexBuilder | UniqueConstraintBuilder\n > = {\n _orderIdx: (cols) => index(`${arrayTableName}_order_idx`).on(cols._order),\n _parentIDIdx: (cols) => index(`${arrayTableName}_parent_id_idx`).on(cols._parentID),\n }\n\n if (field.localized && adapter.payload.config.localization) {\n baseColumns._locale = adapter.enums.enum__locales('_locale').notNull()\n baseExtraConfig._localeIdx = (cols) =>\n index(`${arrayTableName}_locale_idx`).on(cols._locale)\n }\n\n const {\n hasManyNumberField: subHasManyNumberField,\n hasManyTextField: subHasManyTextField,\n relationsToBuild: subRelationsToBuild,\n } = buildTable({\n adapter,\n baseColumns,\n baseExtraConfig,\n disableNotNull: disableNotNullFromHere,\n disableUnique,\n fields: disableUnique ? idToUUID(field.fields) : field.fields,\n rootRelationsToBuild,\n rootRelationships: relationships,\n rootTableIDColType,\n rootTableName,\n tableName: arrayTableName,\n versions,\n })\n\n if (subHasManyTextField) {\n if (!hasManyTextField || subHasManyTextField === 'index')\n hasManyTextField = subHasManyTextField\n }\n if (subHasManyNumberField) {\n if (!hasManyNumberField || subHasManyNumberField === 'index')\n hasManyNumberField = subHasManyNumberField\n }\n\n relationsToBuild.set(fieldName, arrayTableName)\n\n const arrayTableRelations = relations(adapter.tables[arrayTableName], ({ many, one }) => {\n const result: Record<string, Relation<string>> = {\n _parentID: one(adapter.tables[parentTableName], {\n fields: [adapter.tables[arrayTableName]._parentID],\n references: [adapter.tables[parentTableName].id],\n }),\n }\n\n if (hasLocalesTable(field.fields)) {\n result._locales = many(adapter.tables[`${arrayTableName}${adapter.localesSuffix}`])\n }\n\n subRelationsToBuild.forEach((val, key) => {\n result[key] = many(adapter.tables[val])\n })\n\n return result\n })\n\n adapter.relations[`relations_${arrayTableName}`] = arrayTableRelations\n\n break\n }\n\n case 'blocks': {\n const disableNotNullFromHere = Boolean(field.admin?.condition) || disableNotNull\n\n field.blocks.forEach((block) => {\n const blockTableName = getTableName({\n adapter,\n config: block,\n parentTableName: rootTableName,\n prefix: `${rootTableName}_blocks_`,\n throwValidationError,\n })\n if (!adapter.tables[blockTableName]) {\n const baseColumns: Record<string, PgColumnBuilder> = {\n _order: integer('_order').notNull(),\n _parentID: parentIDColumnMap[rootTableIDColType]('_parent_id')\n .references(() => adapter.tables[rootTableName].id, { onDelete: 'cascade' })\n .notNull(),\n _path: text('_path').notNull(),\n }\n\n const baseExtraConfig: Record<\n string,\n (cols: GenericColumns) => IndexBuilder | UniqueConstraintBuilder\n > = {\n _orderIdx: (cols) => index(`${blockTableName}_order_idx`).on(cols._order),\n _parentIDIdx: (cols) => index(`${blockTableName}_parent_id_idx`).on(cols._parentID),\n _pathIdx: (cols) => index(`${blockTableName}_path_idx`).on(cols._path),\n }\n\n if (field.localized && adapter.payload.config.localization) {\n baseColumns._locale = adapter.enums.enum__locales('_locale').notNull()\n baseExtraConfig._localeIdx = (cols) =>\n index(`${blockTableName}_locale_idx`).on(cols._locale)\n }\n\n const {\n hasManyNumberField: subHasManyNumberField,\n hasManyTextField: subHasManyTextField,\n relationsToBuild: subRelationsToBuild,\n } = buildTable({\n adapter,\n baseColumns,\n baseExtraConfig,\n disableNotNull: disableNotNullFromHere,\n disableUnique,\n fields: disableUnique ? idToUUID(block.fields) : block.fields,\n rootRelationsToBuild,\n rootRelationships: relationships,\n rootTableIDColType,\n rootTableName,\n tableName: blockTableName,\n versions,\n })\n\n if (subHasManyTextField) {\n if (!hasManyTextField || subHasManyTextField === 'index')\n hasManyTextField = subHasManyTextField\n }\n\n if (subHasManyNumberField) {\n if (!hasManyNumberField || subHasManyNumberField === 'index')\n hasManyNumberField = subHasManyNumberField\n }\n\n const blockTableRelations = relations(\n adapter.tables[blockTableName],\n ({ many, one }) => {\n const result: Record<string, Relation<string>> = {\n _parentID: one(adapter.tables[rootTableName], {\n fields: [adapter.tables[blockTableName]._parentID],\n references: [adapter.tables[rootTableName].id],\n }),\n }\n\n if (hasLocalesTable(block.fields)) {\n result._locales = many(\n adapter.tables[`${blockTableName}${adapter.localesSuffix}`],\n )\n }\n\n subRelationsToBuild.forEach((val, key) => {\n result[key] = many(adapter.tables[val])\n })\n\n return result\n },\n )\n\n adapter.relations[`relations_${blockTableName}`] = blockTableRelations\n } else if (process.env.NODE_ENV !== 'production' && !versions) {\n validateExistingBlockIsIdentical({\n block,\n localized: field.localized,\n rootTableName,\n table: adapter.tables[blockTableName],\n tableLocales: adapter.tables[`${blockTableName}${adapter.localesSuffix}`],\n })\n }\n adapter.blockTableNames[`${rootTableName}.${toSnakeCase(block.slug)}`] = blockTableName\n rootRelationsToBuild.set(`_blocks_${block.slug}`, blockTableName)\n })\n\n break\n }\n\n case 'tab':\n case 'group': {\n if (!('name' in field)) {\n const {\n hasLocalizedField: groupHasLocalizedField,\n hasLocalizedManyNumberField: groupHasLocalizedManyNumberField,\n hasLocalizedManyTextField: groupHasLocalizedManyTextField,\n hasLocalizedRelationshipField: groupHasLocalizedRelationshipField,\n hasManyNumberField: groupHasManyNumberField,\n hasManyTextField: groupHasManyTextField,\n } = traverseFields({\n adapter,\n buildNumbers,\n buildRelationships,\n buildTexts,\n columnPrefix,\n columns,\n disableNotNull,\n disableUnique,\n fieldPrefix,\n fields: field.fields,\n forceLocalized,\n indexes,\n localesColumns,\n localesIndexes,\n newTableName,\n parentTableName,\n relationsToBuild,\n relationships,\n rootRelationsToBuild,\n rootTableIDColType,\n rootTableName,\n versions,\n })\n\n if (groupHasLocalizedField) hasLocalizedField = true\n if (groupHasLocalizedRelationshipField) hasLocalizedRelationshipField = true\n if (groupHasManyTextField) hasManyTextField = true\n if (groupHasLocalizedManyTextField) hasLocalizedManyTextField = true\n if (groupHasManyNumberField) hasManyNumberField = true\n if (groupHasLocalizedManyNumberField) hasLocalizedManyNumberField = true\n break\n }\n\n const disableNotNullFromHere = Boolean(field.admin?.condition) || disableNotNull\n\n const {\n hasLocalizedField: groupHasLocalizedField,\n hasLocalizedManyNumberField: groupHasLocalizedManyNumberField,\n hasLocalizedManyTextField: groupHasLocalizedManyTextField,\n hasLocalizedRelationshipField: groupHasLocalizedRelationshipField,\n hasManyNumberField: groupHasManyNumberField,\n hasManyTextField: groupHasManyTextField,\n } = traverseFields({\n adapter,\n buildNumbers,\n buildRelationships,\n buildTexts,\n columnPrefix: `${columnName}_`,\n columns,\n disableNotNull: disableNotNullFromHere,\n disableUnique,\n fieldPrefix: `${fieldName}.`,\n fields: field.fields,\n forceLocalized: field.localized,\n indexes,\n localesColumns,\n localesIndexes,\n newTableName: `${parentTableName}_${columnName}`,\n parentTableName,\n relationsToBuild,\n relationships,\n rootRelationsToBuild,\n rootTableIDColType,\n rootTableName,\n versions,\n })\n\n if (groupHasLocalizedField) hasLocalizedField = true\n if (groupHasLocalizedRelationshipField) hasLocalizedRelationshipField = true\n if (groupHasManyTextField) hasManyTextField = true\n if (groupHasLocalizedManyTextField) hasLocalizedManyTextField = true\n if (groupHasManyNumberField) hasManyNumberField = true\n if (groupHasLocalizedManyNumberField) hasLocalizedManyNumberField = true\n break\n }\n\n case 'tabs': {\n const disableNotNullFromHere = Boolean(field.admin?.condition) || disableNotNull\n\n const {\n hasLocalizedField: tabHasLocalizedField,\n hasLocalizedManyNumberField: tabHasLocalizedManyNumberField,\n hasLocalizedManyTextField: tabHasLocalizedManyTextField,\n hasLocalizedRelationshipField: tabHasLocalizedRelationshipField,\n hasManyNumberField: tabHasManyNumberField,\n hasManyTextField: tabHasManyTextField,\n } = traverseFields({\n adapter,\n buildNumbers,\n buildRelationships,\n buildTexts,\n columnPrefix,\n columns,\n disableNotNull: disableNotNullFromHere,\n disableUnique,\n fieldPrefix,\n fields: field.tabs.map((tab) => ({ ...tab, type: 'tab' })),\n forceLocalized,\n indexes,\n localesColumns,\n localesIndexes,\n newTableName,\n parentTableName,\n relationsToBuild,\n relationships,\n rootRelationsToBuild,\n rootTableIDColType,\n rootTableName,\n versions,\n })\n\n if (tabHasLocalizedField) hasLocalizedField = true\n if (tabHasLocalizedRelationshipField) hasLocalizedRelationshipField = true\n if (tabHasManyTextField) hasManyTextField = true\n if (tabHasLocalizedManyTextField) hasLocalizedManyTextField = true\n if (tabHasManyNumberField) hasManyNumberField = true\n if (tabHasLocalizedManyNumberField) hasLocalizedManyNumberField = true\n break\n }\n\n case 'row':\n case 'collapsible': {\n const disableNotNullFromHere = Boolean(field.admin?.condition) || disableNotNull\n const {\n hasLocalizedField: rowHasLocalizedField,\n hasLocalizedManyNumberField: rowHasLocalizedManyNumberField,\n hasLocalizedManyTextField: rowHasLocalizedManyTextField,\n hasLocalizedRelationshipField: rowHasLocalizedRelationshipField,\n hasManyNumberField: rowHasManyNumberField,\n hasManyTextField: rowHasManyTextField,\n } = traverseFields({\n adapter,\n buildNumbers,\n buildRelationships,\n buildTexts,\n columnPrefix,\n columns,\n disableNotNull: disableNotNullFromHere,\n disableUnique,\n fieldPrefix,\n fields: field.fields,\n forceLocalized,\n indexes,\n localesColumns,\n localesIndexes,\n newTableName,\n parentTableName,\n relationsToBuild,\n relationships,\n rootRelationsToBuild,\n rootTableIDColType,\n rootTableName,\n versions,\n })\n\n if (rowHasLocalizedField) hasLocalizedField = true\n if (rowHasLocalizedRelationshipField) hasLocalizedRelationshipField = true\n if (rowHasManyTextField) hasManyTextField = true\n if (rowHasLocalizedManyTextField) hasLocalizedManyTextField = true\n if (rowHasManyNumberField) hasManyNumberField = true\n if (rowHasLocalizedManyNumberField) hasLocalizedManyNumberField = true\n break\n }\n\n case 'relationship':\n case 'upload':\n if (Array.isArray(field.relationTo)) {\n field.relationTo.forEach((relation) => relationships.add(relation))\n } else {\n relationships.add(field.relationTo)\n }\n\n if (field.localized && adapter.payload.config.localization) {\n hasLocalizedRelationshipField = true\n }\n break\n\n default:\n break\n }\n\n const condition = field.admin && field.admin.condition\n\n if (\n !disableNotNull &&\n targetTable[fieldName] &&\n 'required' in field &&\n field.required &&\n !condition\n ) {\n targetTable[fieldName].notNull()\n }\n })\n\n return {\n hasLocalizedField,\n hasLocalizedManyNumberField,\n hasLocalizedManyTextField,\n hasLocalizedRelationshipField,\n hasManyNumberField,\n hasManyTextField,\n }\n}\n"],"names":["relations","PgNumericBuilder","PgUUIDBuilder","PgVarcharBuilder","boolean","index","integer","jsonb","numeric","pgEnum","text","timestamp","varchar","InvalidConfiguration","fieldAffectsData","optionIsObject","toSnakeCase","hasLocalesTable","buildTable","createIndex","getTableName","idToUUID","parentIDColumnMap","validateExistingBlockIsIdentical","traverseFields","adapter","buildNumbers","buildRelationships","buildTexts","columnPrefix","columns","disableNotNull","disableUnique","fieldPrefix","fields","forceLocalized","indexes","localesColumns","localesIndexes","newTableName","parentTableName","relationsToBuild","relationships","rootRelationsToBuild","rootTableIDColType","rootTableName","versions","throwValidationError","hasLocalizedField","hasLocalizedRelationshipField","hasManyTextField","hasLocalizedManyTextField","hasManyNumberField","hasLocalizedManyNumberField","parentIDColType","id","forEach","field","name","columnName","fieldName","targetTable","targetIndexes","replace","payload","config","localization","localized","unique","includes","type","hasMany","constraintValue","fieldConstraints","tableName","mode","precision","withTimezone","enumName","prefix","target","enums","options","map","option","value","selectTableName","baseColumns","order","notNull","parent","references","tables","onDelete","baseExtraConfig","orderIdx","cols","on","parentIdx","locale","enum__locales","localeIdx","set","selectTableRelations","one","result","disableNotNullFromHere","Boolean","admin","condition","arrayTableName","_order","_parentID","_orderIdx","_parentIDIdx","_locale","_localeIdx","subHasManyNumberField","subHasManyTextField","subRelationsToBuild","rootRelationships","arrayTableRelations","many","_locales","localesSuffix","val","key","blocks","block","blockTableName","_path","_pathIdx","blockTableRelations","process","env","NODE_ENV","table","tableLocales","blockTableNames","slug","groupHasLocalizedField","groupHasLocalizedManyNumberField","groupHasLocalizedManyTextField","groupHasLocalizedRelationshipField","groupHasManyNumberField","groupHasManyTextField","tabHasLocalizedField","tabHasLocalizedManyNumberField","tabHasLocalizedManyTextField","tabHasLocalizedRelationshipField","tabHasManyNumberField","tabHasManyTextField","tabs","tab","rowHasLocalizedField","rowHasLocalizedManyNumberField","rowHasLocalizedManyTextField","rowHasLocalizedRelationshipField","rowHasManyNumberField","rowHasManyTextField","Array","isArray","relationTo","relation","add","required"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,oCAAoC,GAKpC,SAASA,SAAS,QAAQ,cAAa;AACvC,SACEC,gBAAgB,EAChBC,aAAa,EACbC,gBAAgB,EAChBC,OAAO,EACPC,KAAK,EACLC,OAAO,EACPC,KAAK,EACLC,OAAO,EACPC,MAAM,EACNC,IAAI,EACJC,SAAS,EACTC,OAAO,QACF,sBAAqB;AAC5B,SAASC,oBAAoB,QAAQ,iBAAgB;AACrD,SAASC,gBAAgB,EAAEC,cAAc,QAAQ,gBAAe;AAChE,OAAOC,iBAAiB,gBAAe;AAIvC,SAASC,eAAe,QAAQ,kCAAiC;AACjE,SAASC,UAAU,QAAQ,aAAY;AACvC,SAASC,WAAW,QAAQ,mBAAkB;AAC9C,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SAASC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C;wBACAC;wBACAC;wBACAC;wBACAC;wBACAC;wBACAC;wBACAC;wBACAC;wBACAC;wBACAC;oBACF;oBAEA,IAAI4G,sBAAsB1G,oBAAoB;oBAC9C,IAAI6G,kCAAkC5G,gCAAgC;oBACtE,IAAI8G,qBAAqB7G,mBAAmB;oBAC5C,IAAI0G,8BAA8BzG,4BAA4B;oBAC9D,IAAI2G,uBAAuB1G,qBAAqB;oBAChD,IAAIuG,gCAAgCtG,8BAA8B;oBAClE;gBACF;YAEA,KAAK;YACL,KAAK;gBACH,IAAI2G,MAAMC,OAAO,CAACxG,MAAMyG,UAAU,GAAG;oBACnCzG,MAAMyG,UAAU,CAAC1G,OAAO,CAAC,CAAC2G,WAAazH,cAAc0H,GAAG,CAACD;gBAC3D,OAAO;oBACLzH,cAAc0H,GAAG,CAAC3G,MAAMyG,UAAU;gBACpC;gBAEA,IAAIzG,MAAMU,SAAS,IAAI1C,QAAQuC,OAAO,CAACC,MAAM,CAACC,YAAY,EAAE;oBAC1DjB,gCAAgC;gBAClC;gBACA;YAEF;gBACE;QACJ;QAEA,MAAM4D,YAAYpD,MAAMmD,KAAK,IAAInD,MAAMmD,KAAK,CAACC,SAAS;QAEtD,IACE,CAAC9E,kBACD8B,WAAW,CAACD,UAAU,IACtB,cAAcH,SACdA,MAAM4G,QAAQ,IACd,CAACxD,WACD;YACAhD,WAAW,CAACD,UAAU,CAAC6B,OAAO;QAChC;IACF;IAEA,OAAO;QACLzC;QACAK;QACAF;QACAF;QACAG;QACAF;IACF;AACF,EAAC"}
|
1
|
+
{"version":3,"sources":["../../src/schema/traverseFields.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport type { Relation } from 'drizzle-orm'\nimport type { IndexBuilder, PgColumnBuilder } from 'drizzle-orm/pg-core'\nimport type { Field, TabAsField } from 'payload/types'\n\nimport { relations } from 'drizzle-orm'\nimport {\n PgNumericBuilder,\n PgUUIDBuilder,\n PgVarcharBuilder,\n boolean,\n foreignKey,\n index,\n integer,\n jsonb,\n numeric,\n pgEnum,\n text,\n timestamp,\n varchar,\n} from 'drizzle-orm/pg-core'\nimport { InvalidConfiguration } from 'payload/errors'\nimport { fieldAffectsData, optionIsObject } from 'payload/types'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { GenericColumns, IDType, PostgresAdapter } from '../types.js'\nimport type { BaseExtraConfig } from './build.js'\n\nimport { hasLocalesTable } from '../utilities/hasLocalesTable.js'\nimport { buildTable } from './build.js'\nimport { createIndex } from './createIndex.js'\nimport { getTableName } from './getTableName.js'\nimport { idToUUID } from './idToUUID.js'\nimport { parentIDColumnMap } from './parentIDColumnMap.js'\nimport { validateExistingBlockIsIdentical } from './validateExistingBlockIsIdentical.js'\n\ntype Args = {\n adapter: PostgresAdapter\n buildNumbers: boolean\n buildRelationships: boolean\n buildTexts: boolean\n columnPrefix?: string\n columns: Record<string, PgColumnBuilder>\n disableNotNull: boolean\n disableUnique?: boolean\n fieldPrefix?: string\n fields: (Field | TabAsField)[]\n forceLocalized?: boolean\n indexes: Record<string, (cols: GenericColumns) => IndexBuilder>\n localesColumns: Record<string, PgColumnBuilder>\n localesIndexes: Record<string, (cols: GenericColumns) => IndexBuilder>\n newTableName: string\n parentTableName: string\n relationsToBuild: Map<string, string>\n relationships: Set<string>\n rootRelationsToBuild?: Map<string, string>\n rootTableIDColType: string\n rootTableName: string\n versions: boolean\n}\n\ntype Result = {\n hasLocalizedField: boolean\n hasLocalizedManyNumberField: boolean\n hasLocalizedManyTextField: boolean\n hasLocalizedRelationshipField: boolean\n hasManyNumberField: 'index' | boolean\n hasManyTextField: 'index' | boolean\n}\n\nexport const traverseFields = ({\n adapter,\n buildNumbers,\n buildRelationships,\n buildTexts,\n columnPrefix,\n columns,\n disableNotNull,\n disableUnique = false,\n fieldPrefix,\n fields,\n forceLocalized,\n indexes,\n localesColumns,\n localesIndexes,\n newTableName,\n parentTableName,\n relationsToBuild,\n relationships,\n rootRelationsToBuild,\n rootTableIDColType,\n rootTableName,\n versions,\n}: Args): Result => {\n const throwValidationError = true\n let hasLocalizedField = false\n let hasLocalizedRelationshipField = false\n let hasManyTextField: 'index' | boolean = false\n let hasLocalizedManyTextField = false\n let hasManyNumberField: 'index' | boolean = false\n let hasLocalizedManyNumberField = false\n\n let parentIDColType: IDType = 'integer'\n if (columns.id instanceof PgUUIDBuilder) parentIDColType = 'uuid'\n if (columns.id instanceof PgNumericBuilder) parentIDColType = 'numeric'\n if (columns.id instanceof PgVarcharBuilder) parentIDColType = 'varchar'\n\n fields.forEach((field) => {\n if ('name' in field && field.name === 'id') return\n let columnName: string\n let fieldName: string\n\n let targetTable = columns\n let targetIndexes = indexes\n\n if (fieldAffectsData(field)) {\n columnName = `${columnPrefix || ''}${field.name[0] === '_' ? '_' : ''}${toSnakeCase(\n field.name,\n )}`\n fieldName = `${fieldPrefix?.replace('.', '_') || ''}${field.name}`\n\n // If field is localized,\n // add the column to the locale table instead of main table\n if (adapter.payload.config.localization && (field.localized || forceLocalized)) {\n hasLocalizedField = true\n targetTable = localesColumns\n targetIndexes = localesIndexes\n }\n\n if (\n (field.unique || field.index) &&\n !['array', 'blocks', 'group', 'point', 'relationship', 'upload'].includes(field.type) &&\n !('hasMany' in field && field.hasMany === true)\n ) {\n const unique = disableUnique !== true && field.unique\n if (unique) {\n const constraintValue = `${fieldPrefix || ''}${field.name}`\n if (!adapter.fieldConstraints?.[rootTableName]) {\n adapter.fieldConstraints[rootTableName] = {}\n }\n adapter.fieldConstraints[rootTableName][`${columnName}_idx`] = constraintValue\n }\n targetIndexes[`${newTableName}_${field.name}Idx`] = createIndex({\n name: fieldName,\n columnName,\n tableName: newTableName,\n unique,\n })\n }\n }\n\n switch (field.type) {\n case 'text': {\n if (field.hasMany) {\n if (field.localized) {\n hasLocalizedManyTextField = true\n }\n\n if (field.index) {\n hasManyTextField = 'index'\n } else if (!hasManyTextField) {\n hasManyTextField = true\n }\n\n if (field.unique) {\n throw new InvalidConfiguration(\n 'Unique is not supported in Postgres for hasMany text fields.',\n )\n }\n } else {\n targetTable[fieldName] = varchar(columnName)\n }\n break\n }\n case 'email':\n case 'code':\n case 'textarea': {\n targetTable[fieldName] = varchar(columnName)\n break\n }\n\n case 'number': {\n if (field.hasMany) {\n if (field.localized) {\n hasLocalizedManyNumberField = true\n }\n\n if (field.index) {\n hasManyNumberField = 'index'\n } else if (!hasManyNumberField) {\n hasManyNumberField = true\n }\n\n if (field.unique) {\n throw new InvalidConfiguration(\n 'Unique is not supported in Postgres for hasMany number fields.',\n )\n }\n } else {\n targetTable[fieldName] = numeric(columnName)\n }\n break\n }\n\n case 'richText':\n case 'json': {\n targetTable[fieldName] = jsonb(columnName)\n break\n }\n\n case 'date': {\n targetTable[fieldName] = timestamp(columnName, {\n mode: 'string',\n precision: 3,\n withTimezone: true,\n })\n break\n }\n\n case 'point': {\n break\n }\n\n case 'radio':\n case 'select': {\n const enumName = getTableName({\n adapter,\n config: field,\n parentTableName: newTableName,\n prefix: `enum_${newTableName}_`,\n target: 'enumName',\n throwValidationError,\n })\n\n adapter.enums[enumName] = pgEnum(\n enumName,\n field.options.map((option) => {\n if (optionIsObject(option)) {\n return option.value\n }\n\n return option\n }) as [string, ...string[]],\n )\n\n if (field.type === 'select' && field.hasMany) {\n const selectTableName = getTableName({\n adapter,\n config: field,\n parentTableName: newTableName,\n prefix: `${newTableName}_`,\n throwValidationError,\n })\n const baseColumns: Record<string, PgColumnBuilder> = {\n order: integer('order').notNull(),\n parent: parentIDColumnMap[parentIDColType]('parent_id').notNull(),\n value: adapter.enums[enumName]('value'),\n }\n\n const baseExtraConfig: BaseExtraConfig = {\n orderIdx: (cols) => index(`${selectTableName}_order_idx`).on(cols.order),\n parentFk: (cols) =>\n foreignKey({\n name: `${selectTableName}_parent_fk`,\n columns: [cols.parent],\n foreignColumns: [adapter.tables[parentTableName].id],\n }),\n parentIdx: (cols) => index(`${selectTableName}_parent_idx`).on(cols.parent),\n }\n\n if (field.localized) {\n baseColumns.locale = adapter.enums.enum__locales('locale').notNull()\n baseExtraConfig.localeIdx = (cols) =>\n index(`${selectTableName}_locale_idx`).on(cols.locale)\n }\n\n if (field.index) {\n baseExtraConfig.value = (cols) => index(`${selectTableName}_value_idx`).on(cols.value)\n }\n\n buildTable({\n adapter,\n baseColumns,\n baseExtraConfig,\n disableNotNull,\n disableUnique,\n fields: [],\n tableName: selectTableName,\n versions,\n })\n\n relationsToBuild.set(fieldName, selectTableName)\n\n const selectTableRelations = relations(adapter.tables[selectTableName], ({ one }) => {\n const result: Record<string, Relation<string>> = {\n parent: one(adapter.tables[parentTableName], {\n fields: [adapter.tables[selectTableName].parent],\n references: [adapter.tables[parentTableName].id],\n }),\n }\n\n return result\n })\n\n adapter.relations[`relation_${selectTableName}`] = selectTableRelations\n } else {\n targetTable[fieldName] = adapter.enums[enumName](fieldName)\n }\n break\n }\n\n case 'checkbox': {\n targetTable[fieldName] = boolean(columnName)\n break\n }\n\n case 'array': {\n const disableNotNullFromHere = Boolean(field.admin?.condition) || disableNotNull\n\n const arrayTableName = getTableName({\n adapter,\n config: field,\n parentTableName: newTableName,\n prefix: `${newTableName}_`,\n throwValidationError,\n })\n\n const baseColumns: Record<string, PgColumnBuilder> = {\n _order: integer('_order').notNull(),\n _parentID: parentIDColumnMap[parentIDColType]('_parent_id').notNull(),\n }\n\n const baseExtraConfig: BaseExtraConfig = {\n _orderIdx: (cols) => index(`${arrayTableName}_order_idx`).on(cols._order),\n _parentIDFk: (cols) =>\n foreignKey({\n name: `${arrayTableName}_parent_id_fk`,\n columns: [cols['_parentID']],\n foreignColumns: [adapter.tables[parentTableName].id],\n }).onDelete('cascade'),\n _parentIDIdx: (cols) => index(`${arrayTableName}_parent_id_idx`).on(cols._parentID),\n }\n\n if (field.localized && adapter.payload.config.localization) {\n baseColumns._locale = adapter.enums.enum__locales('_locale').notNull()\n baseExtraConfig._localeIdx = (cols) =>\n index(`${arrayTableName}_locale_idx`).on(cols._locale)\n }\n\n const {\n hasManyNumberField: subHasManyNumberField,\n hasManyTextField: subHasManyTextField,\n relationsToBuild: subRelationsToBuild,\n } = buildTable({\n adapter,\n baseColumns,\n baseExtraConfig,\n disableNotNull: disableNotNullFromHere,\n disableUnique,\n fields: disableUnique ? idToUUID(field.fields) : field.fields,\n rootRelationsToBuild,\n rootRelationships: relationships,\n rootTableIDColType,\n rootTableName,\n tableName: arrayTableName,\n versions,\n })\n\n if (subHasManyTextField) {\n if (!hasManyTextField || subHasManyTextField === 'index')\n hasManyTextField = subHasManyTextField\n }\n if (subHasManyNumberField) {\n if (!hasManyNumberField || subHasManyNumberField === 'index')\n hasManyNumberField = subHasManyNumberField\n }\n\n relationsToBuild.set(fieldName, arrayTableName)\n\n const arrayTableRelations = relations(adapter.tables[arrayTableName], ({ many, one }) => {\n const result: Record<string, Relation<string>> = {\n _parentID: one(adapter.tables[parentTableName], {\n fields: [adapter.tables[arrayTableName]._parentID],\n references: [adapter.tables[parentTableName].id],\n }),\n }\n\n if (hasLocalesTable(field.fields)) {\n result._locales = many(adapter.tables[`${arrayTableName}${adapter.localesSuffix}`])\n }\n\n subRelationsToBuild.forEach((val, key) => {\n result[key] = many(adapter.tables[val])\n })\n\n return result\n })\n\n adapter.relations[`relations_${arrayTableName}`] = arrayTableRelations\n\n break\n }\n\n case 'blocks': {\n const disableNotNullFromHere = Boolean(field.admin?.condition) || disableNotNull\n\n field.blocks.forEach((block) => {\n const blockTableName = getTableName({\n adapter,\n config: block,\n parentTableName: rootTableName,\n prefix: `${rootTableName}_blocks_`,\n throwValidationError,\n })\n if (!adapter.tables[blockTableName]) {\n const baseColumns: Record<string, PgColumnBuilder> = {\n _order: integer('_order').notNull(),\n _parentID: parentIDColumnMap[rootTableIDColType]('_parent_id').notNull(),\n _path: text('_path').notNull(),\n }\n\n const baseExtraConfig: BaseExtraConfig = {\n _orderIdx: (cols) => index(`${blockTableName}_order_idx`).on(cols._order),\n _parentIDIdx: (cols) => index(`${blockTableName}_parent_id_idx`).on(cols._parentID),\n _parentIdFk: (cols) =>\n foreignKey({\n name: `${blockTableName}_parent_id_fk`,\n columns: [cols._parentID],\n foreignColumns: [adapter.tables[rootTableName].id],\n }).onDelete('cascade'),\n _pathIdx: (cols) => index(`${blockTableName}_path_idx`).on(cols._path),\n }\n\n if (field.localized && adapter.payload.config.localization) {\n baseColumns._locale = adapter.enums.enum__locales('_locale').notNull()\n baseExtraConfig._localeIdx = (cols) =>\n index(`${blockTableName}_locale_idx`).on(cols._locale)\n }\n\n const {\n hasManyNumberField: subHasManyNumberField,\n hasManyTextField: subHasManyTextField,\n relationsToBuild: subRelationsToBuild,\n } = buildTable({\n adapter,\n baseColumns,\n baseExtraConfig,\n disableNotNull: disableNotNullFromHere,\n disableUnique,\n fields: disableUnique ? idToUUID(block.fields) : block.fields,\n rootRelationsToBuild,\n rootRelationships: relationships,\n rootTableIDColType,\n rootTableName,\n tableName: blockTableName,\n versions,\n })\n\n if (subHasManyTextField) {\n if (!hasManyTextField || subHasManyTextField === 'index')\n hasManyTextField = subHasManyTextField\n }\n\n if (subHasManyNumberField) {\n if (!hasManyNumberField || subHasManyNumberField === 'index')\n hasManyNumberField = subHasManyNumberField\n }\n\n const blockTableRelations = relations(\n adapter.tables[blockTableName],\n ({ many, one }) => {\n const result: Record<string, Relation<string>> = {\n _parentID: one(adapter.tables[rootTableName], {\n fields: [adapter.tables[blockTableName]._parentID],\n references: [adapter.tables[rootTableName].id],\n }),\n }\n\n if (hasLocalesTable(block.fields)) {\n result._locales = many(\n adapter.tables[`${blockTableName}${adapter.localesSuffix}`],\n )\n }\n\n subRelationsToBuild.forEach((val, key) => {\n result[key] = many(adapter.tables[val])\n })\n\n return result\n },\n )\n\n adapter.relations[`relations_${blockTableName}`] = blockTableRelations\n } else if (process.env.NODE_ENV !== 'production' && !versions) {\n validateExistingBlockIsIdentical({\n block,\n localized: field.localized,\n rootTableName,\n table: adapter.tables[blockTableName],\n tableLocales: adapter.tables[`${blockTableName}${adapter.localesSuffix}`],\n })\n }\n adapter.blockTableNames[`${rootTableName}.${toSnakeCase(block.slug)}`] = blockTableName\n rootRelationsToBuild.set(`_blocks_${block.slug}`, blockTableName)\n })\n\n break\n }\n\n case 'tab':\n case 'group': {\n if (!('name' in field)) {\n const {\n hasLocalizedField: groupHasLocalizedField,\n hasLocalizedManyNumberField: groupHasLocalizedManyNumberField,\n hasLocalizedManyTextField: groupHasLocalizedManyTextField,\n hasLocalizedRelationshipField: groupHasLocalizedRelationshipField,\n hasManyNumberField: groupHasManyNumberField,\n hasManyTextField: groupHasManyTextField,\n } = traverseFields({\n adapter,\n buildNumbers,\n buildRelationships,\n buildTexts,\n columnPrefix,\n columns,\n disableNotNull,\n disableUnique,\n fieldPrefix,\n fields: field.fields,\n forceLocalized,\n indexes,\n localesColumns,\n localesIndexes,\n newTableName,\n parentTableName,\n relationsToBuild,\n relationships,\n rootRelationsToBuild,\n rootTableIDColType,\n rootTableName,\n versions,\n })\n\n if (groupHasLocalizedField) hasLocalizedField = true\n if (groupHasLocalizedRelationshipField) hasLocalizedRelationshipField = true\n if (groupHasManyTextField) hasManyTextField = true\n if (groupHasLocalizedManyTextField) hasLocalizedManyTextField = true\n if (groupHasManyNumberField) hasManyNumberField = true\n if (groupHasLocalizedManyNumberField) hasLocalizedManyNumberField = true\n break\n }\n\n const disableNotNullFromHere = Boolean(field.admin?.condition) || disableNotNull\n\n const {\n hasLocalizedField: groupHasLocalizedField,\n hasLocalizedManyNumberField: groupHasLocalizedManyNumberField,\n hasLocalizedManyTextField: groupHasLocalizedManyTextField,\n hasLocalizedRelationshipField: groupHasLocalizedRelationshipField,\n hasManyNumberField: groupHasManyNumberField,\n hasManyTextField: groupHasManyTextField,\n } = traverseFields({\n adapter,\n buildNumbers,\n buildRelationships,\n buildTexts,\n columnPrefix: `${columnName}_`,\n columns,\n disableNotNull: disableNotNullFromHere,\n disableUnique,\n fieldPrefix: `${fieldName}.`,\n fields: field.fields,\n forceLocalized: field.localized,\n indexes,\n localesColumns,\n localesIndexes,\n newTableName: `${parentTableName}_${columnName}`,\n parentTableName,\n relationsToBuild,\n relationships,\n rootRelationsToBuild,\n rootTableIDColType,\n rootTableName,\n versions,\n })\n\n if (groupHasLocalizedField) hasLocalizedField = true\n if (groupHasLocalizedRelationshipField) hasLocalizedRelationshipField = true\n if (groupHasManyTextField) hasManyTextField = true\n if (groupHasLocalizedManyTextField) hasLocalizedManyTextField = true\n if (groupHasManyNumberField) hasManyNumberField = true\n if (groupHasLocalizedManyNumberField) hasLocalizedManyNumberField = true\n break\n }\n\n case 'tabs': {\n const disableNotNullFromHere = Boolean(field.admin?.condition) || disableNotNull\n\n const {\n hasLocalizedField: tabHasLocalizedField,\n hasLocalizedManyNumberField: tabHasLocalizedManyNumberField,\n hasLocalizedManyTextField: tabHasLocalizedManyTextField,\n hasLocalizedRelationshipField: tabHasLocalizedRelationshipField,\n hasManyNumberField: tabHasManyNumberField,\n hasManyTextField: tabHasManyTextField,\n } = traverseFields({\n adapter,\n buildNumbers,\n buildRelationships,\n buildTexts,\n columnPrefix,\n columns,\n disableNotNull: disableNotNullFromHere,\n disableUnique,\n fieldPrefix,\n fields: field.tabs.map((tab) => ({ ...tab, type: 'tab' })),\n forceLocalized,\n indexes,\n localesColumns,\n localesIndexes,\n newTableName,\n parentTableName,\n relationsToBuild,\n relationships,\n rootRelationsToBuild,\n rootTableIDColType,\n rootTableName,\n versions,\n })\n\n if (tabHasLocalizedField) hasLocalizedField = true\n if (tabHasLocalizedRelationshipField) hasLocalizedRelationshipField = true\n if (tabHasManyTextField) hasManyTextField = true\n if (tabHasLocalizedManyTextField) hasLocalizedManyTextField = true\n if (tabHasManyNumberField) hasManyNumberField = true\n if (tabHasLocalizedManyNumberField) hasLocalizedManyNumberField = true\n break\n }\n\n case 'row':\n case 'collapsible': {\n const disableNotNullFromHere = Boolean(field.admin?.condition) || disableNotNull\n const {\n hasLocalizedField: rowHasLocalizedField,\n hasLocalizedManyNumberField: rowHasLocalizedManyNumberField,\n hasLocalizedManyTextField: rowHasLocalizedManyTextField,\n hasLocalizedRelationshipField: rowHasLocalizedRelationshipField,\n hasManyNumberField: rowHasManyNumberField,\n hasManyTextField: rowHasManyTextField,\n } = traverseFields({\n adapter,\n buildNumbers,\n buildRelationships,\n buildTexts,\n columnPrefix,\n columns,\n disableNotNull: disableNotNullFromHere,\n disableUnique,\n fieldPrefix,\n fields: field.fields,\n forceLocalized,\n indexes,\n localesColumns,\n localesIndexes,\n newTableName,\n parentTableName,\n relationsToBuild,\n relationships,\n rootRelationsToBuild,\n rootTableIDColType,\n rootTableName,\n versions,\n })\n\n if (rowHasLocalizedField) hasLocalizedField = true\n if (rowHasLocalizedRelationshipField) hasLocalizedRelationshipField = true\n if (rowHasManyTextField) hasManyTextField = true\n if (rowHasLocalizedManyTextField) hasLocalizedManyTextField = true\n if (rowHasManyNumberField) hasManyNumberField = true\n if (rowHasLocalizedManyNumberField) hasLocalizedManyNumberField = true\n break\n }\n\n case 'relationship':\n case 'upload':\n if (Array.isArray(field.relationTo)) {\n field.relationTo.forEach((relation) => relationships.add(relation))\n } else {\n relationships.add(field.relationTo)\n }\n\n if (field.localized && adapter.payload.config.localization) {\n hasLocalizedRelationshipField = true\n }\n break\n\n default:\n break\n }\n\n const condition = field.admin && field.admin.condition\n\n if (\n !disableNotNull &&\n targetTable[fieldName] &&\n 'required' in field &&\n field.required &&\n !condition\n ) {\n targetTable[fieldName].notNull()\n }\n })\n\n return {\n hasLocalizedField,\n hasLocalizedManyNumberField,\n hasLocalizedManyTextField,\n hasLocalizedRelationshipField,\n hasManyNumberField,\n hasManyTextField,\n }\n}\n"],"names":["relations","PgNumericBuilder","PgUUIDBuilder","PgVarcharBuilder","boolean","foreignKey","index","integer","jsonb","numeric","pgEnum","text","timestamp","varchar","InvalidConfiguration","fieldAffectsData","optionIsObject","toSnakeCase","hasLocalesTable","buildTable","createIndex","getTableName","idToUUID","parentIDColumnMap","validateExistingBlockIsIdentical","traverseFields","adapter","buildNumbers","buildRelationships","buildTexts","columnPrefix","columns","disableNotNull","disableUnique","fieldPrefix","fields","forceLocalized","indexes","localesColumns","localesIndexes","newTableName","parentTableName","relationsToBuild","relationships","rootRelationsToBuild","rootTableIDColType","rootTableName","versions","throwValidationError","hasLocalizedField","hasLocalizedRelationshipField","hasManyTextField","hasLocalizedManyTextField","hasManyNumberField","hasLocalizedManyNumberField","parentIDColType","id","forEach","field","name","columnName","fieldName","targetTable","targetIndexes","replace","payload","config","localization","localized","unique","includes","type","hasMany","constraintValue","fieldConstraints","tableName","mode","precision","withTimezone","enumName","prefix","target","enums","options","map","option","value","selectTableName","baseColumns","order","notNull","parent","baseExtraConfig","orderIdx","cols","on","parentFk","foreignColumns","tables","parentIdx","locale","enum__locales","localeIdx","set","selectTableRelations","one","result","references","disableNotNullFromHere","Boolean","admin","condition","arrayTableName","_order","_parentID","_orderIdx","_parentIDFk","onDelete","_parentIDIdx","_locale","_localeIdx","subHasManyNumberField","subHasManyTextField","subRelationsToBuild","rootRelationships","arrayTableRelations","many","_locales","localesSuffix","val","key","blocks","block","blockTableName","_path","_parentIdFk","_pathIdx","blockTableRelations","process","env","NODE_ENV","table","tableLocales","blockTableNames","slug","groupHasLocalizedField","groupHasLocalizedManyNumberField","groupHasLocalizedManyTextField","groupHasLocalizedRelationshipField","groupHasManyNumberField","groupHasManyTextField","tabHasLocalizedField","tabHasLocalizedManyNumberField","tabHasLocalizedManyTextField","tabHasLocalizedRelationshipField","tabHasManyNumberField","tabHasManyTextField","tabs","tab","rowHasLocalizedField","rowHasLocalizedManyNumberField","rowHasLocalizedManyTextField","rowHasLocalizedRelationshipField","rowHasManyNumberField","rowHasManyTextField","Array","isArray","relationTo","relation","add","required"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;wBACAC;wBACAC;wBACAC,gBAAgB4E;wBAChB3E;wBACAC;wBACAC,QAAQuB,MAAMvB,MAAM;wBACpBC;wBACAC;wBACAC;wBACAC;wBACAC;wBACAC;wBACAC;wBACAC;wBACAC;wBACAC;wBACAC;wBACAC;oBACF;oBAEA,IAAIgH,sBAAsB9G,oBAAoB;oBAC9C,IAAIiH,kCAAkChH,gCAAgC;oBACtE,IAAIkH,qBAAqBjH,mBAAmB;oBAC5C,IAAI8G,8BAA8B7G,4BAA4B;oBAC9D,IAAI+G,uBAAuB9G,qBAAqB;oBAChD,IAAI2G,gCAAgC1G,8BAA8B;oBAClE;gBACF;YAEA,KAAK;YACL,KAAK;gBACH,IAAI+G,MAAMC,OAAO,CAAC5G,MAAM6G,UAAU,GAAG;oBACnC7G,MAAM6G,UAAU,CAAC9G,OAAO,CAAC,CAAC+G,WAAa7H,cAAc8H,GAAG,CAACD;gBAC3D,OAAO;oBACL7H,cAAc8H,GAAG,CAAC/G,MAAM6G,UAAU;gBACpC;gBAEA,IAAI7G,MAAMU,SAAS,IAAI1C,QAAQuC,OAAO,CAACC,MAAM,CAACC,YAAY,EAAE;oBAC1DjB,gCAAgC;gBAClC;gBACA;YAEF;gBACE;QACJ;QAEA,MAAM6D,YAAYrD,MAAMoD,KAAK,IAAIpD,MAAMoD,KAAK,CAACC,SAAS;QAEtD,IACE,CAAC/E,kBACD8B,WAAW,CAACD,UAAU,IACtB,cAAcH,SACdA,MAAMgH,QAAQ,IACd,CAAC3D,WACD;YACAjD,WAAW,CAACD,UAAU,CAAC6B,OAAO;QAChC;IACF;IAEA,OAAO;QACLzC;QACAK;QACAF;QACAF;QACAG;QACAF;IACF;AACF,EAAC"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@payloadcms/db-postgres",
|
3
|
-
"version": "3.0.0-beta.
|
3
|
+
"version": "3.0.0-beta.13",
|
4
4
|
"description": "The officially supported Postgres database adapter for Payload",
|
5
5
|
"repository": {
|
6
6
|
"type": "git",
|
@@ -31,10 +31,10 @@
|
|
31
31
|
"@types/pg": "8.10.2",
|
32
32
|
"@types/to-snake-case": "1.0.0",
|
33
33
|
"@payloadcms/eslint-config": "1.1.1",
|
34
|
-
"payload": "3.0.0-beta.
|
34
|
+
"payload": "3.0.0-beta.13"
|
35
35
|
},
|
36
36
|
"peerDependencies": {
|
37
|
-
"payload": "3.0.0-beta.
|
37
|
+
"payload": "3.0.0-beta.13"
|
38
38
|
},
|
39
39
|
"exports": {
|
40
40
|
".": {
|