@payloadcms/db-postgres 3.0.0-canary.95569e4 → 3.0.0-canary.96477cf

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. package/dist/connect.d.ts.map +1 -1
  2. package/dist/connect.js +12 -5
  3. package/dist/connect.js.map +1 -1
  4. package/dist/index.d.ts +2 -2
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +9 -16
  7. package/dist/index.js.map +1 -1
  8. package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.d.ts.map +1 -1
  9. package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.js +3 -1
  10. package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.js.map +1 -1
  11. package/dist/predefinedMigrations/v2-v3/index.js +2 -2
  12. package/dist/predefinedMigrations/v2-v3/index.js.map +1 -1
  13. package/dist/predefinedMigrations/v2-v3/migrateRelationships.d.ts.map +1 -1
  14. package/dist/predefinedMigrations/v2-v3/migrateRelationships.js +9 -3
  15. package/dist/predefinedMigrations/v2-v3/migrateRelationships.js.map +1 -1
  16. package/dist/types.d.ts +22 -106
  17. package/dist/types.d.ts.map +1 -1
  18. package/dist/types.js.map +1 -1
  19. package/package.json +8 -6
  20. package/dist/countDistinct.d.ts +0 -3
  21. package/dist/countDistinct.d.ts.map +0 -1
  22. package/dist/countDistinct.js +0 -24
  23. package/dist/countDistinct.js.map +0 -1
  24. package/dist/createJSONQuery/convertPathToJSONTraversal.d.ts +0 -2
  25. package/dist/createJSONQuery/convertPathToJSONTraversal.d.ts.map +0 -1
  26. package/dist/createJSONQuery/convertPathToJSONTraversal.js +0 -14
  27. package/dist/createJSONQuery/convertPathToJSONTraversal.js.map +0 -1
  28. package/dist/createJSONQuery/formatJSONPathSegment.d.ts +0 -2
  29. package/dist/createJSONQuery/formatJSONPathSegment.d.ts.map +0 -1
  30. package/dist/createJSONQuery/formatJSONPathSegment.js +0 -5
  31. package/dist/createJSONQuery/formatJSONPathSegment.js.map +0 -1
  32. package/dist/createJSONQuery/index.d.ts +0 -10
  33. package/dist/createJSONQuery/index.d.ts.map +0 -1
  34. package/dist/createJSONQuery/index.js +0 -54
  35. package/dist/createJSONQuery/index.js.map +0 -1
  36. package/dist/createMigration.d.ts +0 -3
  37. package/dist/createMigration.d.ts.map +0 -1
  38. package/dist/createMigration.js +0 -91
  39. package/dist/createMigration.js.map +0 -1
  40. package/dist/defaultSnapshot.d.ts +0 -3
  41. package/dist/defaultSnapshot.d.ts.map +0 -1
  42. package/dist/defaultSnapshot.js +0 -17
  43. package/dist/defaultSnapshot.js.map +0 -1
  44. package/dist/deleteWhere.d.ts +0 -3
  45. package/dist/deleteWhere.d.ts.map +0 -1
  46. package/dist/deleteWhere.js +0 -6
  47. package/dist/deleteWhere.js.map +0 -1
  48. package/dist/dropDatabase.d.ts +0 -3
  49. package/dist/dropDatabase.d.ts.map +0 -1
  50. package/dist/dropDatabase.js +0 -9
  51. package/dist/dropDatabase.js.map +0 -1
  52. package/dist/execute.d.ts +0 -3
  53. package/dist/execute.d.ts.map +0 -1
  54. package/dist/execute.js +0 -11
  55. package/dist/execute.js.map +0 -1
  56. package/dist/getMigrationTemplate.d.ts +0 -4
  57. package/dist/getMigrationTemplate.d.ts.map +0 -1
  58. package/dist/getMigrationTemplate.js +0 -13
  59. package/dist/getMigrationTemplate.js.map +0 -1
  60. package/dist/init.d.ts +0 -3
  61. package/dist/init.d.ts.map +0 -1
  62. package/dist/init.js +0 -95
  63. package/dist/init.js.map +0 -1
  64. package/dist/insert.d.ts +0 -3
  65. package/dist/insert.d.ts.map +0 -1
  66. package/dist/insert.js +0 -12
  67. package/dist/insert.js.map +0 -1
  68. package/dist/requireDrizzleKit.d.ts +0 -3
  69. package/dist/requireDrizzleKit.d.ts.map +0 -1
  70. package/dist/requireDrizzleKit.js +0 -5
  71. package/dist/requireDrizzleKit.js.map +0 -1
  72. package/dist/schema/build.d.ts +0 -38
  73. package/dist/schema/build.d.ts.map +0 -1
  74. package/dist/schema/build.js +0 -369
  75. package/dist/schema/build.js.map +0 -1
  76. package/dist/schema/createIndex.d.ts +0 -12
  77. package/dist/schema/createIndex.d.ts.map +0 -1
  78. package/dist/schema/createIndex.js +0 -18
  79. package/dist/schema/createIndex.js.map +0 -1
  80. package/dist/schema/idToUUID.d.ts +0 -3
  81. package/dist/schema/idToUUID.d.ts.map +0 -1
  82. package/dist/schema/idToUUID.js +0 -11
  83. package/dist/schema/idToUUID.js.map +0 -1
  84. package/dist/schema/parentIDColumnMap.d.ts +0 -4
  85. package/dist/schema/parentIDColumnMap.d.ts.map +0 -1
  86. package/dist/schema/parentIDColumnMap.js +0 -9
  87. package/dist/schema/parentIDColumnMap.js.map +0 -1
  88. package/dist/schema/setColumnID.d.ts +0 -11
  89. package/dist/schema/setColumnID.d.ts.map +0 -1
  90. package/dist/schema/setColumnID.js +0 -24
  91. package/dist/schema/setColumnID.js.map +0 -1
  92. package/dist/schema/traverseFields.d.ts +0 -36
  93. package/dist/schema/traverseFields.d.ts.map +0 -1
  94. package/dist/schema/traverseFields.js +0 -613
  95. package/dist/schema/traverseFields.js.map +0 -1
  96. package/dist/schema/withDefault.d.ts +0 -4
  97. package/dist/schema/withDefault.d.ts.map +0 -1
  98. package/dist/schema/withDefault.js +0 -10
  99. package/dist/schema/withDefault.js.map +0 -1
