@payloadcms/drizzle 4.0.0-internal.38b7f1d → 4.0.0-internal.c2b57ce
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/dist/createTableName.d.ts.map +1 -1
- package/dist/find/buildFindManyArgs.d.ts.map +1 -1
- package/dist/find/chainMethods.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/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/migrate.d.ts.map +1 -1
- package/dist/migrate.js +1 -3
- package/dist/migrate.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/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/groupUpSQLStatements.d.ts.map +1 -1
- package/dist/postgres/predefinedMigrations/v2-v3/index.d.ts.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/schema/buildDrizzleTable.d.ts.map +1 -1
- package/dist/postgres/schema/geometryColumn.d.ts.map +1 -1
- package/dist/queries/addJoinTable.d.ts.map +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/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/buildDrizzleRelations.d.ts.map +1 -1
- package/dist/schema/buildRawSchema.d.ts.map +1 -1
- package/dist/schema/idToUUID.d.ts.map +1 -1
- package/dist/schema/traverseFields.d.ts.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/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/write/array.d.ts.map +1 -1
- package/dist/transform/write/blocks.d.ts.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/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/index.d.ts.map +1 -1
- package/dist/upsertRow/insertArrays.d.ts.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/buildCreateMigration.d.ts.map +1 -1
- package/dist/utilities/buildCreateMigration.js +2 -30
- 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.map +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 +0 -14
- 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.map +1 -1
- package/package.json +4 -9
- package/dist/exports/types-deprecated.d.ts +0 -150
- package/dist/exports/types-deprecated.d.ts.map +0 -1
- package/dist/exports/types-deprecated.js +0 -5
- package/dist/exports/types-deprecated.js.map +0 -1
- package/dist/migrateVersionsEnabled.d.ts +0 -9
- package/dist/migrateVersionsEnabled.d.ts.map +0 -1
- package/dist/migrateVersionsEnabled.js +0 -52
- package/dist/migrateVersionsEnabled.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
|
-
import {
|
|
3
|
+
import { getPredefinedMigration, writeMigrationIndex } from 'payload';
|
|
4
4
|
import prompts from 'prompts';
|
|
5
5
|
import { getMigrationTemplate } from './getMigrationTemplate.js';
|
|
6
6
|
export const buildCreateMigration = ({ executeMethod, filename, sanitizeStatements })=>{
|
|
@@ -46,28 +46,6 @@ export const buildCreateMigration = ({ executeMethod, filename, sanitizeStatemen
|
|
|
46
46
|
imports = dynamicResult.imports;
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
-
// Config-diff: compute data migrations before DDL to inform empty-migration check
|
|
50
|
-
const prevSnapshot = await readConfigState(dir);
|
|
51
|
-
const nextSnapshot = serializeConfig(payload.config);
|
|
52
|
-
let dataUpCode = '';
|
|
53
|
-
let dataDownCode = '';
|
|
54
|
-
if (prevSnapshot !== null) {
|
|
55
|
-
const changes = diffConfig(prevSnapshot, nextSnapshot);
|
|
56
|
-
if (changes.length > 0) {
|
|
57
|
-
const { shouldAbort } = await resolvePrompts(changes);
|
|
58
|
-
if (shouldAbort) {
|
|
59
|
-
process.exit(1);
|
|
60
|
-
}
|
|
61
|
-
const localization = payload.config.localization || null;
|
|
62
|
-
const { downCode, upCode } = generateDataMigrationCode(changes, {
|
|
63
|
-
defaultLocale: localization?.defaultLocale
|
|
64
|
-
});
|
|
65
|
-
dataUpCode = upCode;
|
|
66
|
-
dataDownCode = downCode;
|
|
67
|
-
}
|
|
68
|
-
} else {
|
|
69
|
-
await bootstrapConfigState(payload, dir);
|
|
70
|
-
}
|
|
71
49
|
let drizzleJsonBefore = this.defaultDrizzleSnapshot;
|
|
72
50
|
if (this.schemaName) {
|
|
73
51
|
drizzleJsonBefore.schemas = {
|
|
@@ -101,7 +79,7 @@ export const buildCreateMigration = ({ executeMethod, filename, sanitizeStatemen
|
|
|
101
79
|
statements: sqlStatementsDown
|
|
102
80
|
});
|
|
103
81
|
}
|
|
104
|
-
if (!upSQL?.length && !downSQL?.length && !
|
|
82
|
+
if (!upSQL?.length && !downSQL?.length && !forceAcceptWarning) {
|
|
105
83
|
if (skipEmpty) {
|
|
106
84
|
process.exit(0);
|
|
107
85
|
}
|
|
@@ -122,12 +100,6 @@ export const buildCreateMigration = ({ executeMethod, filename, sanitizeStatemen
|
|
|
122
100
|
// write schema
|
|
123
101
|
fs.writeFileSync(`${filePath}.json`, JSON.stringify(drizzleJsonAfter, null, 2));
|
|
124
102
|
}
|
|
125
|
-
if (dataUpCode) {
|
|
126
|
-
upSQL = upSQL ? `${upSQL}\n${dataUpCode}` : dataUpCode;
|
|
127
|
-
}
|
|
128
|
-
if (dataDownCode) {
|
|
129
|
-
downSQL = downSQL ? `${downSQL}\n${dataDownCode}` : dataDownCode;
|
|
130
|
-
}
|
|
131
103
|
const data = getMigrationTemplate({
|
|
132
104
|
downSQL: downSQL || ` // Migration code`,
|
|
133
105
|
imports,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/buildCreateMigration.ts"],"sourcesContent":["import type { DrizzleSnapshotJSON } from 'drizzle-kit/api'\nimport type { CreateMigration, Payload } from 'payload'\n\nimport fs from 'fs'\nimport path from 'path'\nimport {\n bootstrapConfigState,\n diffConfig,\n generateDataMigrationCode,\n getPredefinedMigration,\n readConfigState,\n resolvePrompts,\n serializeConfig,\n writeMigrationIndex,\n} from 'payload'\nimport prompts from 'prompts'\n\nimport type { DrizzleAdapter } from '../types.js'\n\nimport { getMigrationTemplate } from './getMigrationTemplate.js'\n\nexport const buildCreateMigration = ({\n executeMethod,\n filename,\n sanitizeStatements,\n}: {\n executeMethod: string\n filename: string\n sanitizeStatements: (args: { sqlExecute: string; statements: string[] }) => string\n}): CreateMigration => {\n const dirname = path.dirname(filename)\n return async function createMigration(\n this: DrizzleAdapter,\n { file, forceAcceptWarning, migrationName, payload, skipEmpty },\n ) {\n const dir = payload.db.migrationDir\n if (!fs.existsSync(dir)) {\n fs.mkdirSync(dir)\n }\n\n const { generateDrizzleJson, generateMigration, upSnapshot } = this.requireDrizzleKit()\n\n const drizzleJsonAfter = await generateDrizzleJson(this.schema)\n\n const [yyymmdd, hhmmss] = new Date().toISOString().split('T')\n const formattedDate = yyymmdd.replace(/\\D/g, '')\n const formattedTime = hhmmss.split('.')[0].replace(/\\D/g, '')\n let imports: string = ''\n let downSQL: string\n let upSQL: string\n\n const predefinedMigration = await getPredefinedMigration({\n dirname,\n file,\n migrationName,\n payload,\n })\n\n imports = predefinedMigration.imports\n downSQL = predefinedMigration.downSQL\n upSQL = predefinedMigration.upSQL\n\n const timestamp = `${formattedDate}_${formattedTime}`\n\n const name = migrationName || file?.split('/').slice(2).join('/')\n const fileName = `${timestamp}${name ? `_${name.replace(/\\W/g, '_')}` : ''}`\n\n const filePath = `${dir}/${fileName}`\n\n if (typeof predefinedMigration.dynamic === 'function') {\n const dynamicResult = await predefinedMigration.dynamic({ filePath, payload })\n\n if (dynamicResult.upSQL) {\n upSQL = dynamicResult.upSQL\n }\n\n if (dynamicResult.downSQL) {\n downSQL = dynamicResult.downSQL\n }\n\n if (dynamicResult.imports) {\n imports = dynamicResult.imports\n }\n }\n\n // Config-diff: compute data migrations before DDL to inform empty-migration check\n const prevSnapshot = await readConfigState(dir)\n const nextSnapshot = serializeConfig(payload.config)\n let dataUpCode = ''\n let dataDownCode = ''\n\n if (prevSnapshot !== null) {\n const changes = diffConfig(prevSnapshot, nextSnapshot)\n if (changes.length > 0) {\n const { shouldAbort } = await resolvePrompts(changes)\n if (shouldAbort) {\n process.exit(1)\n }\n const localization = payload.config.localization || null\n const { downCode, upCode } = generateDataMigrationCode(changes, {\n defaultLocale: localization?.defaultLocale,\n })\n dataUpCode = upCode\n dataDownCode = downCode\n }\n } else {\n await bootstrapConfigState(payload, dir)\n }\n\n let drizzleJsonBefore = this.defaultDrizzleSnapshot as DrizzleSnapshotJSON\n\n if (this.schemaName) {\n drizzleJsonBefore.schemas = {\n [this.schemaName]: this.schemaName,\n }\n }\n\n if (!upSQL) {\n // Get latest migration snapshot\n const latestSnapshot = fs\n .readdirSync(dir)\n .filter((file) => file.endsWith('.json'))\n .sort()\n .reverse()?.[0]\n\n if (latestSnapshot) {\n drizzleJsonBefore = JSON.parse(fs.readFileSync(`${dir}/${latestSnapshot}`, 'utf8'))\n\n if (upSnapshot && drizzleJsonBefore.version < drizzleJsonAfter.version) {\n drizzleJsonBefore = upSnapshot(drizzleJsonBefore)\n }\n }\n\n payload.logger.info('Starting migration: generating UP statements...')\n const sqlStatementsUp = await generateMigration(drizzleJsonBefore, drizzleJsonAfter)\n\n payload.logger.info('Migration UP complete. Generating DOWN statements...')\n const sqlStatementsDown = await generateMigration(drizzleJsonAfter, drizzleJsonBefore)\n\n payload.logger.info('Migration DOWN statements generation complete.')\n\n const sqlExecute = `await db.${executeMethod}(` + 'sql`'\n\n if (sqlStatementsUp?.length) {\n upSQL = sanitizeStatements({ sqlExecute, statements: sqlStatementsUp })\n }\n if (sqlStatementsDown?.length) {\n downSQL = sanitizeStatements({ sqlExecute, statements: sqlStatementsDown })\n }\n\n if (!upSQL?.length && !downSQL?.length && !dataUpCode && !forceAcceptWarning) {\n if (skipEmpty) {\n process.exit(0)\n }\n\n const { confirm: shouldCreateBlankMigration } = await prompts(\n {\n name: 'confirm',\n type: 'confirm',\n initial: false,\n message: 'No schema changes detected. Would you like to create a blank migration file?',\n },\n {\n onCancel: () => {\n process.exit(0)\n },\n },\n )\n\n if (!shouldCreateBlankMigration) {\n process.exit(0)\n }\n }\n\n // write schema\n fs.writeFileSync(`${filePath}.json`, JSON.stringify(drizzleJsonAfter, null, 2))\n }\n\n if (dataUpCode) {\n upSQL = upSQL ? `${upSQL}\\n${dataUpCode}` : dataUpCode\n }\n if (dataDownCode) {\n downSQL = downSQL ? `${downSQL}\\n${dataDownCode}` : dataDownCode\n }\n\n const data = getMigrationTemplate({\n downSQL: downSQL || ` // Migration code`,\n imports,\n packageName: payload.db.packageName,\n upSQL: upSQL || ` // Migration code`,\n })\n\n const fullPath = `${filePath}.ts`\n\n // write migration\n fs.writeFileSync(fullPath, data)\n\n writeMigrationIndex({ migrationsDir: payload.db.migrationDir })\n\n payload.logger.info({ msg: `Migration created at ${fullPath}` })\n }\n}\n"],"names":["fs","path","bootstrapConfigState","diffConfig","generateDataMigrationCode","getPredefinedMigration","readConfigState","resolvePrompts","serializeConfig","writeMigrationIndex","prompts","getMigrationTemplate","buildCreateMigration","executeMethod","filename","sanitizeStatements","dirname","createMigration","file","forceAcceptWarning","migrationName","payload","skipEmpty","dir","db","migrationDir","existsSync","mkdirSync","generateDrizzleJson","generateMigration","upSnapshot","requireDrizzleKit","drizzleJsonAfter","schema","yyymmdd","hhmmss","Date","toISOString","split","formattedDate","replace","formattedTime","imports","downSQL","upSQL","predefinedMigration","timestamp","name","slice","join","fileName","filePath","dynamic","dynamicResult","prevSnapshot","nextSnapshot","config","dataUpCode","dataDownCode","changes","length","shouldAbort","process","exit","localization","downCode","upCode","defaultLocale","drizzleJsonBefore","defaultDrizzleSnapshot","schemaName","schemas","latestSnapshot","readdirSync","filter","endsWith","sort","reverse","JSON","parse","readFileSync","version","logger","info","sqlStatementsUp","sqlStatementsDown","sqlExecute","statements","confirm","shouldCreateBlankMigration","type","initial","message","onCancel","writeFileSync","stringify","data","packageName","fullPath","migrationsDir","msg"],"mappings":"AAGA,OAAOA,QAAQ,KAAI;AACnB,OAAOC,UAAU,OAAM;AACvB,SACEC,oBAAoB,EACpBC,UAAU,EACVC,yBAAyB,EACzBC,sBAAsB,EACtBC,eAAe,EACfC,cAAc,EACdC,eAAe,EACfC,mBAAmB,QACd,UAAS;AAChB,OAAOC,aAAa,UAAS;AAI7B,SAASC,oBAAoB,QAAQ,4BAA2B;AAEhE,OAAO,MAAMC,uBAAuB,CAAC,EACnCC,aAAa,EACbC,QAAQ,EACRC,kBAAkB,EAKnB;IACC,MAAMC,UAAUf,KAAKe,OAAO,CAACF;IAC7B,OAAO,eAAeG,gBAEpB,EAAEC,IAAI,EAAEC,kBAAkB,EAAEC,aAAa,EAAEC,OAAO,EAAEC,SAAS,EAAE;QAE/D,MAAMC,MAAMF,QAAQG,EAAE,CAACC,YAA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AAC,mBAAmB,CAAC;YACzCD;YACAuD,aAAa5E,QAAQG,EAAE,CAACyE,WAAW;YACnCrD,OAAOA,SAAS,CAAC,mBAAmB,CAAC;QACvC;QAEA,MAAMsD,WAAW,GAAG/C,SAAS,GAAG,CAAC;QAEjC,kBAAkB;QAClBnD,GAAG8F,aAAa,CAACI,UAAUF;QAE3BvF,oBAAoB;YAAE0F,eAAe9E,QAAQG,EAAE,CAACC,YAAY;QAAC;QAE7DJ,QAAQ6D,MAAM,CAACC,IAAI,CAAC;YAAEiB,KAAK,CAAC,qBAAqB,EAAEF,UAAU;QAAC;IAChE;AACF,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/buildCreateMigration.ts"],"sourcesContent":["import type { DrizzleSnapshotJSON } from 'drizzle-kit/api'\nimport type { CreateMigration, Payload } from 'payload'\n\nimport fs from 'fs'\nimport path from 'path'\nimport { getPredefinedMigration, writeMigrationIndex } from 'payload'\nimport prompts from 'prompts'\n\nimport type { DrizzleAdapter } from '../types.js'\n\nimport { getMigrationTemplate } from './getMigrationTemplate.js'\n\nexport const buildCreateMigration = ({\n executeMethod,\n filename,\n sanitizeStatements,\n}: {\n executeMethod: string\n filename: string\n sanitizeStatements: (args: { sqlExecute: string; statements: string[] }) => string\n}): CreateMigration => {\n const dirname = path.dirname(filename)\n return async function createMigration(\n this: DrizzleAdapter,\n { file, forceAcceptWarning, migrationName, payload, skipEmpty },\n ) {\n const dir = payload.db.migrationDir\n if (!fs.existsSync(dir)) {\n fs.mkdirSync(dir)\n }\n\n const { generateDrizzleJson, generateMigration, upSnapshot } = this.requireDrizzleKit()\n\n const drizzleJsonAfter = await generateDrizzleJson(this.schema)\n\n const [yyymmdd, hhmmss] = new Date().toISOString().split('T')\n const formattedDate = yyymmdd.replace(/\\D/g, '')\n const formattedTime = hhmmss.split('.')[0].replace(/\\D/g, '')\n let imports: string = ''\n let downSQL: string\n let upSQL: string\n\n const predefinedMigration = await getPredefinedMigration({\n dirname,\n file,\n migrationName,\n payload,\n })\n\n imports = predefinedMigration.imports\n downSQL = predefinedMigration.downSQL\n upSQL = predefinedMigration.upSQL\n\n const timestamp = `${formattedDate}_${formattedTime}`\n\n const name = migrationName || file?.split('/').slice(2).join('/')\n const fileName = `${timestamp}${name ? `_${name.replace(/\\W/g, '_')}` : ''}`\n\n const filePath = `${dir}/${fileName}`\n\n if (typeof predefinedMigration.dynamic === 'function') {\n const dynamicResult = await predefinedMigration.dynamic({ filePath, payload })\n\n if (dynamicResult.upSQL) {\n upSQL = dynamicResult.upSQL\n }\n\n if (dynamicResult.downSQL) {\n downSQL = dynamicResult.downSQL\n }\n\n if (dynamicResult.imports) {\n imports = dynamicResult.imports\n }\n }\n\n let drizzleJsonBefore = this.defaultDrizzleSnapshot as DrizzleSnapshotJSON\n\n if (this.schemaName) {\n drizzleJsonBefore.schemas = {\n [this.schemaName]: this.schemaName,\n }\n }\n\n if (!upSQL) {\n // Get latest migration snapshot\n const latestSnapshot = fs\n .readdirSync(dir)\n .filter((file) => file.endsWith('.json'))\n .sort()\n .reverse()?.[0]\n\n if (latestSnapshot) {\n drizzleJsonBefore = JSON.parse(fs.readFileSync(`${dir}/${latestSnapshot}`, 'utf8'))\n\n if (upSnapshot && drizzleJsonBefore.version < drizzleJsonAfter.version) {\n drizzleJsonBefore = upSnapshot(drizzleJsonBefore)\n }\n }\n\n payload.logger.info('Starting migration: generating UP statements...')\n const sqlStatementsUp = await generateMigration(drizzleJsonBefore, drizzleJsonAfter)\n\n payload.logger.info('Migration UP complete. Generating DOWN statements...')\n const sqlStatementsDown = await generateMigration(drizzleJsonAfter, drizzleJsonBefore)\n\n payload.logger.info('Migration DOWN statements generation complete.')\n\n const sqlExecute = `await db.${executeMethod}(` + 'sql`'\n\n if (sqlStatementsUp?.length) {\n upSQL = sanitizeStatements({ sqlExecute, statements: sqlStatementsUp })\n }\n if (sqlStatementsDown?.length) {\n downSQL = sanitizeStatements({ sqlExecute, statements: sqlStatementsDown })\n }\n\n if (!upSQL?.length && !downSQL?.length && !forceAcceptWarning) {\n if (skipEmpty) {\n process.exit(0)\n }\n\n const { confirm: shouldCreateBlankMigration } = await prompts(\n {\n name: 'confirm',\n type: 'confirm',\n initial: false,\n message: 'No schema changes detected. Would you like to create a blank migration file?',\n },\n {\n onCancel: () => {\n process.exit(0)\n },\n },\n )\n\n if (!shouldCreateBlankMigration) {\n process.exit(0)\n }\n }\n\n // write schema\n fs.writeFileSync(`${filePath}.json`, JSON.stringify(drizzleJsonAfter, null, 2))\n }\n\n const data = getMigrationTemplate({\n downSQL: downSQL || ` // Migration code`,\n imports,\n packageName: payload.db.packageName,\n upSQL: upSQL || ` // Migration code`,\n })\n\n const fullPath = `${filePath}.ts`\n\n // write migration\n fs.writeFileSync(fullPath, data)\n\n writeMigrationIndex({ migrationsDir: payload.db.migrationDir })\n\n payload.logger.info({ msg: `Migration created at ${fullPath}` })\n }\n}\n"],"names":["fs","path","getPredefinedMigration","writeMigrationIndex","prompts","getMigrationTemplate","buildCreateMigration","executeMethod","filename","sanitizeStatements","dirname","createMigration","file","forceAcceptWarning","migrationName","payload","skipEmpty","dir","db","migrationDir","existsSync","mkdirSync","generateDrizzleJson","generateMigration","upSnapshot","requireDrizzleKit","drizzleJsonAfter","schema","yyymmdd","hhmmss","Date","toISOString","split","formattedDate","replace","formattedTime","imports","downSQL","upSQL","predefinedMigration","timestamp","name","slice","join","fileName","filePath","dynamic","dynamicResult","drizzleJsonBefore","defaultDrizzleSnapshot","schemaName","schemas","latestSnapshot","readdirSync","filter","endsWith","sort","reverse","JSON","parse","readFileSync","version","logger","info","sqlStatementsUp","sqlStatementsDown","sqlExecute","length","statements","process","exit","confirm","shouldCreateBlankMigration","type","initial","message","onCancel","writeFileSync","stringify","data","packageName","fullPath","migrationsDir","msg"],"mappings":"AAGA,OAAOA,QAAQ,KAAI;AACnB,OAAOC,UAAU,OAAM;AACvB,SAASC,sBAAsB,EAAEC,mBAAmB,QAAQ,UAAS;AACrE,OAAOC,aAAa,U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/buildForeignKeyName.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAEjD,eAAO,MAAM,mBAAmB
|
|
1
|
+
{"version":3,"file":"buildForeignKeyName.d.ts","sourceRoot":"","sources":["../../src/utilities/buildForeignKeyName.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAEjD,eAAO,MAAM,mBAAmB,GAAI,4BAIjC;IACD,OAAO,EAAE,cAAc,CAAA;IACvB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,KAAG,MAkBH,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildIndexName.d.ts","sourceRoot":"","sources":["../../src/utilities/buildIndexName.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAEjD,eAAO,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"buildIndexName.d.ts","sourceRoot":"","sources":["../../src/utilities/buildIndexName.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAEjD,eAAO,MAAM,cAAc,GAAI,0CAK5B;IACD,OAAO,EAAE,cAAc,CAAA;IACvB,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,KAAG,MAmBH,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createBlocksMap.d.ts","sourceRoot":"","sources":["../../src/utilities/createBlocksMap.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG;IACtB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;CAC1C,CAAA;AAED,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"createBlocksMap.d.ts","sourceRoot":"","sources":["../../src/utilities/createBlocksMap.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG;IACtB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;CAC1C,CAAA;AAED,eAAO,MAAM,eAAe,GAAI,MAAM,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAG,SAyC/D,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createRelationshipMap.d.ts","sourceRoot":"","sources":["../../src/utilities/createRelationshipMap.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"createRelationshipMap.d.ts","sourceRoot":"","sources":["../../src/utilities/createRelationshipMap.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa,GAAI,MAAM,OAAO,KAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAqBrF,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createSchemaGenerator.d.ts","sourceRoot":"","sources":["../../src/utilities/createSchemaGenerator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAM7C,OAAO,KAAK,EAAE,qBAAqB,EAAkB,MAAM,aAAa,CAAA;AAkCxE,eAAO,MAAM,qBAAqB,
|
|
1
|
+
{"version":3,"file":"createSchemaGenerator.d.ts","sourceRoot":"","sources":["../../src/utilities/createSchemaGenerator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAM7C,OAAO,KAAK,EAAE,qBAAqB,EAAkB,MAAM,aAAa,CAAA;AAkCxE,eAAO,MAAM,qBAAqB,GAAI,yGAOnC;IACD,qBAAqB,EAAE,qBAAqB,CAAA;IAC5C,iBAAiB,EAAE,MAAM,CAAA;IACzB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,WAAW,EAAE,MAAM,CAAA;CACpB,KAAG,cAiTH,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"escapeSQLValue.d.ts","sourceRoot":"","sources":["../../src/utilities/escapeSQLValue.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB,QAAmB,CAAA;AAEjD,eAAO,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"escapeSQLValue.d.ts","sourceRoot":"","sources":["../../src/utilities/escapeSQLValue.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB,QAAmB,CAAA;AAEjD,eAAO,MAAM,cAAc,GAAI,OAAO,OAAO,KAAG,OAAO,GAAG,IAAI,GAAG,MAAM,GAAG,MAoBzE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executeSchemaHooks.d.ts","sourceRoot":"","sources":["../../src/utilities/executeSchemaHooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAEjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAE5D,KAAK,cAAc,GAAG;IACpB,KAAK,CAAC,EAAE,cAAc,CAAC,OAAO,CAAC,CAAA;IAC/B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC9B,MAAM,EAAE,cAAc,CAAC,QAAQ,CAAC,CAAA;CACjC,CAAA;AAED,KAAK,OAAO,GAAG;IACb,eAAe,EAAE,kBAAkB,EAAE,CAAA;IACrC,gBAAgB,EAAE,kBAAkB,EAAE,CAAA;CACvC,GAAG,cAAc,CAAA;AAElB,KAAK,sBAAsB,GAAG;IAC5B,OAAO,EAAE,MAAM,CA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AAiB,GAAG,kBAAkB,CAAA;CAC7C,CAAA;AAED,eAAO,MAAM,kBAAkB,GAAU,mBAAmB,IAAI,KAAG,OAAO,CAAC,IAAI,CAkB9E,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extendDrizzleTable.d.ts","sourceRoot":"","sources":["../../src/utilities/extendDrizzleTable.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAEpD,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAWnC,KAAK,IAAI,GAAG;IACV,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAA;IAChD,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,MAAM,CAAA;IACnD,KAAK,EAAE,KAAK,CAAA;CACb,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,
|
|
1
|
+
{"version":3,"file":"extendDrizzleTable.d.ts","sourceRoot":"","sources":["../../src/utilities/extendDrizzleTable.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAEpD,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAWnC,KAAK,IAAI,GAAG;IACV,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAA;IAChD,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,MAAM,CAAA;IACnD,KAAK,EAAE,KAAK,CAAA;CACb,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,GAAI,iCAAiC,IAAI,KAAG,IAkC1E,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getArrayRelationName.d.ts","sourceRoot":"","sources":["../../src/utilities/getArrayRelationName.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEzC,eAAO,MAAM,oBAAoB,
|
|
1
|
+
{"version":3,"file":"getArrayRelationName.d.ts","sourceRoot":"","sources":["../../src/utilities/getArrayRelationName.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEzC,eAAO,MAAM,oBAAoB,GAAI,6BAIlC;IACD,KAAK,EAAE,UAAU,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,CAAA;CAClB,WAMA,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getCollectionIdType.d.ts","sourceRoot":"","sources":["../../src/utilities/getCollectionIdType.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEzC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAUjD,eAAO,MAAM,mBAAmB,
|
|
1
|
+
{"version":3,"file":"getCollectionIdType.d.ts","sourceRoot":"","sources":["../../src/utilities/getCollectionIdType.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEzC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAUjD,eAAO,MAAM,mBAAmB,GAAI,0BAGjC;IACD,OAAO,EAAE,cAAc,CAAA;IACvB,UAAU,EAAE,UAAU,CAAA;CACvB,sBAEA,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getMigrationTemplate.d.ts","sourceRoot":"","sources":["../../src/utilities/getMigrationTemplate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAEpD,eAAO,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"getMigrationTemplate.d.ts","sourceRoot":"","sources":["../../src/utilities/getMigrationTemplate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAEpD,eAAO,MAAM,MAAM,GAAI,MAAM,MAAM,WAIpB,CAAA;AAEf,eAAO,MAAM,oBAAoB,GAAI,2CAKlC,qBAAqB,KAAG,MAS1B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getNameFromDrizzleTable.d.ts","sourceRoot":"","sources":["../../src/utilities/getNameFromDrizzleTable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAIxC,eAAO,MAAM,uBAAuB,
|
|
1
|
+
{"version":3,"file":"getNameFromDrizzleTable.d.ts","sourceRoot":"","sources":["../../src/utilities/getNameFromDrizzleTable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAIxC,eAAO,MAAM,uBAAuB,GAAI,OAAO,KAAK,KAAG,MAEtD,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPrimaryDb.d.ts","sourceRoot":"","sources":["../../src/utilities/getPrimaryDb.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAErE;;GAEG;AACH,eAAO,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"getPrimaryDb.d.ts","sourceRoot":"","sources":["../../src/utilities/getPrimaryDb.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAErE;;GAEG;AACH,eAAO,MAAM,YAAY,GACvB,SAAS,cAAc,EACvB,IAAI,cAAc,CAAC,SAAS,CAAC,GAAG,kBAAkB,+HAMnD,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getTransaction.d.ts","sourceRoot":"","sources":["../../src/utilities/getTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAIjD;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,GAAU,CAAC,SAAS,cAAc,
|
|
1
|
+
{"version":3,"file":"getTransaction.d.ts","sourceRoot":"","sources":["../../src/utilities/getTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAIjD;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,GAAU,CAAC,SAAS,cAAc,GAAG,cAAc,EAC5E,SAAS,CAAC,EACV,MAAM,OAAO,CAAC,cAAc,CAAC,KAC5B,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAStB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hasLocalesTable.d.ts","sourceRoot":"","sources":["../../src/utilities/hasLocalesTable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAIpC,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"hasLocalesTable.d.ts","sourceRoot":"","sources":["../../src/utilities/hasLocalesTable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAIpC,eAAO,MAAM,eAAe,GAAI,gCAG7B;IACD,MAAM,EAAE,KAAK,EAAE,CAAA;IACf;;OAEG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAA;CAC5B,KAAG,OAyBH,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isPolymorphicRelationship.d.ts","sourceRoot":"","sources":["../../src/utilities/isPolymorphicRelationship.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C,eAAO,MAAM,yBAAyB,
|
|
1
|
+
{"version":3,"file":"isPolymorphicRelationship.d.ts","sourceRoot":"","sources":["../../src/utilities/isPolymorphicRelationship.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C,eAAO,MAAM,yBAAyB,GACpC,OAAO,OAAO,KACb,KAAK,IAAI;IACV,UAAU,EAAE,cAAc,CAAA;IAC1B,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;CASvB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isUUIDType.d.ts","sourceRoot":"","sources":["../../src/utilities/isUUIDType.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"isUUIDType.d.ts","sourceRoot":"","sources":["../../src/utilities/isUUIDType.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,GAAI,QAAQ,MAAM,KAAG,OAAmD,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../src/utilities/json.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AAK9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAIjD,wBAAgB,OAAO,CAAC,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,GAAG,gBAM/D;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,CAAC,EACpE,OAAO,EAAE,cAAc,EACvB,KAAK,EAAE,CAAC,gBAuBT;AAED,eAAO,MAAM,kBAAkB,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../src/utilities/json.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AAK9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAIjD,wBAAgB,OAAO,CAAC,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,GAAG,gBAM/D;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,CAAC,EACpE,OAAO,EAAE,cAAc,EACvB,KAAK,EAAE,CAAC,gBAuBT;AAED,eAAO,MAAM,kBAAkB,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,CAAC,EACvE,SAAS,cAAc,EACvB,OAAO,CAAC,iBAGT,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrationTableExists.d.ts","sourceRoot":"","sources":["../../src/utilities/migrationTableExists.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAExD,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAE7D,eAAO,MAAM,oBAAoB,
|
|
1
|
+
{"version":3,"file":"migrationTableExists.d.ts","sourceRoot":"","sources":["../../src/utilities/migrationTableExists.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAExD,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAE7D,eAAO,MAAM,oBAAoB,GAC/B,SAAS,cAAc,EACvB,KAAK,cAAc,GAAG,UAAU,KAC/B,OAAO,CAAC,OAAO,CA2BjB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseError.d.ts","sourceRoot":"","sources":["../../src/utilities/parseError.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"parseError.d.ts","sourceRoot":"","sources":["../../src/utilities/parseError.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,UAAU,GAAI,KAAK,OAAO,EAAE,KAAK,MAAM,KAAG,MAUtD,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pushDevSchema.d.ts","sourceRoot":"","sources":["../../src/utilities/pushDevSchema.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pushDevSchema.d.ts","sourceRoot":"","sources":["../../src/utilities/pushDevSchema.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAwB,MAAM,aAAa,CAAA;AAUvE;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GAAU,SAAS,cAAc,kBA6F1D,CAAA"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { dequal } from 'dequal';
|
|
2
|
-
import { diffConfig, readConfigState, serializeConfig } from 'payload';
|
|
3
2
|
import prompts from 'prompts';
|
|
4
3
|
const previousSchema = {
|
|
5
4
|
localeCodes: null,
|
|
@@ -60,19 +59,6 @@ const previousSchema = {
|
|
|
60
59
|
}
|
|
61
60
|
}
|
|
62
61
|
await apply();
|
|
63
|
-
// Warn if config changes require a data migration that dev push cannot handle
|
|
64
|
-
const prevSnapshot = await readConfigState(adapter.migrationDir);
|
|
65
|
-
if (prevSnapshot !== null) {
|
|
66
|
-
const changes = diffConfig(prevSnapshot, serializeConfig(adapter.payload.config));
|
|
67
|
-
const dataChanges = changes.filter((c)=>![
|
|
68
|
-
'autosave_enabled',
|
|
69
|
-
'locale_added',
|
|
70
|
-
'versions_enabled'
|
|
71
|
-
].includes(c.type));
|
|
72
|
-
if (dataChanges.length > 0) {
|
|
73
|
-
adapter.payload.logger.warn(`[payload] Config changes detected that require a data migration:\n` + dataChanges.map((c)=>` • ${c.type} on "${c.slug ?? c.locale}"`).join('\n') + `\nRun "payload migrate:create" and "payload migrate" to apply.`);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
62
|
const migrationsTable = adapter.schemaName ? `"${adapter.schemaName}"."payload_migrations"` : '"payload_migrations"';
|
|
77
63
|
const drizzle = adapter.drizzle;
|
|
78
64
|
const result = await adapter.execute({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/pushDevSchema.ts"],"sourcesContent":["import { dequal } from 'dequal'\nimport
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/pushDevSchema.ts"],"sourcesContent":["import { dequal } from 'dequal'\nimport prompts from 'prompts'\n\nimport type { BasePostgresAdapter } from '../postgres/types.js'\nimport type { DrizzleAdapter, PostgresDB, RawTable } from '../types.js'\n\nconst previousSchema: {\n localeCodes: null | string[]\n rawTables: null | Record<string, RawTable>\n} = {\n localeCodes: null,\n rawTables: null,\n}\n\n/**\n * Pushes the development schema to the database using Drizzle.\n *\n * @param {DrizzleAdapter} adapter - The PostgresAdapter instance connected to the database.\n * @returns {Promise<void>} - A promise that resolves once the schema push is complete.\n */\nexport const pushDevSchema = async (adapter: DrizzleAdapter) => {\n if (process.env.PAYLOAD_FORCE_DRIZZLE_PUSH !== 'true') {\n const localeCodes =\n adapter.payload.config.localization && adapter.payload.config.localization.localeCodes\n\n const equal = dequal(previousSchema, {\n localeCodes,\n rawTables: adapter.rawTables,\n })\n\n if (equal) {\n if (adapter.logger) {\n adapter.payload.logger.info('No changes detected in schema, skipping schema push.')\n }\n\n return\n } else {\n previousSchema.localeCodes = localeCodes\n previousSchema.rawTables = adapter.rawTables\n }\n }\n\n const { pushSchema } = adapter.requireDrizzleKit()\n\n const { extensions = {}, tablesFilter } = adapter as BasePostgresAdapter\n\n // This will prompt if clarifications are needed for Drizzle to push new schema\n const { apply, hasDataLoss, warnings } = await pushSchema(\n adapter.schema,\n adapter.drizzle,\n adapter.schemaName ? [adapter.schemaName] : undefined,\n tablesFilter,\n // Drizzle extensionsFilter supports only postgis for now\n // https://github.com/drizzle-team/drizzle-orm/blob/83daf2d5cf023112de878bc2249ee2c41a2a5b1b/drizzle-kit/src/cli/validations/cli.ts#L26\n extensions.postgis ? ['postgis'] : undefined,\n )\n\n if (warnings.length) {\n let message = `Warnings detected during schema push: \\n\\n${warnings.join('\\n')}\\n\\n`\n\n if (hasDataLoss) {\n message += `DATA LOSS WARNING: Possible data loss detected if schema is pushed.\\n\\n`\n }\n\n message += `Accept warnings and push schema to database?`\n\n const { confirm: acceptWarnings } = await prompts(\n {\n name: 'confirm',\n type: 'confirm',\n initial: false,\n message,\n },\n {\n onCancel: () => {\n process.exit(0)\n },\n },\n )\n\n // Exit if user does not accept warnings.\n // Q: Is this the right type of exit for this interaction?\n if (!acceptWarnings) {\n process.exit(0)\n }\n }\n\n await apply()\n const migrationsTable = adapter.schemaName\n ? `\"${adapter.schemaName}\".\"payload_migrations\"`\n : '\"payload_migrations\"'\n\n const drizzle = adapter.drizzle as PostgresDB\n\n const result = await adapter.execute({\n drizzle,\n raw: `SELECT * FROM ${migrationsTable} WHERE batch = '-1'`,\n })\n\n const devPush = result.rows\n\n if (!devPush.length) {\n // Use drizzle for insert so $defaultFn's are called\n await drizzle.insert(adapter.tables.payload_migrations).values({\n name: 'dev',\n batch: -1,\n })\n } else {\n await adapter.execute({\n drizzle,\n raw: `UPDATE ${migrationsTable} SET updated_at = CURRENT_TIMESTAMP WHERE batch = '-1'`,\n })\n }\n}\n"],"names":["dequal","prompts","previousSchema","localeCodes","rawTables","pushDevSchema","adapter","process","env","PAYLOAD_FORCE_DRIZZLE_PUSH","payload","config","localization","equal","logger","info","pushSchema","requireDrizzleKit","extensions","tablesFilter","apply","hasDataLoss","warnings","schema","drizzle","schemaName","undefined","postgis","length","message","join","confirm","acceptWarnings","name","type","initial","onCancel","exit","migrationsTable","result","execute","raw","devPush","rows","insert","tables","payload_migrations","values","batch"],"mappings":"AAAA,SAASA,MAAM,QAAQ,SAAQ;AAC/B,OAAOC,aAAa,UAAS;AAK7B,MAAMC,iBAGF;IACFC,aAAa;IACbC,WAAW;AACb;AAEA;;;;;CAKC,GACD,OAAO,MAAMC,gBAAgB,OAAOC;IAClC,IAAIC,QAAQC,GAAG,CAACC,0BAA0B,KAAK,QAAQ;QACrD,MAAMN,cACJG,QAAQI,OAAO,CAACC,MAAM,CAACC,YAAY,IAAIN,QAAQI,OAAO,CAACC,MAAM,CAACC,YAAY,CAACT,WAAW;QAExF,MAAMU,QAAQb,OAAOE,gBAAgB;YACnCC;YACAC,WAAWE,QAAQF,SAAS;QAC9B;QAEA,IAAIS,OAAO;YACT,IAAIP,QAAQQ,MAAM,EAAE;gBAClBR,QAAQI,OAAO,CAACI,MAAM,CAACC,IAAI,CAAC;YAC9B;YAEA;QACF,OAAO;YACLb,eAAeC,WAAW,GAAGA;YAC7BD,eAAeE,SAAS,GAAGE,QAAQF,SAAS;QAC9C;IACF;IAEA,MAAM,EAAEY,UAAU,EAAE,GAAGV,QAAQW,iBAAiB;IAEhD,MAAM,EAAEC,aAAa,CAAC,CAAC,EAAEC,YAAY,EAAE,GAAGb;IAE1C,+EAA+E;IAC/E,MAAM,EAAEc,KAAK,EAAEC,WAAW,EAAEC,QAAQ,EAAE,GAAG,MAAMN,WAC7CV,QAAQiB,MAAM,EACdjB,QAAQkB,OAAO,EACflB,QAAQmB,UAAU,GAAG;QAACnB,QAAQmB,UAAU;KAAC,GAAGC,WAC5CP,cACA,yDAAyD;IACzD,uIAAuI;IACvID,WAAWS,OAAO,GAAG;QAAC;KAAU,GAAGD;IAGrC,IAAIJ,SAASM,MAAM,EAAE;QACnB,IAAIC,UAAU,CAAC,0CAA0C,EAAEP,SAASQ,IAAI,CAAC,MAAM,IAAI,CAAC;QAEpF,IAAIT,aAAa;YACfQ,WAAW,CAAC,uEAAuE,CAAC;QACtF;QAEAA,WAAW,CAAC,4CAA4C,CAAC;QAEzD,MAAM,EAAEE,SAASC,cAAc,EAAE,GAAG,MAAM/B,QACxC;YACEgC,MAAM;YACNC,MAAM;YACNC,SAAS;YACTN;QACF,GACA;YACEO,UAAU;gBACR7B,QAAQ8B,IAAI,CAAC;YACf;QACF;QAGF,yCAAyC;QACzC,0DAA0D;QAC1D,IAAI,CAACL,gBAAgB;YACnBzB,QAAQ8B,IAAI,CAAC;QACf;IACF;IAEA,MAAMjB;IACN,MAAMkB,kBAAkBhC,QAAQmB,UAAU,GACtC,CAAC,CAAC,EAAEnB,QAAQmB,UAAU,CAAC,sBAAsB,CAAC,GAC9C;IAEJ,MAAMD,UAAUlB,QAAQkB,OAAO;IAE/B,MAAMe,SAAS,MAAMjC,QAAQkC,OAAO,CAAC;QACnChB;QACAiB,KAAK,CAAC,cAAc,EAAEH,gBAAgB,mBAAmB,CAAC;IAC5D;IAEA,MAAMI,UAAUH,OAAOI,IAAI;IAE3B,IAAI,CAACD,QAAQd,MAAM,EAAE;QACnB,oDAAoD;QACpD,MAAMJ,QAAQoB,MAAM,CAACtC,QAAQuC,MAAM,CAACC,kBAAkB,EAAEC,MAAM,CAAC;YAC7Dd,MAAM;YACNe,OAAO,CAAC;QACV;IACF,OAAO;QACL,MAAM1C,QAAQkC,OAAO,CAAC;YACpBhB;YACAiB,KAAK,CAAC,OAAO,EAAEH,gBAAgB,sDAAsD,CAAC;QACxF;IACF;AACF,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rawConstraint.d.ts","sourceRoot":"","sources":["../../src/utilities/rawConstraint.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,eAA2B,CAAA;AAEtD;;GAEG;AACH,eAAO,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"rawConstraint.d.ts","sourceRoot":"","sources":["../../src/utilities/rawConstraint.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,eAA2B,CAAA;AAEtD;;GAEG;AACH,eAAO,MAAM,aAAa,GAAI,OAAO,OAAO;;;CAG1C,CAAA;AAEF,eAAO,MAAM,eAAe,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,UAAU,CAAC,OAAO,aAAa,CAExF,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sanitizePathSegment.d.ts","sourceRoot":"","sources":["../../src/utilities/sanitizePathSegment.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,mBAAmB,
|
|
1
|
+
{"version":3,"file":"sanitizePathSegment.d.ts","sourceRoot":"","sources":["../../src/utilities/sanitizePathSegment.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,mBAAmB,GAAI,SAAS,MAAM,KAAG,MAQrD,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validateExistingBlockIsIdentical.d.ts","sourceRoot":"","sources":["../../src/utilities/validateExistingBlockIsIdentical.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAS,cAAc,EAAE,MAAM,SAAS,CAAA;AAS3D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAE3C,KAAK,IAAI,GAAG;IACV,KAAK,EAAE,KAAK,CAAA;IACZ,SAAS,EAAE,OAAO,CAAA;IAClB;;OAEG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,aAAa,EAAE,MAAM,CAAA;IACrB,KAAK,EAAE,QAAQ,CAAA;IACf,YAAY,CAAC,EAAE,QAAQ,CAAA;CACxB,CAAA;AA+DD;;GAEG;AACH,eAAO,MAAM,gCAAgC,
|
|
1
|
+
{"version":3,"file":"validateExistingBlockIsIdentical.d.ts","sourceRoot":"","sources":["../../src/utilities/validateExistingBlockIsIdentical.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAS,cAAc,EAAE,MAAM,SAAS,CAAA;AAS3D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAE3C,KAAK,IAAI,GAAG;IACV,KAAK,EAAE,KAAK,CAAA;IACZ,SAAS,EAAE,OAAO,CAAA;IAClB;;OAEG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,aAAa,EAAE,MAAM,CAAA;IACrB,KAAK,EAAE,QAAQ,CAAA;IACf,YAAY,CAAC,EAAE,QAAQ,CAAA;CACxB,CAAA;AA+DD;;GAEG;AACH,eAAO,MAAM,gCAAgC,GAAI,+DAM9C,IAAI,KAAG,OAwBT,CAAA;AAED,eAAO,MAAM,2BAA2B,eAAwC,CAAA;AAChF,eAAO,MAAM,qBAAqB,GAAI,OAAO,cAAc,EAAE,OAAO,MAAM,SAEzE,CAAA;AAED,eAAO,MAAM,qBAAqB,GAAI,OAAO,cAAc,EAAE,mBAAmB,MAAM,WAMrF,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/drizzle",
|
|
3
|
-
"version": "4.0.0-internal.
|
|
3
|
+
"version": "4.0.0-internal.c2b57ce",
|
|
4
4
|
"description": "A library of shared functions used by different payload database adapters",
|
|
5
5
|
"homepage": "https://payloadcms.com",
|
|
6
6
|
"repository": {
|
|
@@ -34,11 +34,6 @@
|
|
|
34
34
|
"import": "./dist/exports/sqlite.js",
|
|
35
35
|
"types": "./dist/exports/sqlite.d.ts",
|
|
36
36
|
"default": "./dist/exports/sqlite.js"
|
|
37
|
-
},
|
|
38
|
-
"./types": {
|
|
39
|
-
"import": "./dist/exports/types-deprecated.js",
|
|
40
|
-
"types": "./dist/exports/types-deprecated.d.ts",
|
|
41
|
-
"default": "./dist/exports/types-deprecated.js"
|
|
42
37
|
}
|
|
43
38
|
},
|
|
44
39
|
"main": "./dist/index.js",
|
|
@@ -48,7 +43,7 @@
|
|
|
48
43
|
"mock.js"
|
|
49
44
|
],
|
|
50
45
|
"dependencies": {
|
|
51
|
-
"console-table-printer": "2.
|
|
46
|
+
"console-table-printer": "2.15.0",
|
|
52
47
|
"dequal": "2.0.3",
|
|
53
48
|
"drizzle-orm": "0.45.2",
|
|
54
49
|
"prompts": "2.4.2",
|
|
@@ -60,10 +55,10 @@
|
|
|
60
55
|
"@types/pg": "8.20.0",
|
|
61
56
|
"@types/to-snake-case": "1.0.0",
|
|
62
57
|
"@payloadcms/eslint-config": "3.28.0",
|
|
63
|
-
"payload": "4.0.0-internal.
|
|
58
|
+
"payload": "4.0.0-internal.c2b57ce"
|
|
64
59
|
},
|
|
65
60
|
"peerDependencies": {
|
|
66
|
-
"payload": "4.0.0-internal.
|
|
61
|
+
"payload": "4.0.0-internal.c2b57ce"
|
|
67
62
|
},
|
|
68
63
|
"scripts": {
|
|
69
64
|
"build": "pnpm build:swc && pnpm build:types",
|
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
import type { BaseRawColumn as _BaseRawColumn, BuildDrizzleTable as _BuildDrizzleTable, BuildQueryJoinAliases as _BuildQueryJoinAliases, ChainedMethods as _ChainedMethods, ColumnToCodeConverter as _ColumnToCodeConverter, CountDistinct as _CountDistinct, CreateJSONQueryArgs as _CreateJSONQueryArgs, DeleteWhere as _DeleteWhere, DrizzleAdapter as _DrizzleAdapter, DrizzleTransaction as _DrizzleTransaction, DropDatabase as _DropDatabase, EnumRawColumn as _EnumRawColumn, Execute as _Execute, GenericColumn as _GenericColumn, GenericColumns as _GenericColumns, GenericPgColumn as _GenericPgColumn, GenericRelation as _GenericRelation, GenericTable as _GenericTable, IDType as _IDType, Insert as _Insert, IntegerRawColumn as _IntegerRawColumn, Migration as _Migration, PostgresDB as _PostgresDB, RawColumn as _RawColumn, RawForeignKey as _RawForeignKey, RawIndex as _RawIndex, RawRelation as _RawRelation, RawTable as _RawTable, RelationMap as _RelationMap, RequireDrizzleKit as _RequireDrizzleKit, SetColumnID as _SetColumnID, SQLiteDB as _SQLiteDB, TimestampRawColumn as _TimestampRawColumn, TransactionPg as _TransactionPg, TransactionSQLite as _TransactionSQLite, UUIDRawColumn as _UUIDRawColumn, VectorRawColumn as _VectorRawColumn } from '../types.js';
|
|
2
|
-
/**
|
|
3
|
-
* @deprecated - import from `@payloadcms/drizzle` instead
|
|
4
|
-
*/
|
|
5
|
-
export type BaseRawColumn = _BaseRawColumn;
|
|
6
|
-
/**
|
|
7
|
-
* @deprecated - import from `@payloadcms/drizzle` instead
|
|
8
|
-
*/
|
|
9
|
-
export type BuildDrizzleTable = _BuildDrizzleTable;
|
|
10
|
-
/**
|
|
11
|
-
* @deprecated - import from `@payloadcms/drizzle` instead
|
|
12
|
-
*/
|
|
13
|
-
export type BuildQueryJoinAliases = _BuildQueryJoinAliases;
|
|
14
|
-
/**
|
|
15
|
-
* @deprecated - import from `@payloadcms/drizzle` instead
|
|
16
|
-
*/
|
|
17
|
-
export type ChainedMethods = _ChainedMethods;
|
|
18
|
-
/**
|
|
19
|
-
* @deprecated - import from `@payloadcms/drizzle` instead
|
|
20
|
-
*/
|
|
21
|
-
export type ColumnToCodeConverter = _ColumnToCodeConverter;
|
|
22
|
-
/**
|
|
23
|
-
* @deprecated - import from `@payloadcms/drizzle` instead
|
|
24
|
-
*/
|
|
25
|
-
export type CountDistinct = _CountDistinct;
|
|
26
|
-
/**
|
|
27
|
-
* @deprecated - import from `@payloadcms/drizzle` instead
|
|
28
|
-
*/
|
|
29
|
-
export type CreateJSONQueryArgs = _CreateJSONQueryArgs;
|
|
30
|
-
/**
|
|
31
|
-
* @deprecated - import from `@payloadcms/drizzle` instead
|
|
32
|
-
*/
|
|
33
|
-
export type DeleteWhere = _DeleteWhere;
|
|
34
|
-
/**
|
|
35
|
-
* @deprecated - import from `@payloadcms/drizzle` instead
|
|
36
|
-
*/
|
|
37
|
-
export type DrizzleAdapter = _DrizzleAdapter;
|
|
38
|
-
/**
|
|
39
|
-
* @deprecated - import from `@payloadcms/drizzle` instead
|
|
40
|
-
*/
|
|
41
|
-
export type DrizzleTransaction = _DrizzleTransaction;
|
|
42
|
-
/**
|
|
43
|
-
* @deprecated - import from `@payloadcms/drizzle` instead
|
|
44
|
-
*/
|
|
45
|
-
export type DropDatabase = _DropDatabase;
|
|
46
|
-
/**
|
|
47
|
-
* @deprecated - import from `@payloadcms/drizzle` instead
|
|
48
|
-
*/
|
|
49
|
-
export type EnumRawColumn = _EnumRawColumn;
|
|
50
|
-
/**
|
|
51
|
-
* @deprecated - import from `@payloadcms/drizzle` instead
|
|
52
|
-
*/
|
|
53
|
-
export type Execute<T> = _Execute<T>;
|
|
54
|
-
/**
|
|
55
|
-
* @deprecated - import from `@payloadcms/drizzle` instead
|
|
56
|
-
*/
|
|
57
|
-
export type GenericColumn = _GenericColumn;
|
|
58
|
-
/**
|
|
59
|
-
* @deprecated - import from `@payloadcms/drizzle` instead
|
|
60
|
-
*/
|
|
61
|
-
export type GenericColumns<T> = _GenericColumns<T>;
|
|
62
|
-
/**
|
|
63
|
-
* @deprecated - import from `@payloadcms/drizzle` instead
|
|
64
|
-
*/
|
|
65
|
-
export type GenericPgColumn = _GenericPgColumn;
|
|
66
|
-
/**
|
|
67
|
-
* @deprecated - import from `@payloadcms/drizzle` instead
|
|
68
|
-
*/
|
|
69
|
-
export type GenericRelation = _GenericRelation;
|
|
70
|
-
/**
|
|
71
|
-
* @deprecated - import from `@payloadcms/drizzle` instead
|
|
72
|
-
*/
|
|
73
|
-
export type GenericTable = _GenericTable;
|
|
74
|
-
/**
|
|
75
|
-
* @deprecated - import from `@payloadcms/drizzle` instead
|
|
76
|
-
*/
|
|
77
|
-
export type IDType = _IDType;
|
|
78
|
-
/**
|
|
79
|
-
* @deprecated - import from `@payloadcms/drizzle` instead
|
|
80
|
-
*/
|
|
81
|
-
export type Insert = _Insert;
|
|
82
|
-
/**
|
|
83
|
-
* @deprecated - import from `@payloadcms/drizzle` instead
|
|
84
|
-
*/
|
|
85
|
-
export type IntegerRawColumn = _IntegerRawColumn;
|
|
86
|
-
/**
|
|
87
|
-
* @deprecated - import from `@payloadcms/drizzle` instead
|
|
88
|
-
*/
|
|
89
|
-
export type Migration = _Migration;
|
|
90
|
-
/**
|
|
91
|
-
* @deprecated - import from `@payloadcms/drizzle` instead
|
|
92
|
-
*/
|
|
93
|
-
export type PostgresDB = _PostgresDB;
|
|
94
|
-
/**
|
|
95
|
-
* @deprecated - import from `@payloadcms/drizzle` instead
|
|
96
|
-
*/
|
|
97
|
-
export type RawColumn = _RawColumn;
|
|
98
|
-
/**
|
|
99
|
-
* @deprecated - import from `@payloadcms/drizzle` instead
|
|
100
|
-
*/
|
|
101
|
-
export type RawForeignKey = _RawForeignKey;
|
|
102
|
-
/**
|
|
103
|
-
* @deprecated - import from `@payloadcms/drizzle` instead
|
|
104
|
-
*/
|
|
105
|
-
export type RawIndex = _RawIndex;
|
|
106
|
-
/**
|
|
107
|
-
* @deprecated - import from `@payloadcms/drizzle` instead
|
|
108
|
-
*/
|
|
109
|
-
export type RawRelation = _RawRelation;
|
|
110
|
-
/**
|
|
111
|
-
* @deprecated - import from `@payloadcms/drizzle` instead
|
|
112
|
-
*/
|
|
113
|
-
export type RawTable = _RawTable;
|
|
114
|
-
/**
|
|
115
|
-
* @deprecated - import from `@payloadcms/drizzle` instead
|
|
116
|
-
*/
|
|
117
|
-
export type RelationMap = _RelationMap;
|
|
118
|
-
/**
|
|
119
|
-
* @deprecated - import from `@payloadcms/drizzle` instead
|
|
120
|
-
*/
|
|
121
|
-
export type RequireDrizzleKit = _RequireDrizzleKit;
|
|
122
|
-
/**
|
|
123
|
-
* @deprecated - import from `@payloadcms/drizzle` instead
|
|
124
|
-
*/
|
|
125
|
-
export type SetColumnID = _SetColumnID;
|
|
126
|
-
/**
|
|
127
|
-
* @deprecated - import from `@payloadcms/drizzle` instead
|
|
128
|
-
*/
|
|
129
|
-
export type SQLiteDB = _SQLiteDB;
|
|
130
|
-
/**
|
|
131
|
-
* @deprecated - import from `@payloadcms/drizzle` instead
|
|
132
|
-
*/
|
|
133
|
-
export type TimestampRawColumn = _TimestampRawColumn;
|
|
134
|
-
/**
|
|
135
|
-
* @deprecated - import from `@payloadcms/drizzle` instead
|
|
136
|
-
*/
|
|
137
|
-
export type TransactionPg = _TransactionPg;
|
|
138
|
-
/**
|
|
139
|
-
* @deprecated - import from `@payloadcms/drizzle` instead
|
|
140
|
-
*/
|
|
141
|
-
export type TransactionSQLite = _TransactionSQLite;
|
|
142
|
-
/**
|
|
143
|
-
* @deprecated - import from `@payloadcms/drizzle` instead
|
|
144
|
-
*/
|
|
145
|
-
export type UUIDRawColumn = _UUIDRawColumn;
|
|
146
|
-
/**
|
|
147
|
-
* @deprecated - import from `@payloadcms/drizzle` instead
|
|
148
|
-
*/
|
|
149
|
-
export type VectorRawColumn = _VectorRawColumn;
|
|
150
|
-
//# sourceMappingURL=types-deprecated.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types-deprecated.d.ts","sourceRoot":"","sources":["../../src/exports/types-deprecated.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,IAAI,cAAc,EAC/B,iBAAiB,IAAI,kBAAkB,EACvC,qBAAqB,IAAI,sBAAsB,EAC/C,cAAc,IAAI,eAAe,EACjC,qBAAqB,IAAI,sBAAsB,EAC/C,aAAa,IAAI,cAAc,EAC/B,mBAAmB,IAAI,oBAAoB,EAC3C,WAAW,IAAI,YAAY,EAC3B,cAAc,IAAI,eAAe,EACjC,kBAAkB,IAAI,mBAAmB,EACzC,YAAY,IAAI,aAAa,EAC7B,aAAa,IAAI,cAAc,EAC/B,OAAO,IAAI,QAAQ,EACnB,aAAa,IAAI,cAAc,EAC/B,cAAc,IAAI,eAAe,EACjC,eAAe,IAAI,gBAAgB,EACnC,eAAe,IAAI,gBAAgB,EACnC,YAAY,IAAI,aAAa,EAC7B,MAAM,IAAI,OAAO,EACjB,MAAM,IAAI,OAAO,EACjB,gBAAgB,IAAI,iBAAiB,EACrC,SAAS,IAAI,UAAU,EACvB,UAAU,IAAI,WAAW,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AAA;AAC1C;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,gBAAgB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/exports/types-deprecated.ts"],"sourcesContent":["import type {\n BaseRawColumn as _BaseRawColumn,\n BuildDrizzleTable as _BuildDrizzleTable,\n BuildQueryJoinAliases as _BuildQueryJoinAliases,\n ChainedMethods as _ChainedMethods,\n ColumnToCodeConverter as _ColumnToCodeConverter,\n CountDistinct as _CountDistinct,\n CreateJSONQueryArgs as _CreateJSONQueryArgs,\n DeleteWhere as _DeleteWhere,\n DrizzleAdapter as _DrizzleAdapter,\n DrizzleTransaction as _DrizzleTransaction,\n DropDatabase as _DropDatabase,\n EnumRawColumn as _EnumRawColumn,\n Execute as _Execute,\n GenericColumn as _GenericColumn,\n GenericColumns as _GenericColumns,\n GenericPgColumn as _GenericPgColumn,\n GenericRelation as _GenericRelation,\n GenericTable as _GenericTable,\n IDType as _IDType,\n Insert as _Insert,\n IntegerRawColumn as _IntegerRawColumn,\n Migration as _Migration,\n PostgresDB as _PostgresDB,\n RawColumn as _RawColumn,\n RawForeignKey as _RawForeignKey,\n RawIndex as _RawIndex,\n RawRelation as _RawRelation,\n RawTable as _RawTable,\n RelationMap as _RelationMap,\n RequireDrizzleKit as _RequireDrizzleKit,\n SetColumnID as _SetColumnID,\n SQLiteDB as _SQLiteDB,\n TimestampRawColumn as _TimestampRawColumn,\n TransactionPg as _TransactionPg,\n TransactionSQLite as _TransactionSQLite,\n UUIDRawColumn as _UUIDRawColumn,\n VectorRawColumn as _VectorRawColumn,\n} from '../types.js'\n\n/**\n * @deprecated - import from `@payloadcms/drizzle` instead\n */\nexport type BaseRawColumn = _BaseRawColumn\n/**\n * @deprecated - import from `@payloadcms/drizzle` instead\n */\nexport type BuildDrizzleTable = _BuildDrizzleTable\n/**\n * @deprecated - import from `@payloadcms/drizzle` instead\n */\nexport type BuildQueryJoinAliases = _BuildQueryJoinAliases\n/**\n * @deprecated - import from `@payloadcms/drizzle` instead\n */\nexport type ChainedMethods = _ChainedMethods\n/**\n * @deprecated - import from `@payloadcms/drizzle` instead\n */\nexport type ColumnToCodeConverter = _ColumnToCodeConverter\n/**\n * @deprecated - import from `@payloadcms/drizzle` instead\n */\nexport type CountDistinct = _CountDistinct\n/**\n * @deprecated - import from `@payloadcms/drizzle` instead\n */\nexport type CreateJSONQueryArgs = _CreateJSONQueryArgs\n/**\n * @deprecated - import from `@payloadcms/drizzle` instead\n */\nexport type DeleteWhere = _DeleteWhere\n/**\n * @deprecated - import from `@payloadcms/drizzle` instead\n */\nexport type DrizzleAdapter = _DrizzleAdapter\n/**\n * @deprecated - import from `@payloadcms/drizzle` instead\n */\nexport type DrizzleTransaction = _DrizzleTransaction\n/**\n * @deprecated - import from `@payloadcms/drizzle` instead\n */\nexport type DropDatabase = _DropDatabase\n/**\n * @deprecated - import from `@payloadcms/drizzle` instead\n */\nexport type EnumRawColumn = _EnumRawColumn\n/**\n * @deprecated - import from `@payloadcms/drizzle` instead\n */\nexport type Execute<T> = _Execute<T>\n/**\n * @deprecated - import from `@payloadcms/drizzle` instead\n */\nexport type GenericColumn = _GenericColumn\n/**\n * @deprecated - import from `@payloadcms/drizzle` instead\n */\nexport type GenericColumns<T> = _GenericColumns<T>\n/**\n * @deprecated - import from `@payloadcms/drizzle` instead\n */\nexport type GenericPgColumn = _GenericPgColumn\n/**\n * @deprecated - import from `@payloadcms/drizzle` instead\n */\nexport type GenericRelation = _GenericRelation\n/**\n * @deprecated - import from `@payloadcms/drizzle` instead\n */\nexport type GenericTable = _GenericTable\n/**\n * @deprecated - import from `@payloadcms/drizzle` instead\n */\nexport type IDType = _IDType\n/**\n * @deprecated - import from `@payloadcms/drizzle` instead\n */\nexport type Insert = _Insert\n/**\n * @deprecated - import from `@payloadcms/drizzle` instead\n */\nexport type IntegerRawColumn = _IntegerRawColumn\n/**\n * @deprecated - import from `@payloadcms/drizzle` instead\n */\nexport type Migration = _Migration\n/**\n * @deprecated - import from `@payloadcms/drizzle` instead\n */\nexport type PostgresDB = _PostgresDB\n/**\n * @deprecated - import from `@payloadcms/drizzle` instead\n */\nexport type RawColumn = _RawColumn\n/**\n * @deprecated - import from `@payloadcms/drizzle` instead\n */\nexport type RawForeignKey = _RawForeignKey\n/**\n * @deprecated - import from `@payloadcms/drizzle` instead\n */\nexport type RawIndex = _RawIndex\n/**\n * @deprecated - import from `@payloadcms/drizzle` instead\n */\nexport type RawRelation = _RawRelation\n/**\n * @deprecated - import from `@payloadcms/drizzle` instead\n */\nexport type RawTable = _RawTable\n/**\n * @deprecated - import from `@payloadcms/drizzle` instead\n */\nexport type RelationMap = _RelationMap\n/**\n * @deprecated - import from `@payloadcms/drizzle` instead\n */\nexport type RequireDrizzleKit = _RequireDrizzleKit\n/**\n * @deprecated - import from `@payloadcms/drizzle` instead\n */\nexport type SetColumnID = _SetColumnID\n/**\n * @deprecated - import from `@payloadcms/drizzle` instead\n */\nexport type SQLiteDB = _SQLiteDB\n/**\n * @deprecated - import from `@payloadcms/drizzle` instead\n */\nexport type TimestampRawColumn = _TimestampRawColumn\n/**\n * @deprecated - import from `@payloadcms/drizzle` instead\n */\nexport type TransactionPg = _TransactionPg\n/**\n * @deprecated - import from `@payloadcms/drizzle` instead\n */\nexport type TransactionSQLite = _TransactionSQLite\n/**\n * @deprecated - import from `@payloadcms/drizzle` instead\n */\nexport type UUIDRawColumn = _UUIDRawColumn\n/**\n * @deprecated - import from `@payloadcms/drizzle` instead\n */\nexport type VectorRawColumn = _VectorRawColumn\n"],"names":[],"mappings":"AAwLA;;CAEC,GACD,WAA8C"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { PayloadRequest } from 'payload';
|
|
2
|
-
import type { DrizzleAdapter } from './types.js';
|
|
3
|
-
export declare function migrateVersionsEnabled(this: DrizzleAdapter, args: {
|
|
4
|
-
entity: 'collection' | 'global';
|
|
5
|
-
initialStatus: 'draft' | 'published';
|
|
6
|
-
req: PayloadRequest;
|
|
7
|
-
slug: string;
|
|
8
|
-
}): Promise<void>;
|
|
9
|
-
//# sourceMappingURL=migrateVersionsEnabled.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"migrateVersionsEnabled.d.ts","sourceRoot":"","sources":["../src/migrateVersionsEnabled.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAI7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAIhD,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,cAAc,EACpB,IAAI,EAAE;IACJ,MAAM,EAAE,YAAY,GAAG,QAAQ,CAAA;IAC/B,aAAa,EAAE,OAAO,GAAG,WAAW,CAAA;IACpC,GAAG,EAAE,cAAc,CAAA;IACnB,IAAI,EAAE,MAAM,CAAA;CACb,GACA,OAAO,CAAC,IAAI,CAAC,CAsCf"}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { batchTransform } from 'payload/migrations';
|
|
2
|
-
const BATCH_SIZE = 1000;
|
|
3
|
-
export async function migrateVersionsEnabled(args) {
|
|
4
|
-
const { slug, entity, initialStatus, req } = args;
|
|
5
|
-
const { payload } = this;
|
|
6
|
-
payload.logger.info(`[config-migration] Creating version entries for existing ${entity} "${slug}" with _status: ${initialStatus}`);
|
|
7
|
-
if (entity === 'collection') {
|
|
8
|
-
await batchTransform({
|
|
9
|
-
batchSize: BATCH_SIZE,
|
|
10
|
-
fetcher: ({ limit, page })=>payload.db.find({
|
|
11
|
-
collection: slug,
|
|
12
|
-
limit,
|
|
13
|
-
page,
|
|
14
|
-
pagination: true,
|
|
15
|
-
req
|
|
16
|
-
}),
|
|
17
|
-
transform: async (doc)=>{
|
|
18
|
-
await payload.db.createVersion({
|
|
19
|
-
autosave: false,
|
|
20
|
-
collectionSlug: slug,
|
|
21
|
-
createdAt: doc.createdAt ?? new Date().toISOString(),
|
|
22
|
-
parent: doc.id,
|
|
23
|
-
req,
|
|
24
|
-
updatedAt: doc.updatedAt ?? new Date().toISOString(),
|
|
25
|
-
versionData: {
|
|
26
|
-
...doc,
|
|
27
|
-
_status: initialStatus
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
} else {
|
|
33
|
-
const globalDoc = await payload.db.findGlobal({
|
|
34
|
-
slug,
|
|
35
|
-
req
|
|
36
|
-
});
|
|
37
|
-
await payload.db.createGlobalVersion({
|
|
38
|
-
autosave: false,
|
|
39
|
-
createdAt: globalDoc.createdAt ?? new Date().toISOString(),
|
|
40
|
-
globalSlug: slug,
|
|
41
|
-
req,
|
|
42
|
-
updatedAt: globalDoc.updatedAt ?? new Date().toISOString(),
|
|
43
|
-
versionData: {
|
|
44
|
-
...globalDoc,
|
|
45
|
-
_status: initialStatus
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
payload.logger.info(`[config-migration] Done creating version entries for "${slug}"`);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
//# sourceMappingURL=migrateVersionsEnabled.js.map
|