@payloadcms/drizzle 4.0.0-internal.1f9ae9a → 4.0.0-internal.21320b5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +1 -1
- package/dist/createTableName.d.ts.map +1 -1
- package/dist/createTableName.js +2 -7
- package/dist/createTableName.js.map +1 -1
- package/dist/exports/postgres.d.ts +2 -1
- package/dist/exports/postgres.d.ts.map +1 -1
- package/dist/exports/postgres.js +2 -1
- package/dist/exports/postgres.js.map +1 -1
- package/dist/exports/sqlite.d.ts +2 -1
- package/dist/exports/sqlite.d.ts.map +1 -1
- package/dist/exports/sqlite.js +2 -1
- package/dist/exports/sqlite.js.map +1 -1
- package/dist/find/buildFindManyArgs.d.ts.map +1 -1
- package/dist/find/findMany.d.ts.map +1 -1
- package/dist/find/traverseFields.d.ts.map +1 -1
- package/dist/find/traverseFields.js +1 -2
- package/dist/find/traverseFields.js.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/postgres/createDatabase.d.ts.map +1 -1
- package/dist/postgres/createExtensions.d.ts.map +1 -1
- package/dist/postgres/createJSONQuery/index.d.ts.map +1 -1
- package/dist/postgres/predefinedMigrations/localize-status/index.d.ts +11 -0
- package/dist/postgres/predefinedMigrations/localize-status/index.d.ts.map +1 -0
- package/dist/postgres/predefinedMigrations/localize-status/index.js +296 -0
- package/dist/postgres/predefinedMigrations/localize-status/index.js.map +1 -0
- package/dist/postgres/predefinedMigrations/localize-status/migrateMainCollection.d.ts +13 -0
- package/dist/postgres/predefinedMigrations/localize-status/migrateMainCollection.d.ts.map +1 -0
- package/dist/postgres/predefinedMigrations/localize-status/migrateMainCollection.js +51 -0
- package/dist/postgres/predefinedMigrations/localize-status/migrateMainCollection.js.map +1 -0
- package/dist/postgres/predefinedMigrations/localize-status/migrateMainGlobal.d.ts +13 -0
- package/dist/postgres/predefinedMigrations/localize-status/migrateMainGlobal.d.ts.map +1 -0
- package/dist/postgres/predefinedMigrations/localize-status/migrateMainGlobal.js +54 -0
- package/dist/postgres/predefinedMigrations/localize-status/migrateMainGlobal.js.map +1 -0
- package/dist/postgres/predefinedMigrations/v2-v3/fetchAndResave/index.d.ts.map +1 -1
- package/dist/postgres/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.d.ts.map +1 -1
- package/dist/postgres/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.js.map +1 -1
- package/dist/postgres/predefinedMigrations/v2-v3/groupUpSQLStatements.d.ts.map +1 -1
- package/dist/postgres/predefinedMigrations/v2-v3/index.d.ts.map +1 -1
- package/dist/postgres/predefinedMigrations/v2-v3/index.js +1 -1
- package/dist/postgres/predefinedMigrations/v2-v3/index.js.map +1 -1
- package/dist/postgres/predefinedMigrations/v2-v3/migrateRelationships.d.ts.map +1 -1
- package/dist/postgres/predefinedMigrations/v2-v3/traverseFields.d.ts.map +1 -1
- package/dist/postgres/requireDrizzleKit.d.ts +4 -0
- package/dist/postgres/requireDrizzleKit.d.ts.map +1 -1
- package/dist/postgres/requireDrizzleKit.js +16 -10
- package/dist/postgres/requireDrizzleKit.js.map +1 -1
- package/dist/postgres/schema/buildDrizzleTable.d.ts.map +1 -1
- package/dist/postgres/schema/geometryColumn.d.ts +2 -2
- package/dist/postgres/schema/geometryColumn.d.ts.map +1 -1
- package/dist/queries/addJoinTable.d.ts +1 -1
- package/dist/queries/addJoinTable.d.ts.map +1 -1
- package/dist/queries/buildOrderBy.d.ts +1 -1
- package/dist/queries/buildOrderBy.d.ts.map +1 -1
- package/dist/queries/buildQuery.d.ts.map +1 -1
- package/dist/queries/getTableAlias.d.ts.map +1 -1
- package/dist/queries/getTableColumnFromPath.d.ts.map +1 -1
- package/dist/queries/getTableColumnFromPath.js +2 -2
- package/dist/queries/getTableColumnFromPath.js.map +1 -1
- package/dist/queries/sanitizeQueryValue.d.ts.map +1 -1
- package/dist/queries/selectDistinct.d.ts.map +1 -1
- package/dist/schema/build.d.ts.map +1 -1
- package/dist/schema/build.js +5 -4
- package/dist/schema/build.js.map +1 -1
- package/dist/schema/buildDrizzleRelations.d.ts.map +1 -1
- package/dist/schema/buildRawSchema.d.ts.map +1 -1
- package/dist/schema/buildRawSchema.spec.js +230 -0
- package/dist/schema/buildRawSchema.spec.js.map +1 -0
- package/dist/schema/idToUUID.d.ts.map +1 -1
- package/dist/schema/traverseFields.d.ts.map +1 -1
- package/dist/schema/traverseFields.js +7 -6
- package/dist/schema/traverseFields.js.map +1 -1
- package/dist/schema/withDefault.d.ts.map +1 -1
- package/dist/sqlite/createJSONQuery/convertPathToJSONTraversal.d.ts.map +1 -1
- package/dist/sqlite/createJSONQuery/index.d.ts.map +1 -1
- package/dist/sqlite/createRequireDrizzleKit.d.ts +6 -0
- package/dist/sqlite/createRequireDrizzleKit.d.ts.map +1 -0
- package/dist/sqlite/createRequireDrizzleKit.js +15 -0
- package/dist/sqlite/createRequireDrizzleKit.js.map +1 -0
- package/dist/sqlite/createRequireDrizzleKit.spec.js +71 -0
- package/dist/sqlite/createRequireDrizzleKit.spec.js.map +1 -0
- package/dist/sqlite/drizzleKitTooling.spec.js +86 -0
- package/dist/sqlite/drizzleKitTooling.spec.js.map +1 -0
- package/dist/sqlite/predefinedMigrations/localize-status/index.d.ts +28 -0
- package/dist/sqlite/predefinedMigrations/localize-status/index.d.ts.map +1 -0
- package/dist/sqlite/predefinedMigrations/localize-status/index.js +198 -0
- package/dist/sqlite/predefinedMigrations/localize-status/index.js.map +1 -0
- package/dist/sqlite/predefinedMigrations/localize-status/migrateMainCollection.d.ts +12 -0
- package/dist/sqlite/predefinedMigrations/localize-status/migrateMainCollection.d.ts.map +1 -0
- package/dist/sqlite/predefinedMigrations/localize-status/migrateMainCollection.js +24 -0
- package/dist/sqlite/predefinedMigrations/localize-status/migrateMainCollection.js.map +1 -0
- package/dist/sqlite/predefinedMigrations/localize-status/migrateMainGlobal.d.ts +12 -0
- package/dist/sqlite/predefinedMigrations/localize-status/migrateMainGlobal.d.ts.map +1 -0
- package/dist/sqlite/predefinedMigrations/localize-status/migrateMainGlobal.js +28 -0
- package/dist/sqlite/predefinedMigrations/localize-status/migrateMainGlobal.js.map +1 -0
- package/dist/transform/read/hasManyNumber.d.ts.map +1 -1
- package/dist/transform/read/hasManyText.d.ts.map +1 -1
- package/dist/transform/read/index.d.ts.map +1 -1
- package/dist/transform/read/relationship.d.ts.map +1 -1
- package/dist/transform/read/traverseFields.d.ts.map +1 -1
- package/dist/transform/read/traverseFields.js +2 -2
- package/dist/transform/read/traverseFields.js.map +1 -1
- package/dist/transform/write/array.d.ts.map +1 -1
- package/dist/transform/write/blocks.d.ts.map +1 -1
- package/dist/transform/write/blocks.js +1 -1
- package/dist/transform/write/blocks.js.map +1 -1
- package/dist/transform/write/index.d.ts.map +1 -1
- package/dist/transform/write/numbers.d.ts.map +1 -1
- package/dist/transform/write/relationships.d.ts.map +1 -1
- package/dist/transform/write/selects.d.ts.map +1 -1
- package/dist/transform/write/texts.d.ts.map +1 -1
- package/dist/transform/write/traverseFields.d.ts.map +1 -1
- package/dist/transform/write/traverseFields.js +1 -2
- package/dist/transform/write/traverseFields.js.map +1 -1
- package/dist/types.d.ts +2 -6
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -3
- package/dist/types.js.map +1 -1
- package/dist/updateJobs.d.ts.map +1 -1
- package/dist/updateJobs.js +37 -0
- package/dist/updateJobs.js.map +1 -1
- package/dist/upsertRow/deleteExistingArrayRows.d.ts.map +1 -1
- package/dist/upsertRow/deleteExistingRowsByPath.d.ts.map +1 -1
- package/dist/upsertRow/handleUpsertError.d.ts.map +1 -1
- package/dist/upsertRow/handleUpsertError.js +2 -1
- package/dist/upsertRow/handleUpsertError.js.map +1 -1
- package/dist/upsertRow/handleUpsertError.spec.js +42 -0
- package/dist/upsertRow/handleUpsertError.spec.js.map +1 -0
- package/dist/upsertRow/index.d.ts.map +1 -1
- package/dist/upsertRow/index.js +5 -2
- package/dist/upsertRow/index.js.map +1 -1
- package/dist/upsertRow/insertArrays.d.ts.map +1 -1
- package/dist/upsertRow/insertArrays.js +2 -1
- package/dist/upsertRow/insertArrays.js.map +1 -1
- package/dist/upsertRow/shouldUseOptimizedUpsertRow.d.ts.map +1 -1
- package/dist/utilities/appendPrefixToKeys.d.ts.map +1 -1
- package/dist/utilities/blocksToJsonMigrator.d.ts.map +1 -1
- package/dist/utilities/blocksToJsonMigrator.js +1 -1
- package/dist/utilities/blocksToJsonMigrator.js.map +1 -1
- package/dist/utilities/buildCreateMigration.d.ts.map +1 -1
- package/dist/utilities/buildCreateMigration.js +1 -1
- package/dist/utilities/buildCreateMigration.js.map +1 -1
- package/dist/utilities/buildForeignKeyName.d.ts.map +1 -1
- package/dist/utilities/buildIndexName.d.ts.map +1 -1
- package/dist/utilities/createBlocksMap.d.ts.map +1 -1
- package/dist/utilities/createRelationshipMap.d.ts.map +1 -1
- package/dist/utilities/createSchemaGenerator.d.ts.map +1 -1
- package/dist/utilities/escapeSQLValue.d.ts.map +1 -1
- package/dist/utilities/executeSchemaHooks.d.ts.map +1 -1
- package/dist/utilities/extendDrizzleTable.d.ts.map +1 -1
- package/dist/utilities/getArrayRelationName.d.ts.map +1 -1
- package/dist/utilities/getCollectionIdType.d.ts.map +1 -1
- package/dist/utilities/getMigrationTemplate.d.ts.map +1 -1
- package/dist/utilities/getNameFromDrizzleTable.d.ts.map +1 -1
- package/dist/utilities/getPrimaryDb.d.ts +1 -1
- package/dist/utilities/getPrimaryDb.d.ts.map +1 -1
- package/dist/utilities/getTransaction.d.ts +1 -1
- package/dist/utilities/getTransaction.d.ts.map +1 -1
- package/dist/utilities/hasLocalesTable.d.ts.map +1 -1
- package/dist/utilities/isPolymorphicRelationship.d.ts.map +1 -1
- package/dist/utilities/isUUIDType.d.ts.map +1 -1
- package/dist/utilities/json.d.ts.map +1 -1
- package/dist/utilities/migrationTableExists.d.ts.map +1 -1
- package/dist/utilities/parseError.d.ts.map +1 -1
- package/dist/utilities/pushDevSchema.d.ts.map +1 -1
- package/dist/utilities/pushDevSchema.js +1 -1
- package/dist/utilities/pushDevSchema.js.map +1 -1
- package/dist/utilities/rawConstraint.d.ts.map +1 -1
- package/dist/utilities/sanitizePathSegment.d.ts.map +1 -1
- package/dist/utilities/validateExistingBlockIsIdentical.d.ts +1 -5
- package/dist/utilities/validateExistingBlockIsIdentical.d.ts.map +1 -1
- package/dist/utilities/validateExistingBlockIsIdentical.js.map +1 -1
- package/dist/utilities/validateIdentifierLength.d.ts +7 -0
- package/dist/utilities/validateIdentifierLength.d.ts.map +1 -0
- package/dist/utilities/validateIdentifierLength.js +14 -0
- package/dist/utilities/validateIdentifierLength.js.map +1 -0
- package/dist/utilities/validateIdentifierLength.spec.js +19 -0
- package/dist/utilities/validateIdentifierLength.spec.js.map +1 -0
- package/package.json +4 -3
- package/dist/find/chainMethods.d.ts +0 -20
- package/dist/find/chainMethods.d.ts.map +0 -1
- package/dist/find/chainMethods.js +0 -16
- package/dist/find/chainMethods.js.map +0 -1
- package/dist/sqlite/requireDrizzleKit.d.ts +0 -3
- package/dist/sqlite/requireDrizzleKit.d.ts.map +0 -1
- package/dist/sqlite/requireDrizzleKit.js +0 -12
- package/dist/sqlite/requireDrizzleKit.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/schema/traverseFields.ts"],"sourcesContent":["import type { FlattenedField } from 'payload'\n\nimport { InvalidConfiguration } from 'payload'\nimport {\n fieldAffectsData,\n fieldIsVirtual,\n fieldShouldBeLocalized,\n optionIsObject,\n} from 'payload/shared'\nimport toSnakeCase from 'to-snake-case'\n\nimport type {\n DrizzleAdapter,\n IDType,\n RawColumn,\n RawForeignKey,\n RawIndex,\n RawRelation,\n RelationMap,\n SetColumnID,\n} from '../types.js'\n\nimport { createTableName } from '../createTableName.js'\nimport { buildIndexName } from '../utilities/buildIndexName.js'\nimport { getArrayRelationName } from '../utilities/getArrayRelationName.js'\nimport { hasLocalesTable } from '../utilities/hasLocalesTable.js'\nimport { isUUIDType } from '../utilities/isUUIDType.js'\nimport {\n InternalBlockTableNameIndex,\n setInternalBlockIndex,\n validateExistingBlockIsIdentical,\n} from '../utilities/validateExistingBlockIsIdentical.js'\nimport { buildTable } from './build.js'\nimport { idToUUID } from './idToUUID.js'\nimport { withDefault } from './withDefault.js'\n\ntype Args = {\n adapter: DrizzleAdapter\n blocksTableNameMap: Record<string, number>\n columnPrefix?: string\n columns: Record<string, RawColumn>\n disableNotNull: boolean\n disableRelsTableUnique?: boolean\n disableUnique?: boolean\n fieldPrefix?: string\n fields: FlattenedField[]\n forceLocalized?: boolean\n indexes: Record<string, RawIndex>\n localesColumns: Record<string, RawColumn>\n localesIndexes: Record<string, RawIndex>\n newTableName: string\n parentIsLocalized: boolean\n parentTableName: string\n relationships: Set<string>\n relationsToBuild: RelationMap\n rootRelationsToBuild?: RelationMap\n rootTableIDColType: IDType\n rootTableName: string\n setColumnID: SetColumnID\n uniqueRelationships: Set<string>\n versions: boolean\n /**\n * Tracks whether or not this table is built\n * from the result of a localized array or block field at some point\n */\n withinLocalizedArrayOrBlock?: 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 blocksTableNameMap,\n columnPrefix,\n columns,\n disableNotNull,\n disableRelsTableUnique,\n disableUnique = false,\n fieldPrefix,\n fields,\n forceLocalized,\n indexes,\n localesColumns,\n localesIndexes,\n newTableName,\n parentIsLocalized,\n parentTableName,\n relationships,\n relationsToBuild,\n rootRelationsToBuild,\n rootTableIDColType,\n rootTableName,\n setColumnID,\n uniqueRelationships,\n versions,\n withinLocalizedArrayOrBlock,\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\n const idColumn = columns.id\n\n if (idColumn && ['numeric', 'text', 'uuid', 'varchar'].includes(idColumn.type)) {\n parentIDColType = idColumn.type as IDType\n }\n\n fields.forEach((field) => {\n if ('name' in field && field.name === 'id') {\n return\n }\n if (fieldIsVirtual(field)) {\n return\n }\n\n let targetTable = columns\n let targetIndexes = indexes\n\n const columnName = `${columnPrefix || ''}${field.name[0] === '_' ? '_' : ''}${toSnakeCase(\n field.name,\n )}`\n const fieldName = `${fieldPrefix?.replace('.', '_') || ''}${field.name}`\n\n const isFieldLocalized = fieldShouldBeLocalized({ field, parentIsLocalized })\n\n // If field is localized,\n // add the column to the locale table instead of main table\n if (\n adapter.payload.config.localization &&\n (isFieldLocalized || forceLocalized) &&\n field.type !== 'array' &&\n (field.type !== 'blocks' || adapter.blocksAsJSON) &&\n (('hasMany' in field && field.hasMany !== true) || !('hasMany' in field))\n ) {\n hasLocalizedField = true\n targetTable = localesColumns\n targetIndexes = localesIndexes\n }\n\n if (\n (field.unique || field.index || ['relationship', 'upload'].includes(field.type)) &&\n !['array', 'blocks', 'group'].includes(field.type) &&\n !('hasMany' in field && field.hasMany === true) &&\n !('relationTo' in field && Array.isArray(field.relationTo))\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\n const indexName = buildIndexName({ name: `${newTableName}_${columnName}`, adapter })\n\n targetIndexes[indexName] = {\n name: indexName,\n on: isFieldLocalized ? [fieldName, '_locale'] : fieldName,\n unique,\n }\n }\n\n switch (field.type) {\n case 'array': {\n const disableNotNullFromHere = Boolean(field.admin?.condition) || disableNotNull\n\n const arrayTableName = createTableName({\n adapter,\n config: field,\n parentTableName: newTableName,\n prefix: `${newTableName}_`,\n throwValidationError,\n versionsCustomName: versions,\n })\n\n const baseColumns: Record<string, RawColumn> = {\n _order: {\n name: '_order',\n type: 'integer',\n notNull: true,\n },\n _parentID: {\n name: '_parent_id',\n type: parentIDColType,\n notNull: true,\n },\n }\n\n const baseIndexes: Record<string, RawIndex> = {\n _orderIdx: {\n name: `${arrayTableName}_order_idx`,\n on: ['_order'],\n },\n _parentIDIdx: {\n name: `${arrayTableName}_parent_id_idx`,\n on: '_parentID',\n },\n }\n\n const baseForeignKeys: Record<string, RawForeignKey> = {\n _parentIDFk: {\n name: `${arrayTableName}_parent_id_fk`,\n columns: ['_parentID'],\n foreignColumns: [\n {\n name: 'id',\n table: parentTableName,\n },\n ],\n onDelete: 'cascade',\n },\n }\n\n const isLocalized =\n Boolean(isFieldLocalized && adapter.payload.config.localization) ||\n withinLocalizedArrayOrBlock ||\n forceLocalized\n\n if (isLocalized) {\n baseColumns._locale = {\n name: '_locale',\n type: 'enum',\n locale: true,\n notNull: true,\n }\n\n baseIndexes._localeIdx = {\n name: `${arrayTableName}_locale_idx`,\n on: '_locale',\n }\n }\n\n const {\n hasLocalizedManyNumberField: subHasLocalizedManyNumberField,\n hasLocalizedManyTextField: subHasLocalizedManyTextField,\n hasLocalizedRelationshipField: subHasLocalizedRelationshipField,\n hasManyNumberField: subHasManyNumberField,\n hasManyTextField: subHasManyTextField,\n relationsToBuild: subRelationsToBuild,\n } = buildTable({\n adapter,\n baseColumns,\n baseForeignKeys,\n baseIndexes,\n blocksTableNameMap,\n disableNotNull: disableNotNullFromHere,\n disableRelsTableUnique: true,\n disableUnique,\n fields: disableUnique ? idToUUID(field.flattenedFields) : field.flattenedFields,\n parentIsLocalized: parentIsLocalized || field.localized,\n rootRelationships: relationships,\n rootRelationsToBuild,\n rootTableIDColType,\n rootTableName,\n rootUniqueRelationships: uniqueRelationships,\n setColumnID,\n tableName: arrayTableName,\n versions,\n withinLocalizedArrayOrBlock: isLocalized,\n })\n\n if (subHasLocalizedManyNumberField) {\n hasLocalizedManyNumberField = subHasLocalizedManyNumberField\n }\n\n if (subHasLocalizedRelationshipField) {\n hasLocalizedRelationshipField = subHasLocalizedRelationshipField\n }\n\n if (subHasLocalizedManyTextField) {\n hasLocalizedManyTextField = subHasLocalizedManyTextField\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\n const relationName = getArrayRelationName({\n field,\n path: fieldName,\n tableName: arrayTableName,\n })\n\n relationsToBuild.set(relationName, {\n type: 'many',\n // arrays have their own localized table, independent of the base table.\n localized: false,\n target: arrayTableName,\n })\n\n const arrayRelations: Record<string, RawRelation> = {\n _parentID: {\n type: 'one',\n fields: [\n {\n name: '_parentID',\n table: arrayTableName,\n },\n ],\n references: ['id'],\n relationName,\n to: parentTableName,\n },\n }\n\n if (\n hasLocalesTable({\n fields: field.fields,\n parentIsLocalized: parentIsLocalized || field.localized,\n })\n ) {\n arrayRelations._locales = {\n type: 'many',\n relationName: '_locales',\n to: `${arrayTableName}${adapter.localesSuffix}`,\n }\n }\n\n subRelationsToBuild.forEach(({ type, localized, target }, key) => {\n if (type === 'one') {\n const arrayWithLocalized = localized\n ? `${arrayTableName}${adapter.localesSuffix}`\n : arrayTableName\n\n arrayRelations[key] = {\n type: 'one',\n fields: [\n {\n name: key,\n table: arrayWithLocalized,\n },\n ],\n references: ['id'],\n relationName: key,\n to: target,\n }\n }\n\n if (type === 'many') {\n arrayRelations[key] = {\n type: 'many',\n relationName: key,\n to: target,\n }\n }\n })\n\n adapter.rawRelations[arrayTableName] = arrayRelations\n\n break\n }\n case 'blocks': {\n if (adapter.blocksAsJSON) {\n targetTable[fieldName] = withDefault(\n {\n name: columnName,\n type: 'jsonb',\n },\n field,\n )\n break\n }\n\n const disableNotNullFromHere = Boolean(field.admin?.condition) || disableNotNull\n\n ;(field.blockReferences ?? field.blocks).forEach((_block) => {\n const block = typeof _block === 'string' ? adapter.payload.blocks[_block] : _block\n\n let blockTableName = createTableName({\n adapter,\n config: block,\n parentTableName: rootTableName,\n prefix: `${rootTableName}_blocks_`,\n throwValidationError,\n versionsCustomName: versions,\n })\n\n if (typeof blocksTableNameMap[blockTableName] === 'undefined') {\n blocksTableNameMap[blockTableName] = 1\n } else if (\n !adapter.rawTables[blockTableName] ||\n !validateExistingBlockIsIdentical({\n block,\n localized: field.localized,\n rootTableName,\n table: adapter.rawTables[blockTableName],\n tableLocales: adapter.rawTables[`${blockTableName}${adapter.localesSuffix}`],\n })\n ) {\n blocksTableNameMap[blockTableName]++\n setInternalBlockIndex(block, blocksTableNameMap[blockTableName])\n blockTableName = `${blockTableName}_${blocksTableNameMap[blockTableName]}`\n }\n let relationName = `_blocks_${block.slug}`\n if (typeof block[InternalBlockTableNameIndex] !== 'undefined') {\n relationName = `_blocks_${block.slug}_${block[InternalBlockTableNameIndex]}`\n }\n\n if (!adapter.rawTables[blockTableName]) {\n const baseColumns: Record<string, RawColumn> = {\n _order: {\n name: '_order',\n type: 'integer',\n notNull: true,\n },\n _parentID: {\n name: '_parent_id',\n type: rootTableIDColType,\n notNull: true,\n },\n _path: {\n name: '_path',\n type: 'text',\n notNull: true,\n },\n }\n\n const baseIndexes: Record<string, RawIndex> = {\n _orderIdx: {\n name: `${blockTableName}_order_idx`,\n on: '_order',\n },\n _parentIDIdx: {\n name: `${blockTableName}_parent_id_idx`,\n on: ['_parentID'],\n },\n _pathIdx: {\n name: `${blockTableName}_path_idx`,\n on: '_path',\n },\n }\n\n const baseForeignKeys: Record<string, RawForeignKey> = {\n _parentIdFk: {\n name: `${blockTableName}_parent_id_fk`,\n columns: ['_parentID'],\n foreignColumns: [\n {\n name: 'id',\n table: rootTableName,\n },\n ],\n onDelete: 'cascade',\n },\n }\n\n const isLocalized =\n Boolean(isFieldLocalized && adapter.payload.config.localization) ||\n withinLocalizedArrayOrBlock ||\n forceLocalized\n\n if (isLocalized) {\n baseColumns._locale = {\n name: '_locale',\n type: 'enum',\n locale: true,\n notNull: true,\n }\n\n baseIndexes._localeIdx = {\n name: `${blockTableName}_locale_idx`,\n on: '_locale',\n }\n }\n\n const {\n hasLocalizedManyNumberField: subHasLocalizedManyNumberField,\n hasLocalizedManyTextField: subHasLocalizedManyTextField,\n hasLocalizedRelationshipField: subHasLocalizedRelationshipField,\n hasManyNumberField: subHasManyNumberField,\n hasManyTextField: subHasManyTextField,\n relationsToBuild: subRelationsToBuild,\n } = buildTable({\n adapter,\n baseColumns,\n baseForeignKeys,\n baseIndexes,\n blocksTableNameMap,\n disableNotNull: disableNotNullFromHere,\n disableRelsTableUnique: true,\n disableUnique,\n fields: disableUnique ? idToUUID(block.flattenedFields) : block.flattenedFields,\n parentIsLocalized: parentIsLocalized || field.localized,\n rootRelationships: relationships,\n rootRelationsToBuild,\n rootTableIDColType,\n rootTableName,\n rootUniqueRelationships: uniqueRelationships,\n setColumnID,\n tableName: blockTableName,\n versions,\n withinLocalizedArrayOrBlock: isLocalized,\n })\n\n if (subHasLocalizedManyNumberField) {\n hasLocalizedManyNumberField = subHasLocalizedManyNumberField\n }\n\n if (subHasLocalizedRelationshipField) {\n hasLocalizedRelationshipField = subHasLocalizedRelationshipField\n }\n\n if (subHasLocalizedManyTextField) {\n hasLocalizedManyTextField = subHasLocalizedManyTextField\n }\n\n if (subHasManyTextField) {\n if (!hasManyTextField || subHasManyTextField === 'index') {\n hasManyTextField = subHasManyTextField\n }\n }\n\n if (subHasManyNumberField) {\n if (!hasManyNumberField || subHasManyNumberField === 'index') {\n hasManyNumberField = subHasManyNumberField\n }\n }\n\n const blockRelations: Record<string, RawRelation> = {\n _parentID: {\n type: 'one',\n fields: [\n {\n name: '_parentID',\n table: blockTableName,\n },\n ],\n references: ['id'],\n relationName,\n to: rootTableName,\n },\n }\n\n if (\n hasLocalesTable({\n fields: block.fields,\n parentIsLocalized: parentIsLocalized || field.localized,\n })\n ) {\n blockRelations._locales = {\n type: 'many',\n relationName: '_locales',\n to: `${blockTableName}${adapter.localesSuffix}`,\n }\n }\n\n subRelationsToBuild.forEach(({ type, localized, target }, key) => {\n if (type === 'one') {\n const blockWithLocalized = localized\n ? `${blockTableName}${adapter.localesSuffix}`\n : blockTableName\n\n blockRelations[key] = {\n type: 'one',\n fields: [\n {\n name: key,\n table: blockWithLocalized,\n },\n ],\n references: ['id'],\n relationName: key,\n to: target,\n }\n }\n\n if (type === 'many') {\n blockRelations[key] = {\n type: 'many',\n relationName: key,\n to: target,\n }\n }\n })\n\n adapter.rawRelations[blockTableName] = blockRelations\n }\n\n // blocks relationships are defined from the collection or globals table down to the block, bypassing any subBlocks\n rootRelationsToBuild.set(relationName, {\n type: 'many',\n // blocks are not localized on the parent table\n localized: false,\n target: blockTableName,\n })\n })\n\n break\n }\n case 'checkbox': {\n targetTable[fieldName] = withDefault(\n {\n name: columnName,\n type: 'boolean',\n },\n field,\n )\n\n break\n }\n\n case 'code':\n case 'email':\n case 'textarea': {\n targetTable[fieldName] = withDefault(\n {\n name: columnName,\n type: 'varchar',\n },\n field,\n )\n\n break\n }\n\n case 'date': {\n targetTable[fieldName] = withDefault(\n {\n name: columnName,\n type: 'timestamp',\n mode: 'string',\n precision: 3,\n withTimezone: true,\n },\n field,\n )\n\n break\n }\n\n case 'group':\n case 'tab': {\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 blocksTableNameMap,\n columnPrefix: `${columnName}_`,\n columns,\n disableNotNull: disableNotNullFromHere,\n disableUnique,\n fieldPrefix: `${fieldName}.`,\n fields: field.flattenedFields,\n forceLocalized: isFieldLocalized || Boolean(forceLocalized),\n indexes,\n localesColumns,\n localesIndexes,\n newTableName: `${parentTableName}_${columnName}`,\n parentIsLocalized: parentIsLocalized || field.localized,\n parentTableName,\n relationships,\n relationsToBuild,\n rootRelationsToBuild,\n rootTableIDColType,\n rootTableName,\n setColumnID,\n uniqueRelationships,\n versions,\n withinLocalizedArrayOrBlock: withinLocalizedArrayOrBlock || isFieldLocalized,\n })\n\n if (groupHasLocalizedField) {\n hasLocalizedField = true\n }\n if (groupHasLocalizedRelationshipField) {\n hasLocalizedRelationshipField = true\n }\n if (groupHasManyTextField) {\n hasManyTextField = true\n }\n if (groupHasLocalizedManyTextField) {\n hasLocalizedManyTextField = true\n }\n if (groupHasManyNumberField) {\n hasManyNumberField = true\n }\n if (groupHasLocalizedManyNumberField) {\n hasLocalizedManyNumberField = true\n }\n break\n }\n\n case 'json':\n case 'richText': {\n targetTable[fieldName] = withDefault(\n {\n name: columnName,\n type: 'jsonb',\n },\n field,\n )\n\n break\n }\n\n case 'number': {\n if (field.hasMany) {\n const isLocalized =\n Boolean(isFieldLocalized && adapter.payload.config.localization) ||\n withinLocalizedArrayOrBlock ||\n forceLocalized\n\n if (isLocalized) {\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] = withDefault(\n {\n name: columnName,\n type: 'numeric',\n },\n field,\n )\n }\n\n break\n }\n\n case 'point': {\n targetTable[fieldName] = withDefault(\n {\n name: columnName,\n type: 'geometry',\n },\n field,\n )\n\n break\n }\n\n case 'radio':\n case 'select': {\n const enumName = createTableName({\n adapter,\n config: field,\n parentTableName: newTableName,\n prefix: `enum_${newTableName}_`,\n target: 'enumName',\n throwValidationError,\n })\n\n const options = field.options.map((option) => {\n if (optionIsObject(option)) {\n return option.value\n }\n\n return option\n })\n\n if (field.type === 'select' && field.hasMany) {\n const selectTableName = createTableName({\n adapter,\n config: field,\n parentTableName: newTableName,\n prefix: `${newTableName}_`,\n throwValidationError,\n versionsCustomName: versions,\n })\n\n const baseColumns: Record<string, RawColumn> = {\n order: {\n name: 'order',\n type: 'integer',\n notNull: true,\n },\n parent: {\n name: 'parent_id',\n type: parentIDColType,\n notNull: true,\n },\n value: {\n name: 'value',\n type: 'enum',\n enumName: createTableName({\n adapter,\n config: field,\n parentTableName: newTableName,\n prefix: `enum_${newTableName}_`,\n target: 'enumName',\n throwValidationError,\n }),\n options,\n },\n }\n\n const baseIndexes: Record<string, RawIndex> = {\n orderIdx: {\n name: `${selectTableName}_order_idx`,\n on: 'order',\n },\n parentIdx: {\n name: `${selectTableName}_parent_idx`,\n on: 'parent',\n },\n }\n\n const baseForeignKeys: Record<string, RawForeignKey> = {\n parentFk: {\n name: `${selectTableName}_parent_fk`,\n columns: ['parent'],\n foreignColumns: [\n {\n name: 'id',\n table: parentTableName,\n },\n ],\n onDelete: 'cascade',\n },\n }\n\n const isLocalized =\n Boolean(isFieldLocalized && adapter.payload.config.localization) ||\n withinLocalizedArrayOrBlock ||\n forceLocalized\n\n if (isLocalized) {\n baseColumns.locale = {\n name: 'locale',\n type: 'enum',\n locale: true,\n notNull: true,\n }\n\n baseIndexes.localeIdx = {\n name: `${selectTableName}_locale_idx`,\n on: 'locale',\n }\n }\n\n if (field.index) {\n baseIndexes.value = {\n name: `${selectTableName}_value_idx`,\n on: 'value',\n }\n }\n\n buildTable({\n adapter,\n baseColumns,\n baseForeignKeys,\n baseIndexes,\n blocksTableNameMap,\n disableNotNull,\n disableUnique,\n fields: [],\n parentIsLocalized: parentIsLocalized || field.localized,\n rootTableName,\n setColumnID,\n tableName: selectTableName,\n versions,\n })\n\n relationsToBuild.set(fieldName, {\n type: 'many',\n // selects have their own localized table, independent of the base table.\n localized: false,\n target: selectTableName,\n })\n\n adapter.rawRelations[selectTableName] = {\n parent: {\n type: 'one',\n fields: [\n {\n name: 'parent',\n table: selectTableName,\n },\n ],\n references: ['id'],\n relationName: fieldName,\n to: parentTableName,\n },\n }\n } else {\n targetTable[fieldName] = withDefault(\n {\n name: columnName,\n type: 'enum',\n enumName,\n options,\n },\n field,\n )\n }\n break\n }\n\n case 'relationship':\n case 'upload':\n if (Array.isArray(field.relationTo)) {\n field.relationTo.forEach((relation) => {\n relationships.add(relation)\n if (field.unique && !disableUnique && !disableRelsTableUnique) {\n uniqueRelationships.add(relation)\n }\n })\n } else if (field.hasMany) {\n relationships.add(field.relationTo)\n if (field.unique && !disableUnique && !disableRelsTableUnique) {\n uniqueRelationships.add(field.relationTo)\n }\n } else {\n // simple relationships get a column on the targetTable with a foreign key to the relationTo table\n const relationshipConfig = adapter.payload.collections[field.relationTo].config\n\n const tableName = adapter.tableNameMap.get(toSnakeCase(field.relationTo))\n\n // get the id type of the related collection\n let colType: IDType = isUUIDType(adapter.idType) ? 'uuid' : 'integer'\n const relatedCollectionCustomID = relationshipConfig.fields.find(\n (field) => fieldAffectsData(field) && field.name === 'id',\n )\n if (relatedCollectionCustomID?.type === 'number') {\n colType = 'numeric'\n }\n if (relatedCollectionCustomID?.type === 'text') {\n colType = 'varchar'\n }\n\n // make the foreign key column for relationship using the correct id column type\n targetTable[fieldName] = {\n name: `${columnName}_id`,\n type: colType,\n reference: {\n name: 'id',\n onDelete: 'set null',\n table: tableName,\n },\n }\n\n // add relationship to table\n relationsToBuild.set(fieldName, {\n type: 'one',\n localized: adapter.payload.config.localization && (isFieldLocalized || forceLocalized),\n target: tableName,\n })\n\n // add notNull when not required\n if (!disableNotNull && field.required && !field.admin?.condition) {\n targetTable[fieldName].notNull = true\n }\n break\n }\n\n if (\n Boolean(isFieldLocalized && adapter.payload.config.localization) ||\n withinLocalizedArrayOrBlock\n ) {\n hasLocalizedRelationshipField = true\n }\n\n break\n\n case 'text': {\n if (field.hasMany) {\n const isLocalized =\n Boolean(isFieldLocalized && adapter.payload.config.localization) ||\n withinLocalizedArrayOrBlock ||\n forceLocalized\n\n if (isLocalized) {\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] = withDefault(\n {\n name: columnName,\n type: 'varchar',\n },\n field,\n )\n }\n break\n }\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 = true\n }\n })\n\n return {\n hasLocalizedField,\n hasLocalizedManyNumberField,\n hasLocalizedManyTextField,\n hasLocalizedRelationshipField,\n hasManyNumberField,\n hasManyTextField,\n }\n}\n"],"names":["InvalidConfiguration","fieldAffectsData","fieldIsVirtual","fieldShouldBeLocalized","optionIsObject","toSnakeCase","createTableName","buildIndexName","getArrayRelationName","hasLocalesTable","isUUIDType","InternalBlockTableNameIndex","setInternalBlockIndex","validateExistingBlockIsIdentical","buildTable","idToUUID","withDefault","traverseFields","adapter","blocksTableNameMap","columnPrefix","columns","disableNotNull","disableRelsTableUnique","disableUnique","fieldPrefix","fields","forceLocalized","indexes","localesColumns","localesIndexes","newTableName","parentIsLocalized","parentTableName","relationships","relationsToBuild","rootRelationsToBuild","rootTableIDColType","rootTableName","setColumnID","uniqueRelationships","versions","withinLocalizedArrayOrBlock","throwValidationError","hasLocalizedField","hasLocalizedRelationshipField","hasManyTextField","hasLocalizedManyTextField","hasManyNumberField","hasLocalizedManyNumberField","parentIDColType","idColumn","id","includes","type","forEach","field","name","targetTable","targetIndexes","columnName","fieldName","replace","isFieldLocalized","payload","config","localization","blocksAsJSON","hasMany","unique","index","Array","isArray","relationTo","constraintValue","fieldConstraints","indexName","on","disableNotNullFromHere","Boolean","admin","condition","arrayTableName","prefix","versionsCustomName","baseColumns","_order","notNull","_parentID","baseIndexes","_orderIdx","_parentIDIdx","baseForeignKeys","_parentIDFk","foreignColumns","table","onDelete","isLocalized","_locale","locale","_localeIdx","subHasLocalizedManyNumberField","subHasLocalizedManyTextField","subHasLocalizedRelationshipField","subHasManyNumberField","subHasManyTextField","subRelationsToBuild","flattenedFields","localized","rootRelationships","rootUniqueRelationships","tableName","relationName","path","set","target","arrayRelations","references","to","_locales","localesSuffix","key","arrayWithLocalized","rawRelations","blockReferences","blocks","_block","block","blockTableName","rawTables","tableLocales","slug","_path","_pathIdx","_parentIdFk","blockRelations","blockWithLocalized","mode","precision","withTimezone","groupHasLocalizedField","groupHasLocalizedManyNumberField","groupHasLocalizedManyTextField","groupHasLocalizedRelationshipField","groupHasManyNumberField","groupHasManyTextField","enumName","options","map","option","value","selectTableName","order","parent","orderIdx","parentIdx","parentFk","localeIdx","relation","add","relationshipConfig","collections","tableNameMap","get","colType","idType","relatedCollectionCustomID","find","reference","required"],"mappings":"AAEA,SAASA,oBAAoB,QAAQ,UAAS;AAC9C,SACEC,gBAAgB,EAChBC,cAAc,EACdC,sBAAsB,EACtBC,cAAc,QACT,iBAAgB;AACvB,OAAOC,iBAAiB,gBAAe;AAavC,SAASC,eAAe,QAAQ,wBAAuB;AACvD,SAASC,cAAc,QAAQ,iCAAgC;AAC/D,SAASC,oBAAoB,QAAQ,uCAAsC;AAC3E,SAASC,eAAe,QAAQ,kCAAiC;AACjE,SAASC,UAAU,QAAQ,6BAA4B;AACvD,SACEC,2BAA2B,EAC3BC,qBAAqB,EACrBC,gCAAgC,QAC3B,mDAAkD;AACzD,SAASC,UAAU,QAAQ,aAAY;AACvC,SAASC,QAAQ,QAAQ,gBAAe;AACxC,SAASC,WAAW,QAAQ,mBAAkB;AA2C9C,OAAO,MAAMC,iBAAiB,CAAC,EAC7BC,OAAO,EACPC,kBAAkB,EAClBC,YAAY,EACZC,OAAO,EACPC,c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CAACC,MAAM,CAACC,YAAY,KAC/DxB,6BACA;oBACAG,gCAAgC;gBAClC;gBAEA;YAEF,KAAK;gBAAQ;oBACX,IAAIW,MAAMY,OAAO,EAAE;wBACjB,MAAM6B,cACJlB,QAAQhB,oBAAoB7C,QAAQ8C,OAAO,CAACC,MAAM,CAACC,YAAY,KAC/DxB,+BACAf;wBAEF,IAAIsE,aAAa;4BACflD,4BAA4B;wBAC9B;wBAEA,IAAIS,MAAMc,KAAK,EAAE;4BACfxB,mBAAmB;wBACrB,OAAO,IAAI,CAACA,kBAAkB;4BAC5BA,mBAAmB;wBACrB;wBAEA,IAAIU,MAAMa,MAAM,EAAE;4BAChB,MAAM,IAAIrE,qBACR;wBAEJ;oBACF,OAAO;wBACL0D,WAAW,CAACG,UAAU,GAAG7C,YACvB;4BACEyC,MAAMG;4BACNN,MAAM;wBACR,GACAE;oBAEJ;oBACA;gBACF;YAEA;gBACE;QACJ;QAEA,MAAMyB,YAAYzB,MAAMwB,KAAK,IAAIxB,MAAMwB,KAAK,CAACC,SAAS;QAEtD,IACE,CAAC3D,kBACDoC,WAAW,CAACG,UAAU,IACtB,cAAcL,SACdA,MAAMiH,QAAQ,IACd,CAACxF,WACD;YACAvB,WAAW,CAACG,UAAU,CAAC0B,OAAO,GAAG;QACnC;IACF;IAEA,OAAO;QACL3C;QACAK;QACAF;QACAF;QACAG;QACAF;IACF;AACF,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../src/schema/traverseFields.ts"],"sourcesContent":["import type { FlattenedField } from 'payload'\n\nimport { InvalidConfiguration } from 'payload'\nimport {\n fieldAffectsData,\n fieldIsVirtual,\n fieldShouldBeLocalized,\n optionIsObject,\n} from 'payload/shared'\nimport toSnakeCase from 'to-snake-case'\n\nimport type {\n DrizzleAdapter,\n IDType,\n RawColumn,\n RawForeignKey,\n RawIndex,\n RawRelation,\n RelationMap,\n SetColumnID,\n} from '../types.js'\n\nimport { createTableName } from '../createTableName.js'\nimport { buildIndexName } from '../utilities/buildIndexName.js'\nimport { getArrayRelationName } from '../utilities/getArrayRelationName.js'\nimport { hasLocalesTable } from '../utilities/hasLocalesTable.js'\nimport { isUUIDType } from '../utilities/isUUIDType.js'\nimport {\n InternalBlockTableNameIndex,\n setInternalBlockIndex,\n validateExistingBlockIsIdentical,\n} from '../utilities/validateExistingBlockIsIdentical.js'\nimport { buildTable } from './build.js'\nimport { idToUUID } from './idToUUID.js'\nimport { withDefault } from './withDefault.js'\n\ntype Args = {\n adapter: DrizzleAdapter\n blocksTableNameMap: Record<string, number>\n columnPrefix?: string\n columns: Record<string, RawColumn>\n disableNotNull: boolean\n disableRelsTableUnique?: boolean\n disableUnique?: boolean\n fieldPrefix?: string\n fields: FlattenedField[]\n forceLocalized?: boolean\n indexes: Record<string, RawIndex>\n localesColumns: Record<string, RawColumn>\n localesIndexes: Record<string, RawIndex>\n newTableName: string\n parentIsLocalized: boolean\n parentTableName: string\n relationships: Set<string>\n relationsToBuild: RelationMap\n rootRelationsToBuild?: RelationMap\n rootTableIDColType: IDType\n rootTableName: string\n setColumnID: SetColumnID\n uniqueRelationships: Set<string>\n versions: boolean\n /**\n * Tracks whether or not this table is built\n * from the result of a localized array or block field at some point\n */\n withinLocalizedArrayOrBlock?: 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 blocksTableNameMap,\n columnPrefix,\n columns,\n disableNotNull,\n disableRelsTableUnique,\n disableUnique = false,\n fieldPrefix,\n fields,\n forceLocalized,\n indexes,\n localesColumns,\n localesIndexes,\n newTableName,\n parentIsLocalized,\n parentTableName,\n relationships,\n relationsToBuild,\n rootRelationsToBuild,\n rootTableIDColType,\n rootTableName,\n setColumnID,\n uniqueRelationships,\n versions,\n withinLocalizedArrayOrBlock,\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\n const idColumn = columns.id\n\n if (idColumn && ['numeric', 'text', 'uuid', 'varchar'].includes(idColumn.type)) {\n parentIDColType = idColumn.type as IDType\n }\n\n fields.forEach((field) => {\n if ('name' in field && field.name === 'id') {\n return\n }\n if (fieldIsVirtual(field)) {\n return\n }\n\n let targetTable = columns\n let targetIndexes = indexes\n\n const columnName = `${columnPrefix || ''}${field.name[0] === '_' ? '_' : ''}${toSnakeCase(\n field.name,\n )}`\n const fieldName = `${fieldPrefix?.replace('.', '_') || ''}${field.name}`\n\n const isFieldLocalized = fieldShouldBeLocalized({ field, parentIsLocalized })\n\n // If field is localized,\n // add the column to the locale table instead of main table\n if (\n adapter.payload.config.localization &&\n (isFieldLocalized || forceLocalized) &&\n field.type !== 'array' &&\n (field.type !== 'blocks' || adapter.blocksAsJSON) &&\n (('hasMany' in field && field.hasMany !== true) || !('hasMany' in field))\n ) {\n hasLocalizedField = true\n targetTable = localesColumns\n targetIndexes = localesIndexes\n }\n\n if (\n (field.unique || field.index || ['relationship', 'upload'].includes(field.type)) &&\n !['array', 'blocks', 'group'].includes(field.type) &&\n !('hasMany' in field && field.hasMany === true) &&\n !('relationTo' in field && Array.isArray(field.relationTo))\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\n const indexName = buildIndexName({ name: `${newTableName}_${columnName}`, adapter })\n\n targetIndexes[indexName] = {\n name: indexName,\n on: isFieldLocalized ? [fieldName, '_locale'] : fieldName,\n unique,\n }\n }\n\n switch (field.type) {\n case 'array': {\n const disableNotNullFromHere = Boolean(field.admin?.condition) || disableNotNull\n\n const arrayTableName = createTableName({\n adapter,\n config: field,\n parentTableName: newTableName,\n prefix: `${newTableName}_`,\n throwValidationError,\n versionsCustomName: versions,\n })\n\n const baseColumns: Record<string, RawColumn> = {\n _order: {\n name: '_order',\n type: 'integer',\n notNull: true,\n },\n _parentID: {\n name: '_parent_id',\n type: parentIDColType,\n notNull: true,\n },\n }\n\n const baseIndexes: Record<string, RawIndex> = {\n _orderIdx: {\n name: `${arrayTableName}_order_idx`,\n on: ['_order'],\n },\n _parentIDIdx: {\n name: `${arrayTableName}_parent_id_idx`,\n on: '_parentID',\n },\n }\n\n const baseForeignKeys: Record<string, RawForeignKey> = {\n _parentIDFk: {\n name: `${arrayTableName}_parent_id_fk`,\n columns: ['_parentID'],\n foreignColumns: [\n {\n name: 'id',\n table: parentTableName,\n },\n ],\n onDelete: 'cascade',\n },\n }\n\n const isLocalized =\n Boolean(isFieldLocalized && adapter.payload.config.localization) ||\n withinLocalizedArrayOrBlock ||\n forceLocalized\n\n if (isLocalized) {\n baseColumns._locale = {\n name: '_locale',\n type: 'enum',\n locale: true,\n notNull: true,\n }\n\n baseIndexes._localeIdx = {\n name: `${arrayTableName}_locale_idx`,\n on: '_locale',\n }\n }\n\n const {\n hasLocalizedManyNumberField: subHasLocalizedManyNumberField,\n hasLocalizedManyTextField: subHasLocalizedManyTextField,\n hasLocalizedRelationshipField: subHasLocalizedRelationshipField,\n hasManyNumberField: subHasManyNumberField,\n hasManyTextField: subHasManyTextField,\n relationsToBuild: subRelationsToBuild,\n } = buildTable({\n adapter,\n baseColumns,\n baseForeignKeys,\n baseIndexes,\n blocksTableNameMap,\n disableNotNull: disableNotNullFromHere,\n disableRelsTableUnique: true,\n disableUnique,\n fields: disableUnique ? idToUUID(field.flattenedFields) : field.flattenedFields,\n parentIsLocalized: parentIsLocalized || field.localized,\n rootRelationships: relationships,\n rootRelationsToBuild,\n rootTableIDColType,\n rootTableName,\n rootUniqueRelationships: uniqueRelationships,\n setColumnID,\n tableName: arrayTableName,\n versions,\n withinLocalizedArrayOrBlock: isLocalized,\n })\n\n if (subHasLocalizedManyNumberField) {\n hasLocalizedManyNumberField = subHasLocalizedManyNumberField\n }\n\n if (subHasLocalizedRelationshipField) {\n hasLocalizedRelationshipField = subHasLocalizedRelationshipField\n }\n\n if (subHasLocalizedManyTextField) {\n hasLocalizedManyTextField = subHasLocalizedManyTextField\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\n const relationName = getArrayRelationName({\n field,\n path: fieldName,\n tableName: arrayTableName,\n })\n\n relationsToBuild.set(relationName, {\n type: 'many',\n // arrays have their own localized table, independent of the base table.\n localized: false,\n target: arrayTableName,\n })\n\n const arrayRelations: Record<string, RawRelation> = {\n _parentID: {\n type: 'one',\n fields: [\n {\n name: '_parentID',\n table: arrayTableName,\n },\n ],\n references: ['id'],\n relationName,\n to: parentTableName,\n },\n }\n\n if (\n hasLocalesTable({\n fields: field.fields,\n parentIsLocalized: parentIsLocalized || field.localized,\n })\n ) {\n arrayRelations._locales = {\n type: 'many',\n relationName: '_locales',\n to: `${arrayTableName}${adapter.localesSuffix}`,\n }\n }\n\n subRelationsToBuild.forEach(({ type, localized, target }, key) => {\n if (type === 'one') {\n const arrayWithLocalized = localized\n ? `${arrayTableName}${adapter.localesSuffix}`\n : arrayTableName\n\n arrayRelations[key] = {\n type: 'one',\n fields: [\n {\n name: key,\n table: arrayWithLocalized,\n },\n ],\n references: ['id'],\n relationName: key,\n to: target,\n }\n }\n\n if (type === 'many') {\n arrayRelations[key] = {\n type: 'many',\n relationName: key,\n to: target,\n }\n }\n })\n\n adapter.rawRelations[arrayTableName] = arrayRelations\n\n break\n }\n case 'blocks': {\n if (adapter.blocksAsJSON) {\n targetTable[fieldName] = withDefault(\n {\n name: columnName,\n type: 'jsonb',\n },\n field,\n )\n break\n }\n\n const disableNotNullFromHere = Boolean(field.admin?.condition) || disableNotNull\n\n field.blocks.forEach((_block) => {\n const block = typeof _block === 'string' ? adapter.payload.blocks[_block] : _block\n\n let blockTableName = createTableName({\n adapter,\n config: block,\n parentTableName: rootTableName,\n prefix: `${rootTableName}_blocks_`,\n throwValidationError,\n versionsCustomName: versions,\n })\n\n const isLocalizedBlockTable =\n Boolean(isFieldLocalized && adapter.payload.config.localization) ||\n withinLocalizedArrayOrBlock ||\n forceLocalized\n\n if (typeof blocksTableNameMap[blockTableName] === 'undefined') {\n blocksTableNameMap[blockTableName] = 1\n } else if (\n !adapter.rawTables[blockTableName] ||\n !validateExistingBlockIsIdentical({\n block,\n localized: isLocalizedBlockTable,\n parentIsLocalized,\n table: adapter.rawTables[blockTableName],\n tableLocales: adapter.rawTables[`${blockTableName}${adapter.localesSuffix}`],\n })\n ) {\n blocksTableNameMap[blockTableName]++\n setInternalBlockIndex(block, blocksTableNameMap[blockTableName])\n blockTableName = `${blockTableName}_${blocksTableNameMap[blockTableName]}`\n }\n let relationName = `_blocks_${block.slug}`\n if (typeof block[InternalBlockTableNameIndex] !== 'undefined') {\n relationName = `_blocks_${block.slug}_${block[InternalBlockTableNameIndex]}`\n }\n\n if (!adapter.rawTables[blockTableName]) {\n const baseColumns: Record<string, RawColumn> = {\n _order: {\n name: '_order',\n type: 'integer',\n notNull: true,\n },\n _parentID: {\n name: '_parent_id',\n type: rootTableIDColType,\n notNull: true,\n },\n _path: {\n name: '_path',\n type: 'text',\n notNull: true,\n },\n }\n\n const baseIndexes: Record<string, RawIndex> = {\n _orderIdx: {\n name: `${blockTableName}_order_idx`,\n on: '_order',\n },\n _parentIDIdx: {\n name: `${blockTableName}_parent_id_idx`,\n on: ['_parentID'],\n },\n _pathIdx: {\n name: `${blockTableName}_path_idx`,\n on: '_path',\n },\n }\n\n const baseForeignKeys: Record<string, RawForeignKey> = {\n _parentIdFk: {\n name: `${blockTableName}_parent_id_fk`,\n columns: ['_parentID'],\n foreignColumns: [\n {\n name: 'id',\n table: rootTableName,\n },\n ],\n onDelete: 'cascade',\n },\n }\n\n if (isLocalizedBlockTable) {\n baseColumns._locale = {\n name: '_locale',\n type: 'enum',\n locale: true,\n notNull: true,\n }\n\n baseIndexes._localeIdx = {\n name: `${blockTableName}_locale_idx`,\n on: '_locale',\n }\n }\n\n const {\n hasLocalizedManyNumberField: subHasLocalizedManyNumberField,\n hasLocalizedManyTextField: subHasLocalizedManyTextField,\n hasLocalizedRelationshipField: subHasLocalizedRelationshipField,\n hasManyNumberField: subHasManyNumberField,\n hasManyTextField: subHasManyTextField,\n relationsToBuild: subRelationsToBuild,\n } = buildTable({\n adapter,\n baseColumns,\n baseForeignKeys,\n baseIndexes,\n blocksTableNameMap,\n disableNotNull: disableNotNullFromHere,\n disableRelsTableUnique: true,\n disableUnique,\n fields: disableUnique ? idToUUID(block.flattenedFields) : block.flattenedFields,\n parentIsLocalized: parentIsLocalized || field.localized,\n rootRelationships: relationships,\n rootRelationsToBuild,\n rootTableIDColType,\n rootTableName,\n rootUniqueRelationships: uniqueRelationships,\n setColumnID,\n tableName: blockTableName,\n versions,\n withinLocalizedArrayOrBlock: isLocalizedBlockTable,\n })\n\n if (subHasLocalizedManyNumberField) {\n hasLocalizedManyNumberField = subHasLocalizedManyNumberField\n }\n\n if (subHasLocalizedRelationshipField) {\n hasLocalizedRelationshipField = subHasLocalizedRelationshipField\n }\n\n if (subHasLocalizedManyTextField) {\n hasLocalizedManyTextField = subHasLocalizedManyTextField\n }\n\n if (subHasManyTextField) {\n if (!hasManyTextField || subHasManyTextField === 'index') {\n hasManyTextField = subHasManyTextField\n }\n }\n\n if (subHasManyNumberField) {\n if (!hasManyNumberField || subHasManyNumberField === 'index') {\n hasManyNumberField = subHasManyNumberField\n }\n }\n\n const blockRelations: Record<string, RawRelation> = {\n _parentID: {\n type: 'one',\n fields: [\n {\n name: '_parentID',\n table: blockTableName,\n },\n ],\n references: ['id'],\n relationName,\n to: rootTableName,\n },\n }\n\n if (\n hasLocalesTable({\n fields: block.fields,\n parentIsLocalized: parentIsLocalized || field.localized,\n })\n ) {\n blockRelations._locales = {\n type: 'many',\n relationName: '_locales',\n to: `${blockTableName}${adapter.localesSuffix}`,\n }\n }\n\n subRelationsToBuild.forEach(({ type, localized, target }, key) => {\n if (type === 'one') {\n const blockWithLocalized = localized\n ? `${blockTableName}${adapter.localesSuffix}`\n : blockTableName\n\n blockRelations[key] = {\n type: 'one',\n fields: [\n {\n name: key,\n table: blockWithLocalized,\n },\n ],\n references: ['id'],\n relationName: key,\n to: target,\n }\n }\n\n if (type === 'many') {\n blockRelations[key] = {\n type: 'many',\n relationName: key,\n to: target,\n }\n }\n })\n\n adapter.rawRelations[blockTableName] = blockRelations\n }\n\n // blocks relationships are defined from the collection or globals table down to the block, bypassing any subBlocks\n rootRelationsToBuild.set(relationName, {\n type: 'many',\n // blocks are not localized on the parent table\n localized: false,\n target: blockTableName,\n })\n })\n\n break\n }\n case 'checkbox': {\n targetTable[fieldName] = withDefault(\n {\n name: columnName,\n type: 'boolean',\n },\n field,\n )\n\n break\n }\n\n case 'code':\n case 'email':\n case 'slug':\n case 'textarea': {\n targetTable[fieldName] = withDefault(\n {\n name: columnName,\n type: 'varchar',\n },\n field,\n )\n\n break\n }\n\n case 'date': {\n targetTable[fieldName] = withDefault(\n {\n name: columnName,\n type: 'timestamp',\n mode: 'string',\n precision: 3,\n withTimezone: true,\n },\n field,\n )\n\n break\n }\n\n case 'group':\n case 'tab': {\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 blocksTableNameMap,\n columnPrefix: `${columnName}_`,\n columns,\n disableNotNull: disableNotNullFromHere,\n disableUnique,\n fieldPrefix: `${fieldName}.`,\n fields: field.flattenedFields,\n forceLocalized: isFieldLocalized || Boolean(forceLocalized),\n indexes,\n localesColumns,\n localesIndexes,\n newTableName: `${parentTableName}_${columnName}`,\n parentIsLocalized: parentIsLocalized || field.localized,\n parentTableName,\n relationships,\n relationsToBuild,\n rootRelationsToBuild,\n rootTableIDColType,\n rootTableName,\n setColumnID,\n uniqueRelationships,\n versions,\n withinLocalizedArrayOrBlock: withinLocalizedArrayOrBlock || isFieldLocalized,\n })\n\n if (groupHasLocalizedField) {\n hasLocalizedField = true\n }\n if (groupHasLocalizedRelationshipField) {\n hasLocalizedRelationshipField = true\n }\n if (groupHasManyTextField) {\n hasManyTextField = true\n }\n if (groupHasLocalizedManyTextField) {\n hasLocalizedManyTextField = true\n }\n if (groupHasManyNumberField) {\n hasManyNumberField = true\n }\n if (groupHasLocalizedManyNumberField) {\n hasLocalizedManyNumberField = true\n }\n break\n }\n\n case 'json':\n case 'richText': {\n targetTable[fieldName] = withDefault(\n {\n name: columnName,\n type: 'jsonb',\n },\n field,\n )\n\n break\n }\n\n case 'number': {\n if (field.hasMany) {\n const isLocalized =\n Boolean(isFieldLocalized && adapter.payload.config.localization) ||\n withinLocalizedArrayOrBlock ||\n forceLocalized\n\n if (isLocalized) {\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] = withDefault(\n {\n name: columnName,\n type: 'numeric',\n },\n field,\n )\n }\n\n break\n }\n\n case 'point': {\n targetTable[fieldName] = withDefault(\n {\n name: columnName,\n type: 'geometry',\n },\n field,\n )\n\n break\n }\n\n case 'radio':\n case 'select': {\n const enumName = createTableName({\n adapter,\n config: field,\n parentTableName: newTableName,\n prefix: `enum_${newTableName}_`,\n target: 'enumName',\n throwValidationError,\n })\n\n const options = field.options.map((option) => {\n if (optionIsObject(option)) {\n return option.value\n }\n\n return option\n })\n\n if (field.type === 'select' && field.hasMany) {\n const selectTableName = createTableName({\n adapter,\n config: field,\n parentTableName: newTableName,\n prefix: `${newTableName}_`,\n throwValidationError,\n versionsCustomName: versions,\n })\n\n const baseColumns: Record<string, RawColumn> = {\n order: {\n name: 'order',\n type: 'integer',\n notNull: true,\n },\n parent: {\n name: 'parent_id',\n type: parentIDColType,\n notNull: true,\n },\n value: {\n name: 'value',\n type: 'enum',\n enumName: createTableName({\n adapter,\n config: field,\n parentTableName: newTableName,\n prefix: `enum_${newTableName}_`,\n target: 'enumName',\n throwValidationError,\n }),\n options,\n },\n }\n\n const baseIndexes: Record<string, RawIndex> = {\n orderIdx: {\n name: `${selectTableName}_order_idx`,\n on: 'order',\n },\n parentIdx: {\n name: `${selectTableName}_parent_idx`,\n on: 'parent',\n },\n }\n\n const baseForeignKeys: Record<string, RawForeignKey> = {\n parentFk: {\n name: `${selectTableName}_parent_fk`,\n columns: ['parent'],\n foreignColumns: [\n {\n name: 'id',\n table: parentTableName,\n },\n ],\n onDelete: 'cascade',\n },\n }\n\n const isLocalized =\n Boolean(isFieldLocalized && adapter.payload.config.localization) ||\n withinLocalizedArrayOrBlock ||\n forceLocalized\n\n if (isLocalized) {\n baseColumns.locale = {\n name: 'locale',\n type: 'enum',\n locale: true,\n notNull: true,\n }\n\n baseIndexes.localeIdx = {\n name: `${selectTableName}_locale_idx`,\n on: 'locale',\n }\n }\n\n if (field.index) {\n baseIndexes.value = {\n name: `${selectTableName}_value_idx`,\n on: 'value',\n }\n }\n\n buildTable({\n adapter,\n baseColumns,\n baseForeignKeys,\n baseIndexes,\n blocksTableNameMap,\n disableNotNull,\n disableUnique,\n fields: [],\n parentIsLocalized: parentIsLocalized || field.localized,\n rootTableName,\n setColumnID,\n tableName: selectTableName,\n versions,\n })\n\n relationsToBuild.set(fieldName, {\n type: 'many',\n // selects have their own localized table, independent of the base table.\n localized: false,\n target: selectTableName,\n })\n\n adapter.rawRelations[selectTableName] = {\n parent: {\n type: 'one',\n fields: [\n {\n name: 'parent',\n table: selectTableName,\n },\n ],\n references: ['id'],\n relationName: fieldName,\n to: parentTableName,\n },\n }\n } else {\n targetTable[fieldName] = withDefault(\n {\n name: columnName,\n type: 'enum',\n enumName,\n options,\n },\n field,\n )\n }\n break\n }\n\n case 'relationship':\n case 'upload':\n if (Array.isArray(field.relationTo)) {\n field.relationTo.forEach((relation) => {\n relationships.add(relation)\n if (field.unique && !disableUnique && !disableRelsTableUnique) {\n uniqueRelationships.add(relation)\n }\n })\n } else if (field.hasMany) {\n relationships.add(field.relationTo)\n if (field.unique && !disableUnique && !disableRelsTableUnique) {\n uniqueRelationships.add(field.relationTo)\n }\n } else {\n // simple relationships get a column on the targetTable with a foreign key to the relationTo table\n const relationshipConfig = adapter.payload.collections[field.relationTo].config\n\n const tableName = adapter.tableNameMap.get(toSnakeCase(field.relationTo))\n\n // get the id type of the related collection\n let colType: IDType = isUUIDType(adapter.idType) ? 'uuid' : 'integer'\n const relatedCollectionCustomID = relationshipConfig.fields.find(\n (field) => fieldAffectsData(field) && field.name === 'id',\n )\n if (relatedCollectionCustomID?.type === 'number') {\n colType = 'numeric'\n }\n if (relatedCollectionCustomID?.type === 'text') {\n colType = 'varchar'\n }\n\n // make the foreign key column for relationship using the correct id column type\n targetTable[fieldName] = {\n name: `${columnName}_id`,\n type: colType,\n reference: {\n name: 'id',\n onDelete: 'set null',\n table: tableName,\n },\n }\n\n // add relationship to table\n relationsToBuild.set(fieldName, {\n type: 'one',\n localized: adapter.payload.config.localization && (isFieldLocalized || forceLocalized),\n target: tableName,\n })\n\n // add notNull when not required\n if (!disableNotNull && field.required && !field.admin?.condition) {\n targetTable[fieldName].notNull = true\n }\n break\n }\n\n if (\n Boolean(isFieldLocalized && adapter.payload.config.localization) ||\n withinLocalizedArrayOrBlock\n ) {\n hasLocalizedRelationshipField = true\n }\n\n break\n\n case 'text': {\n if (field.hasMany) {\n const isLocalized =\n Boolean(isFieldLocalized && adapter.payload.config.localization) ||\n withinLocalizedArrayOrBlock ||\n forceLocalized\n\n if (isLocalized) {\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] = withDefault(\n {\n name: columnName,\n type: 'varchar',\n },\n field,\n )\n }\n break\n }\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 = true\n }\n })\n\n return {\n hasLocalizedField,\n hasLocalizedManyNumberField,\n hasLocalizedManyTextField,\n hasLocalizedRelationshipField,\n hasManyNumberField,\n hasManyTextField,\n }\n}\n"],"names":["InvalidConfiguration","fieldAffectsData","fieldIsVirtual","fieldShouldBeLocalized","optionIsObject","toSnakeCase","createTableName","buildIndexName","getArrayRelationName","hasLocalesTable","isUUIDType","InternalBlockTableNameIndex","setInternalBlockIndex","validateExistingBlockIsIdentical","buildTable","idToUUID","withDefault","traverseFields","adapter","blocksTableNameMap","columnPrefix","columns","disableNotNull","disableRelsTableUnique","disableUnique","fieldPrefix","fields","forceLocalized","indexes","localesColumns","localesIndexes","newTableName","parentIsLocalized","parentTableName","relationships","relationsToBuild","rootRelationsToBuild","rootTableIDColType","rootTableName","setColumnID","uniqueRelationships","versions","withinLocalizedArrayOrBlock","throwValidationError","hasLocalizedField","hasLocalizedRelationshipField","hasManyTextField","hasLocalizedManyTextField","hasManyNumberField","hasLocalizedManyNumberField","parentIDColType","idColumn","id","includes","type","forEach","field","name","targetTable","targetIndexes","columnName","fieldName","replace","isFieldLocalized","payload","config","localization","blocksAsJSON","hasMany","unique","index","Array","isArray","relationTo","constraintValue","fieldConstraints","indexName","on","disableNotNullFromHere","Boolean","admin","condition","arrayTableName","prefix","versionsCustomName","baseColumns","_order","notNull","_parentID","baseIndexes","_orderIdx","_parentIDIdx","baseForeignKeys","_parentIDFk","foreignColumns","table","onDelete","isLocalized","_locale","locale","_localeIdx","subHasLocalizedManyNumberField","subHasLocalizedManyTextField","subHasLocalizedRelationshipField","subHasManyNumberField","subHasManyTextField","subRelationsToBuild","flattenedFields","localized","rootRelationships","rootUniqueRelationships","tableName","relationName","path","set","target","arrayRelations","references","to","_locales","localesSuffix","key","arrayWithLocalized","rawRelations","blocks","_block","block","blockTableName","isLocalizedBlockTable","rawTables","tableLocales","slug","_path","_pathIdx","_parentIdFk","blockRelations","blockWithLocalized","mode","precision","withTimezone","groupHasLocalizedField","groupHasLocalizedManyNumberField","groupHasLocalizedManyTextField","groupHasLocalizedRelationshipField","groupHasManyNumberField","groupHasManyTextField","enumName","options","map","option","value","selectTableName","order","parent","orderIdx","parentIdx","parentFk","localeIdx","relation","add","relationshipConfig","collections","tableNameMap","get","colType","idType","relatedCollectionCustomID","find","reference","required"],"mappings":"AAEA,SAASA,oBAAoB,QAAQ,UAAS;AAC9C,SACEC,gBAAgB,EAChBC,cAAc,EACdC,sBAAsB,EACtBC,cAAc,QACT,iBAAgB;AACvB,OAAOC,iBAAiB,gBAAe;AAavC,SAASC,eAAe,QAAQ,wBAAuB;AACvD,SAASC,cAAc,QAAQ,iCAAgC;AAC/D,SAASC,oBAAoB,QAAQ,uCAAsC;AAC3E,SAASC,eAAe,QAAQ,kCAAiC;AACjE,SAASC,UAAU,QAAQ,6BAA4B;AACvD,SACEC,2BAA2B,EAC3BC,qBAAqB,EACrBC,gCAAgC,QAC3B,mDAAkD;AACzD,SAASC,UAAU,QAAQ,aAAY;AACvC,SAASC,QAAQ,QAAQ,gBAAe;AACxC,SAASC,WAAW,QAAQ,mBAAkB;AA2C9C,O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AEA,IACER,QAAQhB,oBAAoB7C,QAAQ8C,OAAO,CAACC,MAAM,CAACC,YAAY,KAC/DxB,6BACA;oBACAG,gCAAgC;gBAClC;gBAEA;YAEF,KAAK;gBAAQ;oBACX,IAAIW,MAAMY,OAAO,EAAE;wBACjB,MAAM6B,cACJlB,QAAQhB,oBAAoB7C,QAAQ8C,OAAO,CAACC,MAAM,CAACC,YAAY,KAC/DxB,+BACAf;wBAEF,IAAIsE,aAAa;4BACflD,4BAA4B;wBAC9B;wBAEA,IAAIS,MAAMc,KAAK,EAAE;4BACfxB,mBAAmB;wBACrB,OAAO,IAAI,CAACA,kBAAkB;4BAC5BA,mBAAmB;wBACrB;wBAEA,IAAIU,MAAMa,MAAM,EAAE;4BAChB,MAAM,IAAIrE,qBACR;wBAEJ;oBACF,OAAO;wBACL0D,WAAW,CAACG,UAAU,GAAG7C,YACvB;4BACEyC,MAAMG;4BACNN,MAAM;wBACR,GACAE;oBAEJ;oBACA;gBACF;YAEA;gBACE;QACJ;QAEA,MAAMyB,YAAYzB,MAAMwB,KAAK,IAAIxB,MAAMwB,KAAK,CAACC,SAAS;QAEtD,IACE,CAAC3D,kBACDoC,WAAW,CAACG,UAAU,IACtB,cAAcL,SACdA,MAAMiH,QAAQ,IACd,CAACxF,WACD;YACAvB,WAAW,CAACG,UAAU,CAAC0B,OAAO,GAAG;QACnC;IACF;IAEA,OAAO;QACL3C;QACAK;QACAF;QACAF;QACAG;QACAF;IACF;AACF,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withDefault.d.ts","sourceRoot":"","sources":["../../src/schema/withDefault.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAEjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAE5C,eAAO,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"withDefault.d.ts","sourceRoot":"","sources":["../../src/schema/withDefault.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAEjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAE5C,eAAO,MAAM,WAAW,WAAY,SAAS,SAAS,kBAAkB,KAAG,SAS1E,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convertPathToJSONTraversal.d.ts","sourceRoot":"","sources":["../../../src/sqlite/createJSONQuery/convertPathToJSONTraversal.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,0BAA0B,
|
|
1
|
+
{"version":3,"file":"convertPathToJSONTraversal.d.ts","sourceRoot":"","sources":["../../../src/sqlite/createJSONQuery/convertPathToJSONTraversal.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,0BAA0B,qBAAsB,MAAM,EAAE,KAAG,MAWvE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/sqlite/createJSONQuery/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AA8GzD,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/sqlite/createJSONQuery/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AA8GzD,eAAO,MAAM,eAAe,iGASzB,mBAAmB,KAAG,MA0BxB,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { RequireDrizzleKit } from '../types.js';
|
|
2
|
+
export declare const createRequireDrizzleKit: ({ from, }: {
|
|
3
|
+
/** Module URL of the adapter that owns the drizzle-kit dependency. */
|
|
4
|
+
from: string;
|
|
5
|
+
}) => RequireDrizzleKit;
|
|
6
|
+
//# sourceMappingURL=createRequireDrizzleKit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createRequireDrizzleKit.d.ts","sourceRoot":"","sources":["../../src/sqlite/createRequireDrizzleKit.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAEpD,eAAO,MAAM,uBAAuB,cAG/B;IACD,sEAAsE;IACtE,IAAI,EAAE,MAAM,CAAA;CACb,KAAG,iBAeH,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import nodeModule from 'node:module';
|
|
2
|
+
import { dynamicImport } from 'payload';
|
|
3
|
+
export const createRequireDrizzleKit = ({ from })=>async ()=>{
|
|
4
|
+
// Use the default import to preserve Node's loader instead of Webpack's createRequire transform.
|
|
5
|
+
const require = nodeModule.createRequire(from);
|
|
6
|
+
const { generateSQLiteDrizzleJson, generateSQLiteMigration, pushSQLiteSchema } = await dynamicImport(require.resolve('drizzle-kit/api'));
|
|
7
|
+
return {
|
|
8
|
+
generateDrizzleJson: generateSQLiteDrizzleJson,
|
|
9
|
+
generateMigration: generateSQLiteMigration,
|
|
10
|
+
// Drizzle Kit bundles separate ORM types; the owning adapter selects the matching dialect.
|
|
11
|
+
pushSchema: pushSQLiteSchema
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=createRequireDrizzleKit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/sqlite/createRequireDrizzleKit.ts"],"sourcesContent":["import type * as DrizzleKit from 'drizzle-kit/api'\n\nimport nodeModule from 'node:module'\nimport { dynamicImport } from 'payload'\n\nimport type { RequireDrizzleKit } from '../types.js'\n\nexport const createRequireDrizzleKit =\n ({\n from,\n }: {\n /** Module URL of the adapter that owns the drizzle-kit dependency. */\n from: string\n }): RequireDrizzleKit =>\n async () => {\n // Use the default import to preserve Node's loader instead of Webpack's createRequire transform.\n const require = nodeModule.createRequire(from)\n const { generateSQLiteDrizzleJson, generateSQLiteMigration, pushSQLiteSchema } =\n await dynamicImport<typeof DrizzleKit>(require.resolve('drizzle-kit/api'))\n\n return {\n generateDrizzleJson: generateSQLiteDrizzleJson,\n generateMigration: generateSQLiteMigration,\n // Drizzle Kit bundles separate ORM types; the owning adapter selects the matching dialect.\n pushSchema: pushSQLiteSchema as unknown as Awaited<\n ReturnType<RequireDrizzleKit>\n >['pushSchema'],\n }\n }\n"],"names":["nodeModule","dynamicImport","createRequireDrizzleKit","from","require","createRequire","generateSQLiteDrizzleJson","generateSQLiteMigration","pushSQLiteSchema","resolve","generateDrizzleJson","generateMigration","pushSchema"],"mappings":"AAEA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,aAAa,QAAQ,UAAS;AAIvC,OAAO,MAAMC,0BACX,CAAC,EACCC,IAAI,EAIL,GACD;QACE,iGAAiG;QACjG,MAAMC,UAAUJ,WAAWK,aAAa,CAACF;QACzC,MAAM,EAAEG,yBAAyB,EAAEC,uBAAuB,EAAEC,gBAAgB,EAAE,GAC5E,MAAMP,cAAiCG,QAAQK,OAAO,CAAC;QAEzD,OAAO;YACLC,qBAAqBJ;YACrBK,mBAAmBJ;YACnB,2FAA2F;YAC3FK,YAAYJ;QAGd;IACF,EAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { mkdirSync, mkdtempSync, realpathSync, rmSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import nodeModule from 'node:module';
|
|
3
|
+
import { tmpdir } from 'node:os';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { pathToFileURL } from 'node:url';
|
|
6
|
+
import { afterEach, describe, expect, it } from 'vitest';
|
|
7
|
+
import { createRequireDrizzleKit as createPostgresRequireDrizzleKit } from '../postgres/requireDrizzleKit.js';
|
|
8
|
+
import { createRequireDrizzleKit as createSQLiteRequireDrizzleKit } from './createRequireDrizzleKit.js';
|
|
9
|
+
const directories = [];
|
|
10
|
+
afterEach(()=>{
|
|
11
|
+
const require = nodeModule.createRequire(import.meta.url);
|
|
12
|
+
for (const directory of directories.splice(0)){
|
|
13
|
+
for (const filename of Object.keys(require.cache)){
|
|
14
|
+
if (filename.startsWith(`${directory}${path.sep}`)) {
|
|
15
|
+
delete require.cache[filename];
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
rmSync(directory, {
|
|
19
|
+
force: true,
|
|
20
|
+
recursive: true
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
describe.each([
|
|
25
|
+
{
|
|
26
|
+
createRequireDrizzleKit: createSQLiteRequireDrizzleKit,
|
|
27
|
+
dialect: 'sqlite'
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
createRequireDrizzleKit: createPostgresRequireDrizzleKit,
|
|
31
|
+
dialect: 'postgres'
|
|
32
|
+
}
|
|
33
|
+
])('createRequireDrizzleKit ($dialect)', ({ createRequireDrizzleKit, dialect })=>{
|
|
34
|
+
it('should lazily resolve tooling from each owning adapter', async ()=>{
|
|
35
|
+
for(let index = 0; index < 2; index++){
|
|
36
|
+
const directory = createDirectory();
|
|
37
|
+
const load = createRequireDrizzleKit({
|
|
38
|
+
from: pathToFileURL(path.join(directory, 'adapter.js')).href
|
|
39
|
+
});
|
|
40
|
+
await expect(load()).rejects.toThrow(/drizzle-kit/);
|
|
41
|
+
installTooling({
|
|
42
|
+
dialect,
|
|
43
|
+
directory
|
|
44
|
+
});
|
|
45
|
+
expect((await load()).generateDrizzleJson({})).toEqual({
|
|
46
|
+
dialect,
|
|
47
|
+
source: directory
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
function createDirectory() {
|
|
53
|
+
const directory = realpathSync(mkdtempSync(path.join(tmpdir(), 'payload-kit-loader-')));
|
|
54
|
+
directories.push(directory);
|
|
55
|
+
return directory;
|
|
56
|
+
}
|
|
57
|
+
function installTooling({ dialect, directory }) {
|
|
58
|
+
const packageDirectory = path.join(directory, 'node_modules', 'drizzle-kit');
|
|
59
|
+
mkdirSync(packageDirectory, {
|
|
60
|
+
recursive: true
|
|
61
|
+
});
|
|
62
|
+
writeFileSync(path.join(packageDirectory, 'package.json'), JSON.stringify({
|
|
63
|
+
exports: {
|
|
64
|
+
'./api': './api.cjs'
|
|
65
|
+
},
|
|
66
|
+
name: 'drizzle-kit'
|
|
67
|
+
}));
|
|
68
|
+
writeFileSync(path.join(packageDirectory, 'api.cjs'), `exports.${dialect === 'sqlite' ? 'generateSQLiteDrizzleJson' : 'generateDrizzleJson'} = () => ({ dialect: ${JSON.stringify(dialect)}, source: ${JSON.stringify(directory)} })`);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
//# sourceMappingURL=createRequireDrizzleKit.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/sqlite/createRequireDrizzleKit.spec.ts"],"sourcesContent":["import { mkdirSync, mkdtempSync, realpathSync, rmSync, writeFileSync } from 'node:fs'\nimport nodeModule from 'node:module'\nimport { tmpdir } from 'node:os'\nimport path from 'node:path'\nimport { pathToFileURL } from 'node:url'\nimport { afterEach, describe, expect, it } from 'vitest'\n\nimport { createRequireDrizzleKit as createPostgresRequireDrizzleKit } from '../postgres/requireDrizzleKit.js'\nimport { createRequireDrizzleKit as createSQLiteRequireDrizzleKit } from './createRequireDrizzleKit.js'\n\nconst directories: string[] = []\n\nafterEach(() => {\n const require = nodeModule.createRequire(import.meta.url)\n\n for (const directory of directories.splice(0)) {\n for (const filename of Object.keys(require.cache)) {\n if (filename.startsWith(`${directory}${path.sep}`)) {\n delete require.cache[filename]\n }\n }\n rmSync(directory, { force: true, recursive: true })\n }\n})\n\ndescribe.each([\n { createRequireDrizzleKit: createSQLiteRequireDrizzleKit, dialect: 'sqlite' },\n { createRequireDrizzleKit: createPostgresRequireDrizzleKit, dialect: 'postgres' },\n])('createRequireDrizzleKit ($dialect)', ({ createRequireDrizzleKit, dialect }) => {\n it('should lazily resolve tooling from each owning adapter', async () => {\n for (let index = 0; index < 2; index++) {\n const directory = createDirectory()\n const load = createRequireDrizzleKit({\n from: pathToFileURL(path.join(directory, 'adapter.js')).href,\n })\n\n await expect(load()).rejects.toThrow(/drizzle-kit/)\n installTooling({ dialect, directory })\n\n expect((await load()).generateDrizzleJson({})).toEqual({ dialect, source: directory })\n }\n })\n})\n\nfunction createDirectory() {\n const directory = realpathSync(mkdtempSync(path.join(tmpdir(), 'payload-kit-loader-')))\n\n directories.push(directory)\n return directory\n}\n\nfunction installTooling({ dialect, directory }: { dialect: string; directory: string }) {\n const packageDirectory = path.join(directory, 'node_modules', 'drizzle-kit')\n\n mkdirSync(packageDirectory, { recursive: true })\n writeFileSync(\n path.join(packageDirectory, 'package.json'),\n JSON.stringify({ exports: { './api': './api.cjs' }, name: 'drizzle-kit' }),\n )\n writeFileSync(\n path.join(packageDirectory, 'api.cjs'),\n `exports.${dialect === 'sqlite' ? 'generateSQLiteDrizzleJson' : 'generateDrizzleJson'} = () => ({ dialect: ${JSON.stringify(dialect)}, source: ${JSON.stringify(directory)} })`,\n )\n}\n"],"names":["mkdirSync","mkdtempSync","realpathSync","rmSync","writeFileSync","nodeModule","tmpdir","path","pathToFileURL","afterEach","describe","expect","it","createRequireDrizzleKit","createPostgresRequireDrizzleKit","createSQLiteRequireDrizzleKit","directories","require","createRequire","url","directory","splice","filename","Object","keys","cache","startsWith","sep","force","recursive","each","dialect","index","createDirectory","load","from","join","href","rejects","toThrow","installTooling","generateDrizzleJson","toEqual","source","push","packageDirectory","JSON","stringify","exports","name"],"mappings":"AAAA,SAASA,SAAS,EAAEC,WAAW,EAAEC,YAAY,EAAEC,MAAM,EAAEC,aAAa,QAAQ,UAAS;AACrF,OAAOC,gBAAgB,cAAa;AACpC,SAASC,MAAM,QAAQ,UAAS;AAChC,OAAOC,UAAU,YAAW;AAC5B,SAASC,aAAa,QAAQ,WAAU;AACxC,SAASC,SAAS,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,SAAQ;AAExD,SAAS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ASoB,eAAe,EAAET,OAAO,EAAEX,SAAS,EAA0C;IACpF,MAAMyB,mBAAmBtC,KAAK6B,IAAI,CAAChB,WAAW,gBAAgB;IAE9DpB,UAAU6C,kBAAkB;QAAEhB,WAAW;IAAK;IAC9CzB,cACEG,KAAK6B,IAAI,CAACS,kBAAkB,iBAC5BC,KAAKC,SAAS,CAAC;QAAEC,SAAS;YAAE,SAAS;QAAY;QAAGC,MAAM;IAAc;IAE1E7C,cACEG,KAAK6B,IAAI,CAACS,kBAAkB,YAC5B,CAAC,QAAQ,EAAEd,YAAY,WAAW,8BAA8B,sBAAsB,qBAAqB,EAAEe,KAAKC,SAAS,CAAChB,SAAS,UAAU,EAAEe,KAAKC,SAAS,CAAC3B,WAAW,GAAG,CAAC;AAEnL"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { build } from 'esbuild';
|
|
2
|
+
import { execFileSync } from 'node:child_process';
|
|
3
|
+
import { mkdtempSync, rmSync, writeFileSync } from 'node:fs';
|
|
4
|
+
import { tmpdir } from 'node:os';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
7
|
+
import { afterEach, describe, expect, it } from 'vitest';
|
|
8
|
+
const workspaceDirectory = fileURLToPath(new URL('../../../../', import.meta.url));
|
|
9
|
+
const temporaryDirectories = [];
|
|
10
|
+
afterEach(()=>{
|
|
11
|
+
for (const directory of temporaryDirectories.splice(0)){
|
|
12
|
+
rmSync(directory, {
|
|
13
|
+
force: true,
|
|
14
|
+
recursive: true
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
describe('Drizzle Kit tooling in Node', ()=>{
|
|
19
|
+
it.each([
|
|
20
|
+
'db-sqlite',
|
|
21
|
+
'db-postgres'
|
|
22
|
+
])('should resolve real tooling from %s outside Vitest and generate schema changes', async (adapter)=>{
|
|
23
|
+
const directory = mkdtempSync(path.join(tmpdir(), 'payload-drizzle-tooling-'));
|
|
24
|
+
temporaryDirectories.push(directory);
|
|
25
|
+
const isSQLite = adapter === 'db-sqlite';
|
|
26
|
+
// Exercise the real loader outside Vitest.
|
|
27
|
+
await build({
|
|
28
|
+
alias: {
|
|
29
|
+
payload: path.join(workspaceDirectory, 'packages/payload/src/utilities/dynamicImport.ts')
|
|
30
|
+
},
|
|
31
|
+
bundle: true,
|
|
32
|
+
entryPoints: [
|
|
33
|
+
path.join(workspaceDirectory, isSQLite ? 'packages/drizzle/src/sqlite/createRequireDrizzleKit.ts' : 'packages/drizzle/src/postgres/requireDrizzleKit.ts')
|
|
34
|
+
],
|
|
35
|
+
format: 'esm',
|
|
36
|
+
logLevel: 'silent',
|
|
37
|
+
outfile: path.join(directory, 'tooling.mjs'),
|
|
38
|
+
platform: 'node'
|
|
39
|
+
});
|
|
40
|
+
const from = pathToFileURL(path.join(workspaceDirectory, 'packages', adapter, 'src/index.ts')).href;
|
|
41
|
+
const script = path.join(directory, 'check.mjs');
|
|
42
|
+
writeFileSync(script, `
|
|
43
|
+
import assert from 'node:assert/strict'
|
|
44
|
+
import { createRequire } from 'node:module'
|
|
45
|
+
import { createRequireDrizzleKit } from './tooling.mjs'
|
|
46
|
+
const require = createRequire(${JSON.stringify(from)})
|
|
47
|
+
assert.equal(process.env.VITEST, undefined)
|
|
48
|
+
const tooling = await createRequireDrizzleKit({ from: ${JSON.stringify(from)} })()
|
|
49
|
+
${isSQLite ? "const { sqliteTable, integer } = require('drizzle-orm/sqlite-core')" : "const { pgTable, integer: pgInteger } = require('drizzle-orm/pg-core')"}
|
|
50
|
+
const schema = ${isSQLite ? "{ probe: sqliteTable('probe', { id: integer('id').primaryKey() }) }" : "{ probe: pgTable('probe', { id: pgInteger('id').primaryKey() }) }"}
|
|
51
|
+
const before = await tooling.generateDrizzleJson({})
|
|
52
|
+
const after = await tooling.generateDrizzleJson(schema)
|
|
53
|
+
const statements = await tooling.generateMigration(before, after)
|
|
54
|
+
assert.ok(statements.some(sql => sql.includes('CREATE TABLE')))
|
|
55
|
+
if (${isSQLite}) {
|
|
56
|
+
const { createClient } = require('@libsql/client')
|
|
57
|
+
const { drizzle } = require('drizzle-orm/libsql')
|
|
58
|
+
const client = createClient({ url: 'file::memory:' })
|
|
59
|
+
try {
|
|
60
|
+
const pushed = await tooling.pushSchema(schema, drizzle(client))
|
|
61
|
+
await pushed.apply()
|
|
62
|
+
await client.execute('INSERT INTO probe (id) VALUES (42)')
|
|
63
|
+
const result = await client.execute('SELECT id FROM probe')
|
|
64
|
+
assert.equal(result.rows[0].id, 42)
|
|
65
|
+
} finally {
|
|
66
|
+
client.close()
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
console.log('schema tooling passed')
|
|
70
|
+
`);
|
|
71
|
+
const env = {
|
|
72
|
+
...process.env
|
|
73
|
+
};
|
|
74
|
+
delete env.VITEST;
|
|
75
|
+
const output = execFileSync(process.execPath, [
|
|
76
|
+
script
|
|
77
|
+
], {
|
|
78
|
+
encoding: 'utf8',
|
|
79
|
+
env,
|
|
80
|
+
timeout: 30_000
|
|
81
|
+
});
|
|
82
|
+
expect(output).toContain('schema tooling passed');
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
//# sourceMappingURL=drizzleKitTooling.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/sqlite/drizzleKitTooling.spec.ts"],"sourcesContent":["import { build } from 'esbuild'\nimport { execFileSync } from 'node:child_process'\nimport { mkdtempSync, rmSync, writeFileSync } from 'node:fs'\nimport { tmpdir } from 'node:os'\nimport path from 'node:path'\nimport { fileURLToPath, pathToFileURL } from 'node:url'\nimport { afterEach, describe, expect, it } from 'vitest'\n\nconst workspaceDirectory = fileURLToPath(new URL('../../../../', import.meta.url))\nconst temporaryDirectories: string[] = []\n\nafterEach(() => {\n for (const directory of temporaryDirectories.splice(0)) {\n rmSync(directory, { force: true, recursive: true })\n }\n})\n\ndescribe('Drizzle Kit tooling in Node', () => {\n it.each(['db-sqlite', 'db-postgres'])(\n 'should resolve real tooling from %s outside Vitest and generate schema changes',\n async (adapter) => {\n const directory = mkdtempSync(path.join(tmpdir(), 'payload-drizzle-tooling-'))\n temporaryDirectories.push(directory)\n\n const isSQLite = adapter === 'db-sqlite'\n\n // Exercise the real loader outside Vitest.\n await build({\n alias: {\n payload: path.join(workspaceDirectory, 'packages/payload/src/utilities/dynamicImport.ts'),\n },\n bundle: true,\n entryPoints: [\n path.join(\n workspaceDirectory,\n isSQLite\n ? 'packages/drizzle/src/sqlite/createRequireDrizzleKit.ts'\n : 'packages/drizzle/src/postgres/requireDrizzleKit.ts',\n ),\n ],\n format: 'esm',\n logLevel: 'silent',\n outfile: path.join(directory, 'tooling.mjs'),\n platform: 'node',\n })\n\n const from = pathToFileURL(\n path.join(workspaceDirectory, 'packages', adapter, 'src/index.ts'),\n ).href\n const script = path.join(directory, 'check.mjs')\n\n writeFileSync(\n script,\n `\nimport assert from 'node:assert/strict'\nimport { createRequire } from 'node:module'\nimport { createRequireDrizzleKit } from './tooling.mjs'\nconst require = createRequire(${JSON.stringify(from)})\nassert.equal(process.env.VITEST, undefined)\nconst tooling = await createRequireDrizzleKit({ from: ${JSON.stringify(from)} })()\n${\n isSQLite\n ? \"const { sqliteTable, integer } = require('drizzle-orm/sqlite-core')\"\n : \"const { pgTable, integer: pgInteger } = require('drizzle-orm/pg-core')\"\n}\nconst schema = ${\n isSQLite\n ? \"{ probe: sqliteTable('probe', { id: integer('id').primaryKey() }) }\"\n : \"{ probe: pgTable('probe', { id: pgInteger('id').primaryKey() }) }\"\n }\nconst before = await tooling.generateDrizzleJson({})\nconst after = await tooling.generateDrizzleJson(schema)\nconst statements = await tooling.generateMigration(before, after)\nassert.ok(statements.some(sql => sql.includes('CREATE TABLE')))\nif (${isSQLite}) {\nconst { createClient } = require('@libsql/client')\nconst { drizzle } = require('drizzle-orm/libsql')\nconst client = createClient({ url: 'file::memory:' })\ntry {\n const pushed = await tooling.pushSchema(schema, drizzle(client))\n await pushed.apply()\n await client.execute('INSERT INTO probe (id) VALUES (42)')\n const result = await client.execute('SELECT id FROM probe')\n assert.equal(result.rows[0].id, 42)\n} finally {\n client.close()\n}\n}\nconsole.log('schema tooling passed')\n`,\n )\n\n const env = { ...process.env }\n delete env.VITEST\n\n const output = execFileSync(process.execPath, [script], {\n encoding: 'utf8',\n env,\n timeout: 30_000,\n })\n\n expect(output).toContain('schema tooling passed')\n },\n )\n})\n"],"names":["build","execFileSync","mkdtempSync","rmSync","writeFileSync","tmpdir","path","fileURLToPath","pathToFileURL","afterEach","describe","expect","it","workspaceDirectory","URL","url","temporaryDirectories","directory","splice","force","recursive","each","adapter","join","push","isSQLite","alias","payload","bundle","entryPoints","format","logLevel","outfile","platform","from","href","script","JSON","stringify","env","process","VITEST","output","execPath","encoding","timeout","toContain"],"mappings":"AAAA,SAASA,KAAK,QAAQ,UAAS;AAC/B,SAASC,YAAY,QAAQ,qBAAoB;AACjD,SAASC,WAAW,EAAEC,MAAM,EAAEC,aAAa,QAAQ,UAAS;AAC5D,SAASC,MAAM,QAAQ,UAAS;AAChC,OAAOC,UAAU,YAAW;AAC5B,SAASC,aAAa,EAAEC,aAAa,QAAQ,WAAU;AACvD,SAASC,SAAS,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,SAAQ;AAExD,MAAMC,qBAAqBN,cAAc,IAAIO,IAAI,gBAAgB,YAAYC,GAAG;AAChF,MAAMC,uBAAiC,EAAE;AAEzCP,UAAU;IACR,KAAK,MAAMQ,aAAaD,qBAAqBE,MAAM,CAAC,GAAI;QACtDf,OAAOc,WAAW;YAAEE,OAAO;YAAMC,WAAW;QAAK;IACnD;AACF;AAEAV,SAAS,+BAA+B;IACtCE,GAAGS,IAAI,CAAC;QAAC;QAAa;KAAc,EAClC,kFACA,OAAOC;QACL,MAAML,YAAYf,YAAYI,KAAKiB,IAAI,CAAClB,UAAU;QAClDW,qBAAqBQ,IAAI,CAACP;QAE1B,MAAMQ,WAAWH,YAAY;QAE7B,2CAA2C;QAC3C,MAAMtB,MAAM;YACV0B,OAAO;gBACLC,SAASrB,KAAKiB,IAAI,CAACV,oBAAoB;YACzC;YACAe,QAAQ;YACRC,aAAa;gBACXvB,KAAKiB,IAAI,CACPV,oBACAY,WACI,2DACA;aAEP;YACDK,QAAQ;YACRC,UAAU;YACVC,SAAS1B,KAAKiB,IAAI,CAACN,WAAW;YAC9BgB,UAAU;QACZ;QAEA,MAAMC,OAAO1B,cACXF,KAAKiB,IAAI,CAACV,oBAAoB,YAAYS,SAAS,iBACnDa,IAAI;QACN,MAAMC,SAAS9B,KAAKiB,IAAI,CAACN,WAAW;QAEpCb,cACEgC,QACA,CAAC;;;;8BAIqB,EAAEC,KAAKC,SAAS,CAACJ,MAAM;;sDAEC,EAAEG,KAAKC,SAAS,CAACJ,MAAM;AAC7E,EACET,WACI,wEACA,yEACL;eACc,EACLA,WACI,wEACA,oEACL;;;;;IAKL,EAAEA,SAAS;;;;;;;;;;;;;;;AAef,CAAC;QAGK,MAAMc,MAAM;YAAE,GAAGC,QAAQD,GAAG;QAAC;QAC7B,OAAOA,IAAIE,MAAM;QAEjB,MAAMC,SAASzC,aAAauC,QAAQG,QAAQ,EAAE;YAACP;SAAO,EAAE;YACtDQ,UAAU;YACVL;YACAM,SAAS;QACX;QAEAlC,OAAO+B,QAAQI,SAAS,CAAC;IAC3B;AAEJ"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Payload } from 'payload';
|
|
2
|
+
export type LocalizeStatusArgs = {
|
|
3
|
+
collectionSlug?: string;
|
|
4
|
+
db: any;
|
|
5
|
+
globalSlug?: string;
|
|
6
|
+
payload: Payload;
|
|
7
|
+
req?: any;
|
|
8
|
+
};
|
|
9
|
+
export declare function migrateSqliteLocalizeStatus(args: LocalizeStatusArgs): Promise<void>;
|
|
10
|
+
/**
|
|
11
|
+
* Drops a column, first removing any indexes that reference it. SQLite refuses to
|
|
12
|
+
* drop a column that is still referenced by an index.
|
|
13
|
+
*/
|
|
14
|
+
export declare function dropColumn({ columnName, db, tableName, }: {
|
|
15
|
+
columnName: string;
|
|
16
|
+
db: any;
|
|
17
|
+
tableName: string;
|
|
18
|
+
}): Promise<void>;
|
|
19
|
+
export declare function columnExists({ columnName, db, tableName, }: {
|
|
20
|
+
columnName: string;
|
|
21
|
+
db: any;
|
|
22
|
+
tableName: string;
|
|
23
|
+
}): Promise<boolean>;
|
|
24
|
+
export declare function tableExists({ db, tableName, }: {
|
|
25
|
+
db: any;
|
|
26
|
+
tableName: string;
|
|
27
|
+
}): Promise<boolean>;
|
|
28
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/sqlite/predefinedMigrations/localize-status/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAStC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,EAAE,EAAE,GAAG,CAAA;IACP,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,OAAO,EAAE,OAAO,CAAA;IAChB,GAAG,CAAC,EAAE,GAAG,CAAA;CACV,CAAA;AAED,wBAAsB,2BAA2B,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CA2LzF;AAED;;;GAGG;AACH,wBAAsB,UAAU,CAAC,EAC/B,UAAU,EACV,EAAE,EACF,SAAS,GACV,EAAE;IACD,UAAU,EAAE,MAAM,CAAA;IAClB,EAAE,EAAE,GAAG,CAAA;IACP,SAAS,EAAE,MAAM,CAAA;CAClB,GAAG,OAAO,CAAC,IAAI,CAAC,CAYhB;AAED,wBAAsB,YAAY,CAAC,EACjC,UAAU,EACV,EAAE,EACF,SAAS,GACV,EAAE;IACD,UAAU,EAAE,MAAM,CAAA;IAClB,EAAE,EAAE,GAAG,CAAA;IACP,SAAS,EAAE,MAAM,CAAA;CAClB,GAAG,OAAO,CAAC,OAAO,CAAC,CAOnB;AAED,wBAAsB,WAAW,CAAC,EAChC,EAAE,EACF,SAAS,GACV,EAAE;IACD,EAAE,EAAE,GAAG,CAAA;IACP,SAAS,EAAE,MAAM,CAAA;CAClB,GAAG,OAAO,CAAC,OAAO,CAAC,CAOnB"}
|