package/dist/init.js DELETED
@@ -1,95 +0,0 @@
1
- import { createTableName } from '@payloadcms/drizzle';
2
- import { uniqueIndex } from 'drizzle-orm/pg-core';
3
- import { buildVersionCollectionFields, buildVersionGlobalFields } from 'payload';
4
- import toSnakeCase from 'to-snake-case';
5
- import { buildTable } from './schema/build.js';
6
- export const init = function init() {
7
- if (this.payload.config.localization) {
8
- this.enums.enum__locales = this.pgSchema.enum('_locales', this.payload.config.localization.locales.map(({ code })=>code));
9
- }
10
- this.payload.config.collections.forEach((collection)=>{
11
- createTableName({
12
- adapter: this,
13
- config: collection
14
- });
15
- if (collection.versions) {
16
- createTableName({
17
- adapter: this,
18
- config: collection,
19
- versions: true,
20
- versionsCustomName: true
21
- });
22
- }
23
- });
24
- this.payload.config.collections.forEach((collection)=>{
25
- const tableName = this.tableNameMap.get(toSnakeCase(collection.slug));
26
- const baseExtraConfig = {};
27
- if (collection.upload.filenameCompoundIndex) {
28
- const indexName = `${tableName}_filename_compound_idx`;
29
- baseExtraConfig.filename_compound_index = (cols)=>{
30
- const colsConstraint = collection.upload.filenameCompoundIndex.map((f)=>{
31
- return cols[f];
32
- });
33
- return uniqueIndex(indexName).on(colsConstraint[0], ...colsConstraint.slice(1));
34
- };
35
- }
36
- buildTable({
37
- adapter: this,
38
- baseExtraConfig,
39
- disableNotNull: !!collection?.versions?.drafts,
40
- disableUnique: false,
41
- fields: collection.fields,
42
- tableName,
43
- timestamps: collection.timestamps,
44
- versions: false
45
- });
46
- if (collection.versions) {
47
- const versionsTableName = this.tableNameMap.get(`_${toSnakeCase(collection.slug)}${this.versionsSuffix}`);
48
- const versionFields = buildVersionCollectionFields(collection);
49
- buildTable({
50
- adapter: this,
51
- disableNotNull: !!collection.versions?.drafts,
52
- disableUnique: true,
53
- fields: versionFields,
54
- tableName: versionsTableName,
55
- timestamps: true,
56
- versions: true
57
- });
58
- }
59
- });
60
- this.payload.config.globals.forEach((global)=>{
61
- const tableName = createTableName({
62
- adapter: this,
63
- config: global
64
- });
65
- buildTable({
66
- adapter: this,
67
- disableNotNull: !!global?.versions?.drafts,
68
- disableUnique: false,
69
- fields: global.fields,
70
- tableName,
71
- timestamps: false,
72
- versions: false
73
- });
74
- if (global.versions) {
75
- const versionsTableName = createTableName({
76
- adapter: this,
77
- config: global,
78
- versions: true,
79
- versionsCustomName: true
80
- });
81
- const versionFields = buildVersionGlobalFields(global);
82
- buildTable({
83
- adapter: this,
84
- disableNotNull: !!global.versions?.drafts,
85
- disableUnique: true,
86
- fields: versionFields,
87
- tableName: versionsTableName,
88
- timestamps: true,
89
- versions: true
90
- });
91
- }
92
- });
93
- };
94
-
95
- //# sourceMappingURL=init.js.map
package/dist/init.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/init.ts"],"sourcesContent":["import type { Init, SanitizedCollectionConfig } from 'payload'\n\nimport { createTableName } from '@payloadcms/drizzle'\nimport { uniqueIndex } from 'drizzle-orm/pg-core'\nimport { buildVersionCollectionFields, buildVersionGlobalFields } from 'payload'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { BaseExtraConfig } from './schema/build.js'\nimport type { PostgresAdapter } from './types.js'\n\nimport { buildTable } from './schema/build.js'\n\nexport const init: Init = function init(this: PostgresAdapter) {\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 this.payload.config.collections.forEach((collection: SanitizedCollectionConfig) => {\n createTableName({\n adapter: this,\n config: collection,\n })\n\n if (collection.versions) {\n createTableName({\n adapter: this,\n config: collection,\n versions: true,\n versionsCustomName: true,\n })\n }\n })\n this.payload.config.collections.forEach((collection: SanitizedCollectionConfig) => {\n const tableName = this.tableNameMap.get(toSnakeCase(collection.slug))\n\n const baseExtraConfig: BaseExtraConfig = {}\n\n if (collection.upload.filenameCompoundIndex) {\n const indexName = `${tableName}_filename_compound_idx`\n\n baseExtraConfig.filename_compound_index = (cols) => {\n const colsConstraint = collection.upload.filenameCompoundIndex.map((f) => {\n return cols[f]\n })\n return uniqueIndex(indexName).on(colsConstraint[0], ...colsConstraint.slice(1))\n }\n }\n\n buildTable({\n adapter: this,\n baseExtraConfig,\n disableNotNull: !!collection?.versions?.drafts,\n disableUnique: false,\n fields: collection.fields,\n tableName,\n timestamps: collection.timestamps,\n versions: false,\n })\n\n if (collection.versions) {\n const versionsTableName = this.tableNameMap.get(\n `_${toSnakeCase(collection.slug)}${this.versionsSuffix}`,\n )\n const versionFields = buildVersionCollectionFields(collection)\n\n buildTable({\n adapter: this,\n disableNotNull: !!collection.versions?.drafts,\n disableUnique: true,\n fields: versionFields,\n tableName: versionsTableName,\n timestamps: true,\n versions: true,\n })\n }\n })\n\n this.payload.config.globals.forEach((global) => {\n const tableName = createTableName({ adapter: this, config: global })\n\n buildTable({\n adapter: this,\n disableNotNull: !!global?.versions?.drafts,\n disableUnique: false,\n fields: global.fields,\n tableName,\n timestamps: false,\n versions: false,\n })\n\n if (global.versions) {\n const versionsTableName = createTableName({\n adapter: this,\n config: global,\n versions: true,\n versionsCustomName: true,\n })\n const versionFields = buildVersionGlobalFields(global)\n\n buildTable({\n adapter: this,\n disableNotNull: !!global.versions?.drafts,\n disableUnique: true,\n fields: versionFields,\n tableName: versionsTableName,\n timestamps: true,\n versions: true,\n })\n }\n })\n}\n"],"names":["createTableName","uniqueIndex","buildVersionCollectionFields","buildVersionGlobalFields","toSnakeCase","buildTable","init","payload","config","localization","enums","enum__locales","pgSchema","enum","locales","map","code","collections","forEach","collection","adapter","versions","versionsCustomName","tableName","tableNameMap","get","slug","baseExtraConfig","upload","filenameCompoundIndex","indexName","filename_compound_index","cols","colsConstraint","f","on","slice","disableNotNull","drafts","disableUnique","fields","timestamps","versionsTableName","versionsSuffix","versionFields","globals","global"],"mappings":"AAEA,SAASA,eAAe,QAAQ,sBAAqB;AACrD,SAASC,WAAW,QAAQ,sBAAqB;AACjD,SAASC,4BAA4B,EAAEC,wBAAwB,QAAQ,UAAS;AAChF,OAAOC,iBAAiB,gBAAe;AAKvC,SAASC,UAAU,QAAQ,oBAAmB;AAE9C,OAAO,MAAMC,OAAa,SAASA;IACjC,IAAI,IAAI,CAACC,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,IAAI,CAACT,OAAO,CAACC,MAAM,CAACS,WAAW,CAACC,OAAO,CAAC,CAACC;QACvCnB,gB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AWmB;gBACXD,YAAY;gBACZpB,UAAU;YACZ;QACF;IACF;IAEA,IAAI,CAACd,OAAO,CAACC,MAAM,CAACqC,OAAO,CAAC3B,OAAO,CAAC,CAAC4B;QACnC,MAAMvB,YAAYvB,gBAAgB;YAAEoB,SAAS,IAAI;YAAEZ,QAAQsC;QAAO;QAElEzC,WAAW;YACTe,SAAS,IAAI;YACbiB,gBAAgB,CAAC,CAACS,QAAQzB,UAAUiB;YACpCC,eAAe;YACfC,QAAQM,OAAON,MAAM;YACrBjB;YACAkB,YAAY;YACZpB,UAAU;QACZ;QAEA,IAAIyB,OAAOzB,QAAQ,EAAE;YACnB,MAAMqB,oBAAoB1C,gBAAgB;gBACxCoB,SAAS,IAAI;gBACbZ,QAAQsC;gBACRzB,UAAU;gBACVC,oBAAoB;YACtB;YACA,MAAMsB,gBAAgBzC,yBAAyB2C;YAE/CzC,WAAW;gBACTe,SAAS,IAAI;gBACbiB,gBAAgB,CAAC,CAACS,OAAOzB,QAAQ,EAAEiB;gBACnCC,eAAe;gBACfC,QAAQI;gBACRrB,WAAWmB;gBACXD,YAAY;gBACZpB,UAAU;YACZ;QACF;IACF;AACF,EAAC"}
package/dist/insert.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import type { Insert } from './types.js';
2
- export declare const insert: Insert;
3
- //# sourceMappingURL=insert.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"insert.d.ts","sourceRoot":"","sources":["../src/insert.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAExC,eAAO,MAAM,MAAM,EAAE,MAoBpB,CAAA"}
package/dist/insert.js DELETED
@@ -1,12 +0,0 @@
1
- export const insert = async function insert({ db, onConflictDoUpdate, tableName, values }) {
2
- const table = this.tables[tableName];
3
- let result;
4
- if (onConflictDoUpdate) {
5
- result = await db.insert(table).values(values).onConflictDoUpdate(onConflictDoUpdate).returning();
6
- } else {
7
- result = await db.insert(table).values(values).returning();
8
- }
9
- return result;
10
- };
11
-
12
- //# sourceMappingURL=insert.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/insert.ts"],"sourcesContent":["import type { TransactionPg } from '@payloadcms/drizzle/types'\n\nimport type { Insert } from './types.js'\n\nexport const insert: Insert = async function insert({\n db,\n onConflictDoUpdate,\n tableName,\n values,\n}): Promise<Record<string, unknown>[]> {\n const table = this.tables[tableName]\n let result\n\n if (onConflictDoUpdate) {\n result = await (db as TransactionPg)\n .insert(table)\n .values(values)\n .onConflictDoUpdate(onConflictDoUpdate)\n .returning()\n } else {\n result = await (db as TransactionPg).insert(table).values(values).returning()\n }\n\n return result\n}\n"],"names":["insert","db","onConflictDoUpdate","tableName","values","table","tables","result","returning"],"mappings":"AAIA,OAAO,MAAMA,SAAiB,eAAeA,OAAO,EAClDC,EAAE,EACFC,kBAAkB,EAClBC,SAAS,EACTC,MAAM,EACP;IACC,MAAMC,QAAQ,IAAI,CAACC,MAAM,CAACH,UAAU;IACpC,IAAII;IAEJ,IAAIL,oBAAoB;QACtBK,SAAS,MAAM,AAACN,GACbD,MAAM,CAACK,OACPD,MAAM,CAACA,QACPF,kBAAkB,CAACA,oBACnBM,SAAS;IACd,OAAO;QACLD,SAAS,MAAM,AAACN,GAAqBD,MAAM,CAACK,OAAOD,MAAM,CAACA,QAAQI,SAAS;IAC7E;IAEA,OAAOD;AACT,EAAC"}
@@ -1,3 +0,0 @@
1
- import type { RequireDrizzleKit } from '@payloadcms/drizzle/types';
2
- export declare const requireDrizzleKit: RequireDrizzleKit;
3
- //# sourceMappingURL=requireDrizzleKit.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"requireDrizzleKit.d.ts","sourceRoot":"","sources":["../src/requireDrizzleKit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAIlE,eAAO,MAAM,iBAAiB,EAAE,iBAAoD,CAAA"}
@@ -1,5 +0,0 @@
1
- import { createRequire } from 'module';
2
- const require = createRequire(import.meta.url);
3
- export const requireDrizzleKit = ()=>require('drizzle-kit/api');
4
-
5
- //# sourceMappingURL=requireDrizzleKit.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/requireDrizzleKit.ts"],"sourcesContent":["import type { RequireDrizzleKit } from '@payloadcms/drizzle/types'\n\nimport { createRequire } from 'module'\nconst require = createRequire(import.meta.url)\nexport const requireDrizzleKit: RequireDrizzleKit = () => require('drizzle-kit/api')\n"],"names":["createRequire","require","url","requireDrizzleKit"],"mappings":"AAEA,SAASA,aAAa,QAAQ,SAAQ;AACtC,MAAMC,UAAUD,cAAc,YAAYE,GAAG;AAC7C,OAAO,MAAMC,oBAAuC,IAAMF,QAAQ,mBAAkB"}
@@ -1,38 +0,0 @@
1
- import type { ForeignKeyBuilder, IndexBuilder, PgColumnBuilder, UniqueConstraintBuilder } from 'drizzle-orm/pg-core';
2
- import type { Field } from 'payload';
3
- import type { GenericColumns, PostgresAdapter } from '../types.js';
4
- export type BaseExtraConfig = Record<string, (cols: GenericColumns) => ForeignKeyBuilder | IndexBuilder | UniqueConstraintBuilder>;
5
- export type RelationMap = Map<string, {
6
- localized: boolean;
7
- target: string;
8
- type: 'many' | 'one';
9
- }>;
10
- type Args = {
11
- adapter: PostgresAdapter;
12
- baseColumns?: Record<string, PgColumnBuilder>;
13
- /**
14
- * After table is created, run these functions to add extra config to the table
15
- * ie. indexes, multiple columns, etc
16
- */
17
- baseExtraConfig?: BaseExtraConfig;
18
- buildNumbers?: boolean;
19
- buildRelationships?: boolean;
20
- disableNotNull: boolean;
21
- disableUnique: boolean;
22
- fields: Field[];
23
- rootRelationsToBuild?: RelationMap;
24
- rootRelationships?: Set<string>;
25
- rootTableIDColType?: string;
26
- rootTableName?: string;
27
- tableName: string;
28
- timestamps?: boolean;
29
- versions: boolean;
30
- };
31
- type Result = {
32
- hasManyNumberField: 'index' | boolean;
33
- hasManyTextField: 'index' | boolean;
34
- relationsToBuild: RelationMap;
35
- };
36
- export declare const buildTable: ({ adapter, baseColumns, baseExtraConfig, disableNotNull, disableUnique, fields, rootRelationsToBuild, rootRelationships, rootTableIDColType, rootTableName: incomingRootTableName, tableName, timestamps, versions, }: Args) => Result;
37
- export {};
38
- //# sourceMappingURL=build.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/schema/build.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,iBAAiB,EACjB,YAAY,EACZ,eAAe,EAEf,uBAAuB,EACxB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAgBpC,OAAO,KAAK,EAAE,cAAc,EAAwB,eAAe,EAAE,MAAM,aAAa,CAAA;AAMxF,MAAM,MAAM,eAAe,GAAG,MAAM,CAClC,MAAM,EACN,CAAC,IAAI,EAAE,cAAc,KAAK,iBAAiB,GAAG,YAAY,GAAG,uBAAuB,CACrF,CAAA;AAED,MAAM,MAAM,WAAW,GAAG,GAAG,CAAC,MAAM,EAAE;IAAE,SAAS,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,GAAG,KAAK,CAAA;CAAE,CAAC,CAAA;AAEnG,KAAK,IAAI,GAAG;IACV,OAAO,EAAE,eAAe,CAAA;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;IAC7C;;;OAGG;IACH,eAAe,CAAC,EAAE,eAAe,CAAA;IACjC,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,cAAc,EAAE,OAAO,CAAA;IACvB,aAAa,EAAE,OAAO,CAAA;IACtB,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,oBAAoB,CAAC,EAAE,WAAW,CAAA;IAClC,iBAAiB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IAC/B,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,QAAQ,EAAE,OAAO,CAAA;CAClB,CAAA;AAED,KAAK,MAAM,GAAG;IACZ,kBAAkB,EAAE,OAAO,GAAG,OAAO,CAAA;IACrC,gBAAgB,EAAE,OAAO,GAAG,OAAO,CAAA;IACnC,gBAAgB,EAAE,WAAW,CAAA;CAC9B,CAAA;AAED,eAAO,MAAM,UAAU,0NAcpB,IAAI,KAAG,MAqYT,CAAA"}
@@ -1,369 +0,0 @@
1
- import { createTableName } from '@payloadcms/drizzle';
2
- import { relations } from 'drizzle-orm';
3
- import { foreignKey, index, integer, numeric, serial, timestamp, unique, varchar } from 'drizzle-orm/pg-core';
4
- import toSnakeCase from 'to-snake-case';
5
- import { parentIDColumnMap } from './parentIDColumnMap.js';
6
- import { setColumnID } from './setColumnID.js';
7
- import { traverseFields } from './traverseFields.js';
8
- export const buildTable = ({ adapter, baseColumns = {}, baseExtraConfig = {}, disableNotNull, disableUnique = false, fields, rootRelationsToBuild, rootRelationships, rootTableIDColType, rootTableName: incomingRootTableName, tableName, timestamps, versions })=>{
9
- const isRoot = !incomingRootTableName;
10
- const rootTableName = incomingRootTableName || tableName;
11
- const columns = baseColumns;
12
- const indexes = {};
13
- const localesColumns = {};
14
- const localesIndexes = {};
15
- let localesTable;
16
- let textsTable;
17
- let numbersTable;
18
- // Relationships to the base collection
19
- const relationships = rootRelationships || new Set();
20
- let relationshipsTable;
21
- // Drizzle relations
22
- const relationsToBuild = new Map();
23
- const idColType = setColumnID({
24
- adapter,
25
- columns,
26
- fields
27
- });
28
- const { hasLocalizedField, hasLocalizedManyNumberField, hasLocalizedManyTextField, hasLocalizedRelationshipField, hasManyNumberField, hasManyTextField } = traverseFields({
29
- adapter,
30
- columns,
31
- disableNotNull,
32
- disableUnique,
33
- fields,
34
- indexes,
35
- localesColumns,
36
- localesIndexes,
37
- newTableName: tableName,
38
- parentTableName: tableName,
39
- relationsToBuild,
40
- relationships,
41
- rootRelationsToBuild: rootRelationsToBuild || relationsToBuild,
42
- rootTableIDColType: rootTableIDColType || idColType,
43
- rootTableName,
44
- versions
45
- });
46
- // split the relationsToBuild by localized and non-localized
47
- const localizedRelations = new Map();
48
- const nonLocalizedRelations = new Map();
49
- relationsToBuild.forEach(({ type, localized, target }, key)=>{
50
- const map = localized ? localizedRelations : nonLocalizedRelations;
51
- map.set(key, {
52
- type,
53
- target
54
- });
55
- });
56
- if (timestamps) {
57
- columns.createdAt = timestamp('created_at', {
58
- mode: 'string',
59
- precision: 3,
60
- withTimezone: true
61
- }).defaultNow().notNull();
62
- columns.updatedAt = timestamp('updated_at', {
63
- mode: 'string',
64
- precision: 3,
65
- withTimezone: true
66
- }).defaultNow().notNull();
67
- }
68
- const table = adapter.pgSchema.table(tableName, columns, (cols)=>{
69
- const extraConfig = Object.entries(baseExtraConfig).reduce((config, [key, func])=>{
70
- config[key] = func(cols);
71
- return config;
72
- }, {});
73
- const result = Object.entries(indexes).reduce((acc, [colName, func])=>{
74
- acc[colName] = func(cols);
75
- return acc;
76
- }, extraConfig);
77
- return result;
78
- });
79
- adapter.tables[tableName] = table;
80
- if (hasLocalizedField || localizedRelations.size) {
81
- const localeTableName = `${tableName}${adapter.localesSuffix}`;
82
- localesColumns.id = serial('id').primaryKey();
83
- localesColumns._locale = adapter.enums.enum__locales('_locale').notNull();
84
- localesColumns._parentID = parentIDColumnMap[idColType]('_parent_id').notNull();
85
- localesTable = adapter.pgSchema.table(localeTableName, localesColumns, (cols)=>{
86
- return Object.entries(localesIndexes).reduce((acc, [colName, func])=>{
87
- acc[colName] = func(cols);
88
- return acc;
89
- }, {
90
- _localeParent: unique(`${localeTableName}_locale_parent_id_unique`).on(cols._locale, cols._parentID),
91
- _parentIdFk: foreignKey({
92
- name: `${localeTableName}_parent_id_fk`,
93
- columns: [
94
- cols._parentID
95
- ],
96
- foreignColumns: [
97
- table.id
98
- ]
99
- }).onDelete('cascade')
100
- });
101
- });
102
- adapter.tables[localeTableName] = localesTable;
103
- adapter.relations[`relations_${localeTableName}`] = relations(localesTable, ({ many, one })=>{
104
- const result = {};
105
- result._parentID = one(table, {
106
- fields: [
107
- localesTable._parentID
108
- ],
109
- references: [
110
- table.id
111
- ],
112
- // name the relationship by what the many() relationName is
113
- relationName: '_locales'
114
- });
115
- localizedRelations.forEach(({ type, target }, key)=>{
116
- if (type === 'one') {
117
- result[key] = one(adapter.tables[target], {
118
- fields: [
119
- localesTable[key]
120
- ],
121
- references: [
122
- adapter.tables[target].id
123
- ],
124
- relationName: key
125
- });
126
- }
127
- if (type === 'many') {
128
- result[key] = many(adapter.tables[target], {
129
- relationName: key
130
- });
131
- }
132
- });
133
- return result;
134
- });
135
- }
136
- if (isRoot) {
137
- if (hasManyTextField) {
138
- const textsTableName = `${rootTableName}_texts`;
139
- const columns = {
140
- id: serial('id').primaryKey(),
141
- order: integer('order').notNull(),
142
- parent: parentIDColumnMap[idColType]('parent_id').notNull(),
143
- path: varchar('path').notNull(),
144
- text: varchar('text')
145
- };
146
- if (hasLocalizedManyTextField) {
147
- columns.locale = adapter.enums.enum__locales('locale');
148
- }
149
- textsTable = adapter.pgSchema.table(textsTableName, columns, (cols)=>{
150
- const config = {
151
- orderParentIdx: index(`${textsTableName}_order_parent_idx`).on(cols.order, cols.parent),
152
- parentFk: foreignKey({
153
- name: `${textsTableName}_parent_fk`,
154
- columns: [
155
- cols.parent
156
- ],
157
- foreignColumns: [
158
- table.id
159
- ]
160
- }).onDelete('cascade')
161
- };
162
- if (hasManyTextField === 'index') {
163
- config.text_idx = index(`${textsTableName}_text_idx`).on(cols.text);
164
- }
165
- if (hasLocalizedManyTextField) {
166
- config.localeParent = index(`${textsTableName}_locale_parent`).on(cols.locale, cols.parent);
167
- }
168
- return config;
169
- });
170
- adapter.tables[textsTableName] = textsTable;
171
- adapter.relations[`relations_${textsTableName}`] = relations(textsTable, ({ one })=>({
172
- parent: one(table, {
173
- fields: [
174
- textsTable.parent
175
- ],
176
- references: [
177
- table.id
178
- ],
179
- relationName: '_texts'
180
- })
181
- }));
182
- }
183
- if (hasManyNumberField) {
184
- const numbersTableName = `${rootTableName}_numbers`;
185
- const columns = {
186
- id: serial('id').primaryKey(),
187
- number: numeric('number'),
188
- order: integer('order').notNull(),
189
- parent: parentIDColumnMap[idColType]('parent_id').notNull(),
190
- path: varchar('path').notNull()
191
- };
192
- if (hasLocalizedManyNumberField) {
193
- columns.locale = adapter.enums.enum__locales('locale');
194
- }
195
- numbersTable = adapter.pgSchema.table(numbersTableName, columns, (cols)=>{
196
- const config = {
197
- orderParentIdx: index(`${numbersTableName}_order_parent_idx`).on(cols.order, cols.parent),
198
- parentFk: foreignKey({
199
- name: `${numbersTableName}_parent_fk`,
200
- columns: [
201
- cols.parent
202
- ],
203
- foreignColumns: [
204
- table.id
205
- ]
206
- }).onDelete('cascade')
207
- };
208
- if (hasManyNumberField === 'index') {
209
- config.numberIdx = index(`${numbersTableName}_number_idx`).on(cols.number);
210
- }
211
- if (hasLocalizedManyNumberField) {
212
- config.localeParent = index(`${numbersTableName}_locale_parent`).on(cols.locale, cols.parent);
213
- }
214
- return config;
215
- });
216
- adapter.tables[numbersTableName] = numbersTable;
217
- adapter.relations[`relations_${numbersTableName}`] = relations(numbersTable, ({ one })=>({
218
- parent: one(table, {
219
- fields: [
220
- numbersTable.parent
221
- ],
222
- references: [
223
- table.id
224
- ],
225
- relationName: '_numbers'
226
- })
227
- }));
228
- }
229
- if (relationships.size) {
230
- const relationshipColumns = {
231
- id: serial('id').primaryKey(),
232
- order: integer('order'),
233
- parent: parentIDColumnMap[idColType]('parent_id').notNull(),
234
- path: varchar('path').notNull()
235
- };
236
- if (hasLocalizedRelationshipField) {
237
- relationshipColumns.locale = adapter.enums.enum__locales('locale');
238
- }
239
- const relationExtraConfig = {};
240
- const relationshipsTableName = `${tableName}${adapter.relationshipsSuffix}`;
241
- relationships.forEach((relationTo)=>{
242
- const relationshipConfig = adapter.payload.collections[relationTo].config;
243
- const formattedRelationTo = createTableName({
244
- adapter,
245
- config: relationshipConfig,
246
- throwValidationError: true
247
- });
248
- let colType = adapter.idType === 'uuid' ? 'uuid' : 'integer';
249
- const relatedCollectionCustomIDType = adapter.payload.collections[relationshipConfig.slug]?.customIDType;
250
- if (relatedCollectionCustomIDType === 'number') colType = 'numeric';
251
- if (relatedCollectionCustomIDType === 'text') colType = 'varchar';
252
- relationshipColumns[`${relationTo}ID`] = parentIDColumnMap[colType](`${formattedRelationTo}_id`);
253
- relationExtraConfig[`${relationTo}IdFk`] = (cols)=>foreignKey({
254
- name: `${relationshipsTableName}_${toSnakeCase(relationTo)}_fk`,
255
- columns: [
256
- cols[`${relationTo}ID`]
257
- ],
258
- foreignColumns: [
259
- adapter.tables[formattedRelationTo].id
260
- ]
261
- }).onDelete('cascade');
262
- });
263
- relationshipsTable = adapter.pgSchema.table(relationshipsTableName, relationshipColumns, (cols)=>{
264
- const result = Object.entries(relationExtraConfig).reduce((config, [key, func])=>{
265
- config[key] = func(cols);
266
- return config;
267
- }, {
268
- order: index(`${relationshipsTableName}_order_idx`).on(cols.order),
269
- parentFk: foreignKey({
270
- name: `${relationshipsTableName}_parent_fk`,
271
- columns: [
272
- cols.parent
273
- ],
274
- foreignColumns: [
275
- table.id
276
- ]
277
- }).onDelete('cascade'),
278
- parentIdx: index(`${relationshipsTableName}_parent_idx`).on(cols.parent),
279
- pathIdx: index(`${relationshipsTableName}_path_idx`).on(cols.path)
280
- });
281
- if (hasLocalizedRelationshipField) {
282
- result.localeIdx = index(`${relationshipsTableName}_locale_idx`).on(cols.locale);
283
- }
284
- return result;
285
- });
286
- adapter.tables[relationshipsTableName] = relationshipsTable;
287
- adapter.relations[`relations_${relationshipsTableName}`] = relations(relationshipsTable, ({ one })=>{
288
- const result = {
289
- parent: one(table, {
290
- fields: [
291
- relationshipsTable.parent
292
- ],
293
- references: [
294
- table.id
295
- ],
296
- relationName: '_rels'
297
- })
298
- };
299
- relationships.forEach((relationTo)=>{
300
- const relatedTableName = createTableName({
301
- adapter,
302
- config: adapter.payload.collections[relationTo].config,
303
- throwValidationError: true
304
- });
305
- const idColumnName = `${relationTo}ID`;
306
- result[idColumnName] = one(adapter.tables[relatedTableName], {
307
- fields: [
308
- relationshipsTable[idColumnName]
309
- ],
310
- references: [
311
- adapter.tables[relatedTableName].id
312
- ],
313
- relationName: relationTo
314
- });
315
- });
316
- return result;
317
- });
318
- }
319
- }
320
- adapter.relations[`relations_${tableName}`] = relations(table, ({ many, one })=>{
321
- const result = {};
322
- nonLocalizedRelations.forEach(({ type, target }, key)=>{
323
- if (type === 'one') {
324
- result[key] = one(adapter.tables[target], {
325
- fields: [
326
- table[key]
327
- ],
328
- references: [
329
- adapter.tables[target].id
330
- ],
331
- relationName: key
332
- });
333
- }
334
- if (type === 'many') {
335
- result[key] = many(adapter.tables[target], {
336
- relationName: key
337
- });
338
- }
339
- });
340
- if (hasLocalizedField) {
341
- result._locales = many(localesTable, {
342
- relationName: '_locales'
343
- });
344
- }
345
- if (hasManyTextField) {
346
- result._texts = many(textsTable, {
347
- relationName: '_texts'
348
- });
349
- }
350
- if (hasManyNumberField) {
351
- result._numbers = many(numbersTable, {
352
- relationName: '_numbers'
353
- });
354
- }
355
- if (relationships.size && relationshipsTable) {
356
- result._rels = many(relationshipsTable, {
357
- relationName: '_rels'
358
- });
359
- }
360
- return result;
361
- });
362
- return {
363
- hasManyNumberField,
364
- hasManyTextField,
365
- relationsToBuild
366
- };
367
- };
368
-
369
- //# sourceMappingURL=build.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/schema/build.ts"],"sourcesContent":["import type { Relation } from 'drizzle-orm'\nimport type {\n ForeignKeyBuilder,\n IndexBuilder,\n PgColumnBuilder,\n PgTableWithColumns,\n UniqueConstraintBuilder,\n} from 'drizzle-orm/pg-core'\nimport type { Field } from 'payload'\n\nimport { createTableName } from '@payloadcms/drizzle'\nimport { relations } from 'drizzle-orm'\nimport {\n foreignKey,\n index,\n integer,\n numeric,\n serial,\n timestamp,\n unique,\n varchar,\n} from 'drizzle-orm/pg-core'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { GenericColumns, GenericTable, IDType, PostgresAdapter } from '../types.js'\n\nimport { parentIDColumnMap } from './parentIDColumnMap.js'\nimport { setColumnID } from './setColumnID.js'\nimport { traverseFields } from './traverseFields.js'\n\nexport type BaseExtraConfig = Record<\n string,\n (cols: GenericColumns) => ForeignKeyBuilder | IndexBuilder | UniqueConstraintBuilder\n>\n\nexport type RelationMap = Map<string, { localized: boolean; target: string; type: 'many' | 'one' }>\n\ntype Args = {\n adapter: PostgresAdapter\n baseColumns?: Record<string, PgColumnBuilder>\n /**\n * After table is created, run these functions to add extra config to the table\n * ie. indexes, multiple columns, etc\n */\n baseExtraConfig?: BaseExtraConfig\n buildNumbers?: boolean\n buildRelationships?: boolean\n disableNotNull: boolean\n disableUnique: boolean\n fields: Field[]\n rootRelationsToBuild?: RelationMap\n rootRelationships?: Set<string>\n rootTableIDColType?: string\n rootTableName?: string\n tableName: string\n timestamps?: boolean\n versions: boolean\n}\n\ntype Result = {\n hasManyNumberField: 'index' | boolean\n hasManyTextField: 'index' | boolean\n relationsToBuild: RelationMap\n}\n\nexport const buildTable = ({\n adapter,\n baseColumns = {},\n baseExtraConfig = {},\n disableNotNull,\n disableUnique = false,\n fields,\n rootRelationsToBuild,\n rootRelationships,\n rootTableIDColType,\n rootTableName: incomingRootTableName,\n tableName,\n timestamps,\n versions,\n}: Args): Result => {\n const isRoot = !incomingRootTableName\n const rootTableName = incomingRootTableName || tableName\n const columns: Record<string, PgColumnBuilder> = baseColumns\n const indexes: Record<string, (cols: GenericColumns) => IndexBuilder> = {}\n\n const localesColumns: Record<string, PgColumnBuilder> = {}\n const localesIndexes: Record<string, (cols: GenericColumns) => IndexBuilder> = {}\n let localesTable: GenericTable | PgTableWithColumns<any>\n let textsTable: GenericTable | PgTableWithColumns<any>\n let numbersTable: GenericTable | PgTableWithColumns<any>\n\n // Relationships to the base collection\n const relationships: Set<string> = rootRelationships || new Set()\n\n let relationshipsTable: GenericTable | PgTableWithColumns<any>\n\n // Drizzle relations\n const relationsToBuild: RelationMap = new Map()\n\n const idColType: IDType = setColumnID({ adapter, columns, fields })\n\n const {\n hasLocalizedField,\n hasLocalizedManyNumberField,\n hasLocalizedManyTextField,\n hasLocalizedRelationshipField,\n hasManyNumberField,\n hasManyTextField,\n } = traverseFields({\n adapter,\n columns,\n disableNotNull,\n disableUnique,\n fields,\n indexes,\n localesColumns,\n localesIndexes,\n newTableName: tableName,\n parentTableName: tableName,\n relationsToBuild,\n relationships,\n rootRelationsToBuild: rootRelationsToBuild || relationsToBuild,\n rootTableIDColType: rootTableIDColType || idColType,\n rootTableName,\n versions,\n })\n\n // split the relationsToBuild by localized and non-localized\n const localizedRelations = new Map()\n const nonLocalizedRelations = new Map()\n\n relationsToBuild.forEach(({ type, localized, target }, key) => {\n const map = localized ? localizedRelations : nonLocalizedRelations\n map.set(key, { type, target })\n })\n\n if (timestamps) {\n columns.createdAt = timestamp('created_at', {\n mode: 'string',\n precision: 3,\n withTimezone: true,\n })\n .defaultNow()\n .notNull()\n columns.updatedAt = timestamp('updated_at', {\n mode: 'string',\n precision: 3,\n withTimezone: true,\n })\n .defaultNow()\n .notNull()\n }\n\n const table = adapter.pgSchema.table(tableName, columns, (cols) => {\n const extraConfig = Object.entries(baseExtraConfig).reduce((config, [key, func]) => {\n config[key] = func(cols)\n return config\n }, {})\n\n const result = Object.entries(indexes).reduce((acc, [colName, func]) => {\n acc[colName] = func(cols)\n return acc\n }, extraConfig)\n\n return result\n })\n\n adapter.tables[tableName] = table\n\n if (hasLocalizedField || localizedRelations.size) {\n const localeTableName = `${tableName}${adapter.localesSuffix}`\n localesColumns.id = serial('id').primaryKey()\n localesColumns._locale = adapter.enums.enum__locales('_locale').notNull()\n localesColumns._parentID = parentIDColumnMap[idColType]('_parent_id').notNull()\n\n localesTable = adapter.pgSchema.table(localeTableName, localesColumns, (cols) => {\n return Object.entries(localesIndexes).reduce(\n (acc, [colName, func]) => {\n acc[colName] = func(cols)\n return acc\n },\n {\n _localeParent: unique(`${localeTableName}_locale_parent_id_unique`).on(\n cols._locale,\n cols._parentID,\n ),\n _parentIdFk: foreignKey({\n name: `${localeTableName}_parent_id_fk`,\n columns: [cols._parentID],\n foreignColumns: [table.id],\n }).onDelete('cascade'),\n },\n )\n })\n\n adapter.tables[localeTableName] = localesTable\n\n adapter.relations[`relations_${localeTableName}`] = relations(localesTable, ({ many, one }) => {\n const result: Record<string, Relation<string>> = {}\n\n result._parentID = one(table, {\n fields: [localesTable._parentID],\n references: [table.id],\n // name the relationship by what the many() relationName is\n relationName: '_locales',\n })\n\n localizedRelations.forEach(({ type, target }, key) => {\n if (type === 'one') {\n result[key] = one(adapter.tables[target], {\n fields: [localesTable[key]],\n references: [adapter.tables[target].id],\n relationName: key,\n })\n }\n if (type === 'many') {\n result[key] = many(adapter.tables[target], {\n relationName: key,\n })\n }\n })\n\n return result\n })\n }\n\n if (isRoot) {\n if (hasManyTextField) {\n const textsTableName = `${rootTableName}_texts`\n const columns: Record<string, PgColumnBuilder> = {\n id: serial('id').primaryKey(),\n order: integer('order').notNull(),\n parent: parentIDColumnMap[idColType]('parent_id').notNull(),\n path: varchar('path').notNull(),\n text: varchar('text'),\n }\n\n if (hasLocalizedManyTextField) {\n columns.locale = adapter.enums.enum__locales('locale')\n }\n\n textsTable = adapter.pgSchema.table(textsTableName, columns, (cols) => {\n const config: Record<string, ForeignKeyBuilder | IndexBuilder> = {\n orderParentIdx: index(`${textsTableName}_order_parent_idx`).on(cols.order, cols.parent),\n parentFk: foreignKey({\n name: `${textsTableName}_parent_fk`,\n columns: [cols.parent],\n foreignColumns: [table.id],\n }).onDelete('cascade'),\n }\n\n if (hasManyTextField === 'index') {\n config.text_idx = index(`${textsTableName}_text_idx`).on(cols.text)\n }\n\n if (hasLocalizedManyTextField) {\n config.localeParent = index(`${textsTableName}_locale_parent`).on(\n cols.locale,\n cols.parent,\n )\n }\n\n return config\n })\n\n adapter.tables[textsTableName] = textsTable\n\n adapter.relations[`relations_${textsTableName}`] = relations(textsTable, ({ one }) => ({\n parent: one(table, {\n fields: [textsTable.parent],\n references: [table.id],\n relationName: '_texts',\n }),\n }))\n }\n\n if (hasManyNumberField) {\n const numbersTableName = `${rootTableName}_numbers`\n const columns: Record<string, PgColumnBuilder> = {\n id: serial('id').primaryKey(),\n number: numeric('number'),\n order: integer('order').notNull(),\n parent: parentIDColumnMap[idColType]('parent_id').notNull(),\n path: varchar('path').notNull(),\n }\n\n if (hasLocalizedManyNumberField) {\n columns.locale = adapter.enums.enum__locales('locale')\n }\n\n numbersTable = adapter.pgSchema.table(numbersTableName, columns, (cols) => {\n const config: Record<string, ForeignKeyBuilder | IndexBuilder> = {\n orderParentIdx: index(`${numbersTableName}_order_parent_idx`).on(cols.order, cols.parent),\n parentFk: foreignKey({\n name: `${numbersTableName}_parent_fk`,\n columns: [cols.parent],\n foreignColumns: [table.id],\n }).onDelete('cascade'),\n }\n\n if (hasManyNumberField === 'index') {\n config.numberIdx = index(`${numbersTableName}_number_idx`).on(cols.number)\n }\n\n if (hasLocalizedManyNumberField) {\n config.localeParent = index(`${numbersTableName}_locale_parent`).on(\n cols.locale,\n cols.parent,\n )\n }\n\n return config\n })\n\n adapter.tables[numbersTableName] = numbersTable\n\n adapter.relations[`relations_${numbersTableName}`] = relations(numbersTable, ({ one }) => ({\n parent: one(table, {\n fields: [numbersTable.parent],\n references: [table.id],\n relationName: '_numbers',\n }),\n }))\n }\n\n if (relationships.size) {\n const relationshipColumns: Record<string, PgColumnBuilder> = {\n id: serial('id').primaryKey(),\n order: integer('order'),\n parent: parentIDColumnMap[idColType]('parent_id').notNull(),\n path: varchar('path').notNull(),\n }\n\n if (hasLocalizedRelationshipField) {\n relationshipColumns.locale = adapter.enums.enum__locales('locale')\n }\n\n const relationExtraConfig: BaseExtraConfig = {}\n const relationshipsTableName = `${tableName}${adapter.relationshipsSuffix}`\n\n relationships.forEach((relationTo) => {\n const relationshipConfig = adapter.payload.collections[relationTo].config\n const formattedRelationTo = createTableName({\n adapter,\n config: relationshipConfig,\n throwValidationError: true,\n })\n let colType = adapter.idType === 'uuid' ? 'uuid' : 'integer'\n const relatedCollectionCustomIDType =\n adapter.payload.collections[relationshipConfig.slug]?.customIDType\n\n if (relatedCollectionCustomIDType === 'number') colType = 'numeric'\n if (relatedCollectionCustomIDType === 'text') colType = 'varchar'\n\n relationshipColumns[`${relationTo}ID`] = parentIDColumnMap[colType](\n `${formattedRelationTo}_id`,\n )\n\n relationExtraConfig[`${relationTo}IdFk`] = (cols) =>\n foreignKey({\n name: `${relationshipsTableName}_${toSnakeCase(relationTo)}_fk`,\n columns: [cols[`${relationTo}ID`]],\n foreignColumns: [adapter.tables[formattedRelationTo].id],\n }).onDelete('cascade')\n })\n\n relationshipsTable = adapter.pgSchema.table(\n relationshipsTableName,\n relationshipColumns,\n (cols) => {\n const result: Record<string, ForeignKeyBuilder | IndexBuilder> = Object.entries(\n relationExtraConfig,\n ).reduce(\n (config, [key, func]) => {\n config[key] = func(cols)\n return config\n },\n {\n order: index(`${relationshipsTableName}_order_idx`).on(cols.order),\n parentFk: foreignKey({\n name: `${relationshipsTableName}_parent_fk`,\n columns: [cols.parent],\n foreignColumns: [table.id],\n }).onDelete('cascade'),\n parentIdx: index(`${relationshipsTableName}_parent_idx`).on(cols.parent),\n pathIdx: index(`${relationshipsTableName}_path_idx`).on(cols.path),\n },\n )\n\n if (hasLocalizedRelationshipField) {\n result.localeIdx = index(`${relationshipsTableName}_locale_idx`).on(cols.locale)\n }\n\n return result\n },\n )\n\n adapter.tables[relationshipsTableName] = relationshipsTable\n\n adapter.relations[`relations_${relationshipsTableName}`] = relations(\n relationshipsTable,\n ({ one }) => {\n const result: Record<string, Relation<string>> = {\n parent: one(table, {\n fields: [relationshipsTable.parent],\n references: [table.id],\n relationName: '_rels',\n }),\n }\n\n relationships.forEach((relationTo) => {\n const relatedTableName = createTableName({\n adapter,\n config: adapter.payload.collections[relationTo].config,\n throwValidationError: true,\n })\n const idColumnName = `${relationTo}ID`\n result[idColumnName] = one(adapter.tables[relatedTableName], {\n fields: [relationshipsTable[idColumnName]],\n references: [adapter.tables[relatedTableName].id],\n relationName: relationTo,\n })\n })\n\n return result\n },\n )\n }\n }\n\n adapter.relations[`relations_${tableName}`] = relations(table, ({ many, one }) => {\n const result: Record<string, Relation<string>> = {}\n\n nonLocalizedRelations.forEach(({ type, target }, key) => {\n if (type === 'one') {\n result[key] = one(adapter.tables[target], {\n fields: [table[key]],\n references: [adapter.tables[target].id],\n relationName: key,\n })\n }\n if (type === 'many') {\n result[key] = many(adapter.tables[target], { relationName: key })\n }\n })\n\n if (hasLocalizedField) {\n result._locales = many(localesTable, { relationName: '_locales' })\n }\n\n if (hasManyTextField) {\n result._texts = many(textsTable, { relationName: '_texts' })\n }\n\n if (hasManyNumberField) {\n result._numbers = many(numbersTable, { relationName: '_numbers' })\n }\n\n if (relationships.size && relationshipsTable) {\n result._rels = many(relationshipsTable, {\n relationName: '_rels',\n })\n }\n\n return result\n })\n\n return { hasManyNumberField, hasManyTextField, relationsToBuild }\n}\n"],"names":["createTableName","relations","foreignKey","index","integer","numeric","serial","timestamp","unique","varchar","toSnakeCase","parentIDColumnMap","setColumnID","traverseFields","buildTable","adapter","baseColumns","baseExtraConfig","disableNotNull","disableUnique","fields","rootRelationsToBuild","rootRelationships","rootTableIDColType","rootTableName","incomingRootTableName","tableName","timestamps","versions","isRoot","columns","indexes","localesColumns","localesIndexes","localesTable","textsTable","numbersTable","relationships","Set","relationshipsTable","relationsToBuild","Map","idColType","hasLocalizedField","hasLocalizedManyNumberField","hasLocalizedManyTextField","hasLocalizedRelationshipField","hasManyNumberField","hasManyTextField","newTableName","parentTableName","localizedRelations","nonLocalizedRelations","forEach","type","localized","target","key","map","set","createdAt","mode","precision","withTimezone","defaultNow","notNull","updatedAt","table","pgSchema","cols","extraConfig","Object","entries","reduce","config","func","result","acc","colName","tables","size","localeTableName","localesSuffix","id","primaryKey","_locale","enums","enum__locales","_parentID","_localeParent","on","_parentIdFk","name","foreignColumns","onDelete","many","one","references","relationName","textsTableName","order","parent","path","text","locale","orderParentIdx","parentFk","text_idx","localeParent","numbersTableName","number","numberIdx","relationshipColumns","relationExtraConfig","relationshipsTableName","relationshipsSuffix","relationTo","relationshipConfig","payload","collections","formattedRelationTo","throwValidationError","colType","idType","relatedCollectionCustomIDType","slug","customIDType","parentIdx","pathIdx","localeIdx","relatedTableName","idColumnName","_locales","_texts","_numbers","_rels"],"mappings":"AAUA,SAASA,eAAe,QAAQ,sBAAqB;AACrD,SAASC,SAAS,QAAQ,cAAa;AACvC,SACEC,UAAU,EACVC,KAAK,EACLC,OAAO,EACPC,OAAO,EACPC,MAAM,EACNC,SAAS,EACTC,MAAM,EACNC,OAAO,QACF,sBAAqB;AAC5B,OAAOC,iBAAiB,gBAAe;AAIvC,SAASC,iBAAiB,QAAQ,yBAAwB;AAC1D,SAASC,WAAW,QAAQ,mBAAkB;AAC9C,SAASC,cAAc,QAAQ,sBAAqB;AAqCpD,OAAO,MAAMC,aAAa,CAAC,EACzBC,OAAO,EACPC,cAAc,CAAC,CAAC,EAChBC,kBAAkB,CAAC,CAAC,EACpBC,cAAc,EACdC,gBAAgB,KAAK,EACrBC,MAAM,EACNC,oBAAoB,EACpBC,iBAAiB,EACjBC,kBAAkB,EAClBC,eAAeC,qBAAqB,EACpCC,SAAS,EACTC,UAAU,EACVC,QAAQ,EACH;IACL,MAAMC,SAAS,CAACJ;IAChB,MAAMD,gBAAgBC,yBAAyBC;IAC/C,MAAMI,UAA2Cd;IACjD,MAAMe,UAAkE,CAAC;IAEzE,MAAMC,iBAAkD,CAAC;IACzD,MAAMC,iBAAyE,CAAC;IAChF,IAAIC;IACJ,IAAIC;IACJ,IAAIC;IAEJ,uCAAuC;IACvC,MAA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AQgE,MAAM,CAACvB,OAAO,EAAE;oBAAE0C,cAAczC;gBAAI;YACjE;QACF;QAEA,IAAId,mBAAmB;YACrBiC,OAAOwD,QAAQ,GAAGrC,KAAK7D,cAAc;gBAAEgE,cAAc;YAAW;QAClE;QAEA,IAAIlD,kBAAkB;YACpB4B,OAAOyD,MAAM,GAAGtC,KAAK5D,YAAY;gBAAE+D,cAAc;YAAS;QAC5D;QAEA,IAAInD,oBAAoB;YACtB6B,OAAO0D,QAAQ,GAAGvC,KAAK3D,cAAc;gBAAE8D,cAAc;YAAW;QAClE;QAEA,IAAI7D,cAAc2C,IAAI,IAAIzC,oBAAoB;YAC5CqC,OAAO2D,KAAK,GAAGxC,KAAKxD,oBAAoB;gBACtC2D,cAAc;YAChB;QACF;QAEA,OAAOtB;IACT;IAEA,OAAO;QAAE7B;QAAoBC;QAAkBR;IAAiB;AAClE,EAAC"}
@@ -1,12 +0,0 @@
1
- import type { GenericColumn } from '../types.js';
2
- type CreateIndexArgs = {
3
- columnName: string;
4
- name: string | string[];
5
- tableName: string;
6
- unique?: boolean;
7
- };
8
- export declare const createIndex: ({ name, columnName, tableName, unique }: CreateIndexArgs) => (table: {
9
- [x: string]: GenericColumn;
10
- }) => import("drizzle-orm/pg-core").IndexBuilder;
11
- export {};
12
- //# sourceMappingURL=createIndex.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createIndex.d.ts","sourceRoot":"","sources":["../../src/schema/createIndex.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAEhD,KAAK,eAAe,GAAG;IACrB,UAAU,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;IACvB,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,eAAO,MAAM,WAAW,4CAA6C,eAAe,aACnE;IAAE,CAAC,CAAC,EAAE,MAAM,GAAG,aAAa,CAAA;CAAE,+CAc9C,CAAA"}