@payloadcms/drizzle 3.7.1-canary.a7f8738 → 3.8.0
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/exports/postgres.d.ts +0 -2
- package/dist/exports/postgres.d.ts.map +1 -1
- package/dist/exports/postgres.js +0 -2
- package/dist/exports/postgres.js.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/postgres/createMigration.d.ts +3 -0
- package/dist/postgres/createMigration.d.ts.map +1 -0
- package/dist/postgres/createMigration.js +91 -0
- package/dist/postgres/createMigration.js.map +1 -0
- package/dist/postgres/getMigrationTemplate.d.ts +4 -0
- package/dist/postgres/getMigrationTemplate.d.ts.map +1 -0
- package/dist/postgres/getMigrationTemplate.js +13 -0
- package/dist/postgres/getMigrationTemplate.js.map +1 -0
- package/dist/postgres/init.d.ts.map +1 -1
- package/dist/postgres/init.js +3 -7
- package/dist/postgres/init.js.map +1 -1
- package/dist/postgres/schema/build.d.ts +42 -0
- package/dist/postgres/schema/build.d.ts.map +1 -0
- package/dist/postgres/schema/build.js +404 -0
- package/dist/postgres/schema/build.js.map +1 -0
- package/dist/postgres/schema/buildDrizzleTable.d.ts.map +1 -1
- package/dist/postgres/schema/buildDrizzleTable.js +7 -3
- package/dist/postgres/schema/buildDrizzleTable.js.map +1 -1
- package/dist/postgres/schema/createIndex.d.ts +11 -0
- package/dist/postgres/schema/createIndex.d.ts.map +1 -0
- package/dist/postgres/schema/createIndex.js +20 -0
- package/dist/postgres/schema/createIndex.js.map +1 -0
- package/dist/postgres/schema/idToUUID.d.ts +3 -0
- package/dist/postgres/schema/idToUUID.d.ts.map +1 -0
- package/dist/postgres/schema/idToUUID.js +11 -0
- package/dist/postgres/schema/idToUUID.js.map +1 -0
- package/dist/postgres/schema/parentIDColumnMap.d.ts +4 -0
- package/dist/postgres/schema/parentIDColumnMap.d.ts.map +1 -0
- package/dist/postgres/schema/parentIDColumnMap.js +9 -0
- package/dist/postgres/schema/parentIDColumnMap.js.map +1 -0
- package/dist/postgres/schema/traverseFields.d.ts +42 -0
- package/dist/postgres/schema/traverseFields.d.ts.map +1 -0
- package/dist/postgres/schema/traverseFields.js +599 -0
- package/dist/postgres/schema/traverseFields.js.map +1 -0
- package/dist/postgres/schema/withDefault.d.ts +2 -2
- package/dist/postgres/schema/withDefault.d.ts.map +1 -1
- package/dist/postgres/schema/withDefault.js +3 -12
- package/dist/postgres/schema/withDefault.js.map +1 -1
- package/dist/schema/build.js +4 -4
- package/dist/schema/build.js.map +1 -1
- package/dist/schema/buildDrizzleRelations.d.ts +2 -4
- package/dist/schema/buildDrizzleRelations.d.ts.map +1 -1
- package/dist/schema/buildDrizzleRelations.js +21 -18
- package/dist/schema/buildDrizzleRelations.js.map +1 -1
- package/dist/schema/traverseFields.js +9 -4
- package/dist/schema/traverseFields.js.map +1 -1
- package/dist/schema/withDefault.d.ts.map +1 -1
- package/dist/schema/withDefault.js +0 -6
- package/dist/schema/withDefault.js.map +1 -1
- package/dist/transform/read/traverseFields.d.ts.map +1 -1
- package/dist/transform/read/traverseFields.js +7 -0
- package/dist/transform/read/traverseFields.js.map +1 -1
- package/dist/types.d.ts +40 -15
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +3 -3
- package/dist/postgres/columnToCodeConverter.d.ts +0 -3
- package/dist/postgres/columnToCodeConverter.d.ts.map +0 -1
- package/dist/postgres/columnToCodeConverter.js +0 -64
- package/dist/postgres/columnToCodeConverter.js.map +0 -1
- package/dist/utilities/createSchemaGenerator.d.ts +0 -11
- package/dist/utilities/createSchemaGenerator.d.ts.map +0 -1
- package/dist/utilities/createSchemaGenerator.js +0 -216
- package/dist/utilities/createSchemaGenerator.js.map +0 -1
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export { columnToCodeConverter } from '../postgres/columnToCodeConverter.js';
|
|
2
1
|
export { countDistinct } from '../postgres/countDistinct.js';
|
|
3
2
|
export { createDatabase } from '../postgres/createDatabase.js';
|
|
4
3
|
export { createExtensions } from '../postgres/createExtensions.js';
|
|
@@ -11,6 +10,5 @@ export { init } from '../postgres/init.js';
|
|
|
11
10
|
export { insert } from '../postgres/insert.js';
|
|
12
11
|
export { migratePostgresV2toV3 } from '../postgres/predefinedMigrations/v2-v3/index.js';
|
|
13
12
|
export { requireDrizzleKit } from '../postgres/requireDrizzleKit.js';
|
|
14
|
-
export { geometryColumn } from '../postgres/schema/geometryColumn.js';
|
|
15
13
|
export * from '../postgres/types.js';
|
|
16
14
|
//# sourceMappingURL=postgres.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postgres.d.ts","sourceRoot":"","sources":["../../src/exports/postgres.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"postgres.d.ts","sourceRoot":"","sources":["../../src/exports/postgres.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAA;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAA;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAA;AACtE,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAA;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAA;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,iDAAiD,CAAA;AACvF,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AACpE,cAAc,sBAAsB,CAAA"}
|
package/dist/exports/postgres.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export { columnToCodeConverter } from '../postgres/columnToCodeConverter.js';
|
|
2
1
|
export { countDistinct } from '../postgres/countDistinct.js';
|
|
3
2
|
export { createDatabase } from '../postgres/createDatabase.js';
|
|
4
3
|
export { createExtensions } from '../postgres/createExtensions.js';
|
|
@@ -11,7 +10,6 @@ export { init } from '../postgres/init.js';
|
|
|
11
10
|
export { insert } from '../postgres/insert.js';
|
|
12
11
|
export { migratePostgresV2toV3 } from '../postgres/predefinedMigrations/v2-v3/index.js';
|
|
13
12
|
export { requireDrizzleKit } from '../postgres/requireDrizzleKit.js';
|
|
14
|
-
export { geometryColumn } from '../postgres/schema/geometryColumn.js';
|
|
15
13
|
export * from '../postgres/types.js';
|
|
16
14
|
|
|
17
15
|
//# sourceMappingURL=postgres.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/exports/postgres.ts"],"sourcesContent":["export {
|
|
1
|
+
{"version":3,"sources":["../../src/exports/postgres.ts"],"sourcesContent":["export { countDistinct } from '../postgres/countDistinct.js'\nexport { createDatabase } from '../postgres/createDatabase.js'\nexport { createExtensions } from '../postgres/createExtensions.js'\nexport { createJSONQuery } from '../postgres/createJSONQuery/index.js'\nexport { defaultDrizzleSnapshot } from '../postgres/defaultSnapshot.js'\nexport { deleteWhere } from '../postgres/deleteWhere.js'\nexport { dropDatabase } from '../postgres/dropDatabase.js'\nexport { execute } from '../postgres/execute.js'\nexport { init } from '../postgres/init.js'\nexport { insert } from '../postgres/insert.js'\nexport { migratePostgresV2toV3 } from '../postgres/predefinedMigrations/v2-v3/index.js'\nexport { requireDrizzleKit } from '../postgres/requireDrizzleKit.js'\nexport * from '../postgres/types.js'\n"],"names":["countDistinct","createDatabase","createExtensions","createJSONQuery","defaultDrizzleSnapshot","deleteWhere","dropDatabase","execute","init","insert","migratePostgresV2toV3","requireDrizzleKit"],"mappings":"AAAA,SAASA,aAAa,QAAQ,+BAA8B;AAC5D,SAASC,cAAc,QAAQ,gCAA+B;AAC9D,SAASC,gBAAgB,QAAQ,kCAAiC;AAClE,SAASC,eAAe,QAAQ,uCAAsC;AACtE,SAASC,sBAAsB,QAAQ,iCAAgC;AACvE,SAASC,WAAW,QAAQ,6BAA4B;AACxD,SAASC,YAAY,QAAQ,8BAA6B;AAC1D,SAASC,OAAO,QAAQ,yBAAwB;AAChD,SAASC,IAAI,QAAQ,sBAAqB;AAC1C,SAASC,MAAM,QAAQ,wBAAuB;AAC9C,SAASC,qBAAqB,QAAQ,kDAAiD;AACvF,SAASC,iBAAiB,QAAQ,mCAAkC;AACpE,cAAc,uBAAsB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -38,7 +38,6 @@ export { updateVersion } from './updateVersion.js';
|
|
|
38
38
|
export { upsertRow } from './upsertRow/index.js';
|
|
39
39
|
export { buildCreateMigration } from './utilities/buildCreateMigration.js';
|
|
40
40
|
export { buildIndexName } from './utilities/buildIndexName.js';
|
|
41
|
-
export { createSchemaGenerator } from './utilities/createSchemaGenerator.js';
|
|
42
41
|
export { executeSchemaHooks } from './utilities/executeSchemaHooks.js';
|
|
43
42
|
export { extendDrizzleTable } from './utilities/extendDrizzleTable.js';
|
|
44
43
|
export { hasLocalesTable } from './utilities/hasLocalesTable.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAA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0BAA0B,CAAA;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAA;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAA;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAA;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAA;AAC5D,OAAO,EAAE,gCAAgC,EAAE,MAAM,iDAAiD,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -37,7 +37,6 @@ export { updateVersion } from './updateVersion.js';
|
|
|
37
37
|
export { upsertRow } from './upsertRow/index.js';
|
|
38
38
|
export { buildCreateMigration } from './utilities/buildCreateMigration.js';
|
|
39
39
|
export { buildIndexName } from './utilities/buildIndexName.js';
|
|
40
|
-
export { createSchemaGenerator } from './utilities/createSchemaGenerator.js';
|
|
41
40
|
export { executeSchemaHooks } from './utilities/executeSchemaHooks.js';
|
|
42
41
|
export { extendDrizzleTable } from './utilities/extendDrizzleTable.js';
|
|
43
42
|
export { hasLocalesTable } from './utilities/hasLocalesTable.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export { count } from './count.js'\nexport { countGlobalVersions } from './countGlobalVersions.js'\nexport { countVersions } from './countVersions.js'\nexport { create } from './create.js'\nexport { createGlobal } from './createGlobal.js'\nexport { createGlobalVersion } from './createGlobalVersion.js'\nexport { createTableName } from './createTableName.js'\nexport { createVersion } from './createVersion.js'\nexport { deleteMany } from './deleteMany.js'\nexport { deleteOne } from './deleteOne.js'\nexport { deleteVersions } from './deleteVersions.js'\nexport { destroy } from './destroy.js'\nexport { find } from './find.js'\nexport { chainMethods } from './find/chainMethods.js'\nexport { findGlobal } from './findGlobal.js'\nexport { findGlobalVersions } from './findGlobalVersions.js'\nexport { findMigrationDir } from './findMigrationDir.js'\nexport { findOne } from './findOne.js'\nexport { findVersions } from './findVersions.js'\nexport { migrate } from './migrate.js'\nexport { migrateDown } from './migrateDown.js'\nexport { migrateFresh } from './migrateFresh.js'\nexport { migrateRefresh } from './migrateRefresh.js'\nexport { migrateReset } from './migrateReset.js'\nexport { migrateStatus } from './migrateStatus.js'\nexport { operatorMap } from './queries/operatorMap.js'\nexport type { Operators } from './queries/operatorMap.js'\nexport { queryDrafts } from './queryDrafts.js'\nexport { buildDrizzleRelations } from './schema/buildDrizzleRelations.js'\nexport { buildRawSchema } from './schema/buildRawSchema.js'\nexport { beginTransaction } from './transactions/beginTransaction.js'\nexport { commitTransaction } from './transactions/commitTransaction.js'\nexport { rollbackTransaction } from './transactions/rollbackTransaction.js'\nexport { updateOne } from './update.js'\nexport { updateGlobal } from './updateGlobal.js'\nexport { updateGlobalVersion } from './updateGlobalVersion.js'\nexport { updateVersion } from './updateVersion.js'\nexport { upsertRow } from './upsertRow/index.js'\nexport { buildCreateMigration } from './utilities/buildCreateMigration.js'\nexport { buildIndexName } from './utilities/buildIndexName.js'\nexport {
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export { count } from './count.js'\nexport { countGlobalVersions } from './countGlobalVersions.js'\nexport { countVersions } from './countVersions.js'\nexport { create } from './create.js'\nexport { createGlobal } from './createGlobal.js'\nexport { createGlobalVersion } from './createGlobalVersion.js'\nexport { createTableName } from './createTableName.js'\nexport { createVersion } from './createVersion.js'\nexport { deleteMany } from './deleteMany.js'\nexport { deleteOne } from './deleteOne.js'\nexport { deleteVersions } from './deleteVersions.js'\nexport { destroy } from './destroy.js'\nexport { find } from './find.js'\nexport { chainMethods } from './find/chainMethods.js'\nexport { findGlobal } from './findGlobal.js'\nexport { findGlobalVersions } from './findGlobalVersions.js'\nexport { findMigrationDir } from './findMigrationDir.js'\nexport { findOne } from './findOne.js'\nexport { findVersions } from './findVersions.js'\nexport { migrate } from './migrate.js'\nexport { migrateDown } from './migrateDown.js'\nexport { migrateFresh } from './migrateFresh.js'\nexport { migrateRefresh } from './migrateRefresh.js'\nexport { migrateReset } from './migrateReset.js'\nexport { migrateStatus } from './migrateStatus.js'\nexport { operatorMap } from './queries/operatorMap.js'\nexport type { Operators } from './queries/operatorMap.js'\nexport { queryDrafts } from './queryDrafts.js'\nexport { buildDrizzleRelations } from './schema/buildDrizzleRelations.js'\nexport { buildRawSchema } from './schema/buildRawSchema.js'\nexport { beginTransaction } from './transactions/beginTransaction.js'\nexport { commitTransaction } from './transactions/commitTransaction.js'\nexport { rollbackTransaction } from './transactions/rollbackTransaction.js'\nexport { updateOne } from './update.js'\nexport { updateGlobal } from './updateGlobal.js'\nexport { updateGlobalVersion } from './updateGlobalVersion.js'\nexport { updateVersion } from './updateVersion.js'\nexport { upsertRow } from './upsertRow/index.js'\nexport { buildCreateMigration } from './utilities/buildCreateMigration.js'\nexport { buildIndexName } from './utilities/buildIndexName.js'\nexport { executeSchemaHooks } from './utilities/executeSchemaHooks.js'\nexport { extendDrizzleTable } from './utilities/extendDrizzleTable.js'\nexport { hasLocalesTable } from './utilities/hasLocalesTable.js'\nexport { pushDevSchema } from './utilities/pushDevSchema.js'\nexport { validateExistingBlockIsIdentical } from './utilities/validateExistingBlockIsIdentical.js'\n"],"names":["count","countGlobalVersions","countVersions","create","createGlobal","createGlobalVersion","createTableName","createVersion","deleteMany","deleteOne","deleteVersions","destroy","find","chainMethods","findGlobal","findGlobalVersions","findMigrationDir","findOne","findVersions","migrate","migrateDown","migrateFresh","migrateRefresh","migrateReset","migrateStatus","operatorMap","queryDrafts","buildDrizzleRelations","buildRawSchema","beginTransaction","commitTransaction","rollbackTransaction","updateOne","updateGlobal","updateGlobalVersion","updateVersion","upsertRow","buildCreateMigration","buildIndexName","execute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ChD,SAASC,mBAAmB,QAAQ,2BAA0B;AAC9D,SAASC,aAAa,QAAQ,qBAAoB;AAClD,SAASC,SAAS,QAAQ,uBAAsB;AAChD,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,cAAc,QAAQ,gCAA+B;AAC9D,SAASC,kBAAkB,QAAQ,oCAAmC;AACtE,SAASC,kBAAkB,QAAQ,oCAAmC;AACtE,SAASC,eAAe,QAAQ,iCAAgC;AAChE,SAASC,aAAa,QAAQ,+BAA8B;AAC5D,SAASC,gCAAgC,QAAQ,kDAAiD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createMigration.d.ts","sourceRoot":"","sources":["../../src/postgres/createMigration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAc9C,eAAO,MAAM,eAAe,EAAE,eA2G7B,CAAA"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import { createRequire } from 'module';
|
|
3
|
+
import { getPredefinedMigration, writeMigrationIndex } from 'payload';
|
|
4
|
+
import prompts from 'prompts';
|
|
5
|
+
import { defaultDrizzleSnapshot } from './defaultSnapshot.js';
|
|
6
|
+
import { getMigrationTemplate } from './getMigrationTemplate.js';
|
|
7
|
+
const require = createRequire(import.meta.url);
|
|
8
|
+
export const createMigration = async function createMigration({ dirname, file, forceAcceptWarning, migrationName, payload, skipEmpty }) {
|
|
9
|
+
const dir = payload.db.migrationDir;
|
|
10
|
+
if (!fs.existsSync(dir)) {
|
|
11
|
+
fs.mkdirSync(dir);
|
|
12
|
+
}
|
|
13
|
+
const { generateDrizzleJson, generateMigration, upPgSnapshot } = require('drizzle-kit/api');
|
|
14
|
+
const drizzleJsonAfter = generateDrizzleJson(this.schema);
|
|
15
|
+
const [yyymmdd, hhmmss] = new Date().toISOString().split('T');
|
|
16
|
+
const formattedDate = yyymmdd.replace(/\D/g, '');
|
|
17
|
+
const formattedTime = hhmmss.split('.')[0].replace(/\D/g, '');
|
|
18
|
+
let imports = '';
|
|
19
|
+
let downSQL;
|
|
20
|
+
let upSQL;
|
|
21
|
+
({ downSQL, imports, upSQL } = await getPredefinedMigration({
|
|
22
|
+
dirname,
|
|
23
|
+
file,
|
|
24
|
+
migrationName,
|
|
25
|
+
payload
|
|
26
|
+
}));
|
|
27
|
+
const timestamp = `${formattedDate}_${formattedTime}`;
|
|
28
|
+
const name = migrationName || file?.split('/').slice(2).join('/');
|
|
29
|
+
const fileName = `${timestamp}${name ? `_${name.replace(/\W/g, '_')}` : ''}`;
|
|
30
|
+
const filePath = `${dir}/${fileName}`;
|
|
31
|
+
let drizzleJsonBefore = defaultDrizzleSnapshot;
|
|
32
|
+
if (this.schemaName) {
|
|
33
|
+
drizzleJsonBefore.schemas = {
|
|
34
|
+
[this.schemaName]: this.schemaName
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
if (!upSQL) {
|
|
38
|
+
// Get latest migration snapshot
|
|
39
|
+
const latestSnapshot = fs.readdirSync(dir).filter((file)=>file.endsWith('.json')).sort().reverse()?.[0];
|
|
40
|
+
if (latestSnapshot) {
|
|
41
|
+
drizzleJsonBefore = JSON.parse(fs.readFileSync(`${dir}/${latestSnapshot}`, 'utf8'));
|
|
42
|
+
if (drizzleJsonBefore.version < drizzleJsonAfter.version) {
|
|
43
|
+
drizzleJsonBefore = upPgSnapshot(drizzleJsonBefore);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
const sqlStatementsUp = await generateMigration(drizzleJsonBefore, drizzleJsonAfter);
|
|
47
|
+
const sqlStatementsDown = await generateMigration(drizzleJsonAfter, drizzleJsonBefore);
|
|
48
|
+
const sqlExecute = 'await payload.db.drizzle.execute(sql`';
|
|
49
|
+
if (sqlStatementsUp?.length) {
|
|
50
|
+
upSQL = `${sqlExecute}\n ${sqlStatementsUp?.join('\n')}\`)`;
|
|
51
|
+
}
|
|
52
|
+
if (sqlStatementsDown?.length) {
|
|
53
|
+
downSQL = `${sqlExecute}\n ${sqlStatementsDown?.join('\n')}\`)`;
|
|
54
|
+
}
|
|
55
|
+
if (!upSQL?.length && !downSQL?.length && !forceAcceptWarning) {
|
|
56
|
+
if (skipEmpty) {
|
|
57
|
+
process.exit(0);
|
|
58
|
+
}
|
|
59
|
+
const { confirm: shouldCreateBlankMigration } = await prompts({
|
|
60
|
+
name: 'confirm',
|
|
61
|
+
type: 'confirm',
|
|
62
|
+
initial: false,
|
|
63
|
+
message: 'No schema changes detected. Would you like to create a blank migration file?'
|
|
64
|
+
}, {
|
|
65
|
+
onCancel: ()=>{
|
|
66
|
+
process.exit(0);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
if (!shouldCreateBlankMigration) {
|
|
70
|
+
process.exit(0);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
// write schema
|
|
74
|
+
fs.writeFileSync(`${filePath}.json`, JSON.stringify(drizzleJsonAfter, null, 2));
|
|
75
|
+
}
|
|
76
|
+
// write migration
|
|
77
|
+
fs.writeFileSync(`${filePath}.ts`, getMigrationTemplate({
|
|
78
|
+
downSQL: downSQL || ` // Migration code`,
|
|
79
|
+
imports,
|
|
80
|
+
packageName: payload.db.packageName,
|
|
81
|
+
upSQL: upSQL || ` // Migration code`
|
|
82
|
+
}));
|
|
83
|
+
writeMigrationIndex({
|
|
84
|
+
migrationsDir: payload.db.migrationDir
|
|
85
|
+
});
|
|
86
|
+
payload.logger.info({
|
|
87
|
+
msg: `Migration created at ${filePath}.ts`
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
//# sourceMappingURL=createMigration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/postgres/createMigration.ts"],"sourcesContent":["import type { CreateMigration } from 'payload'\n\nimport fs from 'fs'\nimport { createRequire } from 'module'\nimport { getPredefinedMigration, writeMigrationIndex } from 'payload'\nimport prompts from 'prompts'\n\nimport type { BasePostgresAdapter } from './types.js'\n\nimport { defaultDrizzleSnapshot } from './defaultSnapshot.js'\nimport { getMigrationTemplate } from './getMigrationTemplate.js'\n\nconst require = createRequire(import.meta.url)\n\nexport const createMigration: CreateMigration = async function createMigration(\n this: BasePostgresAdapter,\n { dirname, file, forceAcceptWarning, migrationName, payload, skipEmpty },\n) {\n const dir = payload.db.migrationDir\n if (!fs.existsSync(dir)) {\n fs.mkdirSync(dir)\n }\n const { generateDrizzleJson, generateMigration, upPgSnapshot } = require('drizzle-kit/api')\n const drizzleJsonAfter = generateDrizzleJson(this.schema)\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 ;({ downSQL, imports, upSQL } = await getPredefinedMigration({\n dirname,\n file,\n migrationName,\n payload,\n }))\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 let drizzleJsonBefore = defaultDrizzleSnapshot\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 (drizzleJsonBefore.version < drizzleJsonAfter.version) {\n drizzleJsonBefore = upPgSnapshot(drizzleJsonBefore)\n }\n }\n\n const sqlStatementsUp = await generateMigration(drizzleJsonBefore, drizzleJsonAfter)\n const sqlStatementsDown = await generateMigration(drizzleJsonAfter, drizzleJsonBefore)\n const sqlExecute = 'await payload.db.drizzle.execute(sql`'\n\n if (sqlStatementsUp?.length) {\n upSQL = `${sqlExecute}\\n ${sqlStatementsUp?.join('\\n')}\\`)`\n }\n if (sqlStatementsDown?.length) {\n downSQL = `${sqlExecute}\\n ${sqlStatementsDown?.join('\\n')}\\`)`\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 // write migration\n fs.writeFileSync(\n `${filePath}.ts`,\n getMigrationTemplate({\n downSQL: downSQL || ` // Migration code`,\n imports,\n packageName: payload.db.packageName,\n upSQL: upSQL || ` // Migration code`,\n }),\n )\n\n writeMigrationIndex({ migrationsDir: payload.db.migrationDir })\n\n payload.logger.info({ msg: `Migration created at ${filePath}.ts` })\n}\n"],"names":["fs","createRequire","getPredefinedMigration","writeMigrationIndex","prompts","defaultDrizzleSnapshot","getMigrationTemplate","require","url","createMigration","dirname","file","forceAcceptWarning","migrationName","payload","skipEmpty","dir","db","migrationDir","existsSync","mkdirSync","generateDrizzleJson","generateMigration","upPgSnapshot","drizzleJsonAfter","schema","yyymmdd","hhmmss","Date","toISOString","split","formattedDate","replace","formattedTime","imports","downSQL","upSQL","timestamp","name","slice","join","fileName","filePath","drizzleJsonBefore","schemaName","schemas","latestSnapshot","readdirSync","filter","endsWith","sort","reverse","JSON","parse","readFileSync","version","sqlStatementsUp","sqlStatementsDown","sqlExecute","length","process","exit","confirm","shouldCreateBlankMigration","type","initial","message","onCancel","writeFileSync","stringify","packageName","migrationsDir","logger","info","msg"],"mappings":"AAEA,OAAOA,QAAQ,KAAI;AACnB,SAASC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AC;gBACf;YACF;YAGF,IAAI,CAACE,4BAA4B;gBAC/BH,QAAQC,IAAI,CAAC;YACf;QACF;QAEA,eAAe;QACf7D,GAAGoE,aAAa,CAAC,GAAG1B,SAAS,KAAK,CAAC,EAAEU,KAAKiB,SAAS,CAAC7C,kBAAkB,MAAM;IAC9E;IAEA,kBAAkB;IAClBxB,GAAGoE,aAAa,CACd,GAAG1B,SAAS,GAAG,CAAC,EAChBpC,qBAAqB;QACnB6B,SAASA,WAAW,CAAC,mBAAmB,CAAC;QACzCD;QACAoC,aAAaxD,QAAQG,EAAE,CAACqD,WAAW;QACnClC,OAAOA,SAAS,CAAC,mBAAmB,CAAC;IACvC;IAGFjC,oBAAoB;QAAEoE,eAAezD,QAAQG,EAAE,CAACC,YAAY;IAAC;IAE7DJ,QAAQ0D,MAAM,CAACC,IAAI,CAAC;QAAEC,KAAK,CAAC,qBAAqB,EAAEhC,SAAS,GAAG,CAAC;IAAC;AACnE,EAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { MigrationTemplateArgs } from 'payload';
|
|
2
|
+
export declare const indent: (text: string) => string;
|
|
3
|
+
export declare const getMigrationTemplate: ({ downSQL, imports, packageName, upSQL, }: MigrationTemplateArgs) => string;
|
|
4
|
+
//# sourceMappingURL=getMigrationTemplate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getMigrationTemplate.d.ts","sourceRoot":"","sources":["../../src/postgres/getMigrationTemplate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAEpD,eAAO,MAAM,MAAM,SAAU,MAAM,WAIpB,CAAA;AAEf,eAAO,MAAM,oBAAoB,8CAK9B,qBAAqB,KAAG,MAS1B,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const indent = (text)=>text.split('\n').map((line)=>` ${line}`).join('\n');
|
|
2
|
+
export const getMigrationTemplate = ({ downSQL, imports, packageName, upSQL })=>`import { MigrateUpArgs, MigrateDownArgs, sql } from '${packageName}'
|
|
3
|
+
${imports ? `${imports}\n` : ''}
|
|
4
|
+
export async function up({ payload, req }: MigrateUpArgs): Promise<void> {
|
|
5
|
+
${indent(upSQL)}
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export async function down({ payload, req }: MigrateDownArgs): Promise<void> {
|
|
9
|
+
${indent(downSQL)}
|
|
10
|
+
}
|
|
11
|
+
`;
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=getMigrationTemplate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/postgres/getMigrationTemplate.ts"],"sourcesContent":["import type { MigrationTemplateArgs } from 'payload'\n\nexport const indent = (text: string) =>\n text\n .split('\\n')\n .map((line) => ` ${line}`)\n .join('\\n')\n\nexport const getMigrationTemplate = ({\n downSQL,\n imports,\n packageName,\n upSQL,\n}: MigrationTemplateArgs): string => `import { MigrateUpArgs, MigrateDownArgs, sql } from '${packageName}'\n${imports ? `${imports}\\n` : ''}\nexport async function up({ payload, req }: MigrateUpArgs): Promise<void> {\n${indent(upSQL)}\n}\n\nexport async function down({ payload, req }: MigrateDownArgs): Promise<void> {\n${indent(downSQL)}\n}\n`\n"],"names":["indent","text","split","map","line","join","getMigrationTemplate","downSQL","imports","packageName","upSQL"],"mappings":"AAEA,OAAO,MAAMA,SAAS,CAACC,OACrBA,KACGC,KAAK,CAAC,MACNC,GAAG,CAAC,CAACC,OAAS,CAAC,EAAE,EAAEA,MAAM,EACzBC,IAAI,CAAC,MAAK;AAEf,OAAO,MAAMC,uBAAuB,CAAC,EACnCC,OAAO,EACPC,OAAO,EACPC,WAAW,EACXC,KAAK,EACiB,GAAa,CAAC,qDAAqD,EAAED,YAAY;AACzG,EAAED,UAAU,GAAGA,QAAQ,EAAE,CAAC,GAAG,GAAG;;AAEhC,EAAER,OAAOU,OAAO;;;;AAIhB,EAAEV,OAAOO,SAAS;;AAElB,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/postgres/init.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAUnC,eAAO,MAAM,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/postgres/init.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAUnC,eAAO,MAAM,IAAI,EAAE,IA2BlB,CAAA"}
|
package/dist/postgres/init.js
CHANGED
|
@@ -23,13 +23,9 @@ export const init = async function init() {
|
|
|
23
23
|
rawTable: this.rawTables[tableName]
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
rawRelations: this.rawRelations[tableName],
|
|
30
|
-
tableName
|
|
31
|
-
});
|
|
32
|
-
}
|
|
26
|
+
buildDrizzleRelations({
|
|
27
|
+
adapter: this
|
|
28
|
+
});
|
|
33
29
|
await executeSchemaHooks({
|
|
34
30
|
type: 'afterSchemaInit',
|
|
35
31
|
adapter: this
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/postgres/init.ts"],"sourcesContent":["import type { Init } from 'payload'\n\nimport type { BasePostgresAdapter } from './types.js'\n\nimport { buildDrizzleRelations } from '../schema/buildDrizzleRelations.js'\nimport { buildRawSchema } from '../schema/buildRawSchema.js'\nimport { executeSchemaHooks } from '../utilities/executeSchemaHooks.js'\nimport { buildDrizzleTable } from './schema/buildDrizzleTable.js'\nimport { setColumnID } from './schema/setColumnID.js'\n\nexport const init: Init = async function init(this: BasePostgresAdapter) {\n this.rawRelations = {}\n this.rawTables = {}\n\n buildRawSchema({\n adapter: this,\n setColumnID,\n })\n\n await executeSchemaHooks({ type: 'beforeSchemaInit', adapter: this })\n\n if (this.payload.config.localization) {\n this.enums.enum__locales = this.pgSchema.enum(\n '_locales',\n this.payload.config.localization.locales.map(({ code }) => code) as [string, ...string[]],\n )\n }\n\n for (const tableName in this.rawTables) {\n buildDrizzleTable({ adapter: this, rawTable: this.rawTables[tableName] })\n }\n\n
|
|
1
|
+
{"version":3,"sources":["../../src/postgres/init.ts"],"sourcesContent":["import type { Init } from 'payload'\n\nimport type { BasePostgresAdapter } from './types.js'\n\nimport { buildDrizzleRelations } from '../schema/buildDrizzleRelations.js'\nimport { buildRawSchema } from '../schema/buildRawSchema.js'\nimport { executeSchemaHooks } from '../utilities/executeSchemaHooks.js'\nimport { buildDrizzleTable } from './schema/buildDrizzleTable.js'\nimport { setColumnID } from './schema/setColumnID.js'\n\nexport const init: Init = async function init(this: BasePostgresAdapter) {\n this.rawRelations = {}\n this.rawTables = {}\n\n buildRawSchema({\n adapter: this,\n setColumnID,\n })\n\n await executeSchemaHooks({ type: 'beforeSchemaInit', adapter: this })\n\n if (this.payload.config.localization) {\n this.enums.enum__locales = this.pgSchema.enum(\n '_locales',\n this.payload.config.localization.locales.map(({ code }) => code) as [string, ...string[]],\n )\n }\n\n for (const tableName in this.rawTables) {\n buildDrizzleTable({ adapter: this, rawTable: this.rawTables[tableName] })\n }\n\n buildDrizzleRelations({\n adapter: this,\n })\n\n await executeSchemaHooks({ type: 'afterSchemaInit', adapter: this })\n}\n"],"names":["buildDrizzleRelations","buildRawSchema","executeSchemaHooks","buildDrizzleTable","setColumnID","init","rawRelations","rawTables","adapter","type","payload","config","localization","enums","enum__locales","pgSchema","enum","locales","map","code","tableName","rawTable"],"mappings":"AAIA,SAASA,qBAAqB,QAAQ,qCAAoC;AAC1E,SAASC,cAAc,QAAQ,8BAA6B;AAC5D,SAASC,kBAAkB,QAAQ,qCAAoC;AACvE,SAASC,iBAAiB,QAAQ,gCAA+B;AACjE,SAASC,WAAW,QAAQ,0BAAyB;AAErD,OAAO,MAAMC,OAAa,eAAeA;IACvC,IAAI,CAACC,YAAY,GAAG,CAAC;IACrB,IAAI,CAACC,SAAS,GAAG,CAAC;IAElBN,eAAe;QACbO,SAAS,IAAI;QACbJ;IACF;IAEA,MAAMF,mBAAmB;QAAEO,MAAM;QAAoBD,SAAS,IAAI;IAAC;IAEnE,IAAI,IAAI,CAACE,OAAO,CAACC,MAAM,CAACC,YAAY,EAAE;QACpC,IAAI,CAACC,KAAK,CAACC,aAAa,GAAG,IAAI,CAACC,QAAQ,CAACC,IAAI,CAC3C,YACA,IAAI,CAACN,OAAO,CAACC,MAAM,CAACC,YAAY,CAACK,OAAO,CAACC,GAAG,CAAC,CAAC,EAAEC,IAAI,EAAE,GAAKA;IAE/D;IAEA,IAAK,MAAMC,aAAa,IAAI,CAACb,SAAS,CAAE;QACtCJ,kBAAkB;YAAEK,SAAS,IAAI;YAAEa,UAAU,IAAI,CAACd,SAAS,CAACa,UAAU;QAAC;IACzE;IAEApB,sBAAsB;QACpBQ,SAAS,IAAI;IACf;IAEA,MAAMN,mBAAmB;QAAEO,MAAM;QAAmBD,SAAS,IAAI;IAAC;AACpE,EAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { PgColumnBuilder } from 'drizzle-orm/pg-core';
|
|
2
|
+
import type { FlattenedField } from 'payload';
|
|
3
|
+
import type { BaseExtraConfig, BasePostgresAdapter, RelationMap } from '../types.js';
|
|
4
|
+
type Args = {
|
|
5
|
+
adapter: BasePostgresAdapter;
|
|
6
|
+
baseColumns?: Record<string, PgColumnBuilder>;
|
|
7
|
+
/**
|
|
8
|
+
* After table is created, run these functions to add extra config to the table
|
|
9
|
+
* ie. indexes, multiple columns, etc
|
|
10
|
+
*/
|
|
11
|
+
baseExtraConfig?: BaseExtraConfig;
|
|
12
|
+
buildNumbers?: boolean;
|
|
13
|
+
buildRelationships?: boolean;
|
|
14
|
+
disableNotNull: boolean;
|
|
15
|
+
disableRelsTableUnique?: boolean;
|
|
16
|
+
disableUnique: boolean;
|
|
17
|
+
fields: FlattenedField[];
|
|
18
|
+
rootRelationships?: Set<string>;
|
|
19
|
+
rootRelationsToBuild?: RelationMap;
|
|
20
|
+
rootTableIDColType?: string;
|
|
21
|
+
rootTableName?: string;
|
|
22
|
+
rootUniqueRelationships?: Set<string>;
|
|
23
|
+
tableName: string;
|
|
24
|
+
timestamps?: boolean;
|
|
25
|
+
versions: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Tracks whether or not this table is built
|
|
28
|
+
* from the result of a localized array or block field at some point
|
|
29
|
+
*/
|
|
30
|
+
withinLocalizedArrayOrBlock?: boolean;
|
|
31
|
+
};
|
|
32
|
+
type Result = {
|
|
33
|
+
hasLocalizedManyNumberField: boolean;
|
|
34
|
+
hasLocalizedManyTextField: boolean;
|
|
35
|
+
hasLocalizedRelationshipField: boolean;
|
|
36
|
+
hasManyNumberField: 'index' | boolean;
|
|
37
|
+
hasManyTextField: 'index' | boolean;
|
|
38
|
+
relationsToBuild: RelationMap;
|
|
39
|
+
};
|
|
40
|
+
export declare const buildTable: ({ adapter, baseColumns, baseExtraConfig, disableNotNull, disableRelsTableUnique, disableUnique, fields, rootRelationships, rootRelationsToBuild, rootTableIDColType, rootTableName: incomingRootTableName, rootUniqueRelationships, tableName, timestamps, versions, withinLocalizedArrayOrBlock, }: Args) => Result;
|
|
41
|
+
export {};
|
|
42
|
+
//# sourceMappingURL=build.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/postgres/schema/build.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAGV,eAAe,EAEhB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAe7C,OAAO,KAAK,EACV,eAAe,EACf,mBAAmB,EAInB,WAAW,EACZ,MAAM,aAAa,CAAA;AASpB,KAAK,IAAI,GAAG;IACV,OAAO,EAAE,mBAAmB,CAAA;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eA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