@payloadcms/db-postgres 3.0.0-canary.ef0a8d0 → 3.0.0-canary.f118ee4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. package/dist/connect.d.ts.map +1 -1
  2. package/dist/connect.js +6 -0
  3. package/dist/connect.js.map +1 -1
  4. package/dist/index.d.ts +0 -1
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +15 -16
  7. package/dist/index.js.map +1 -1
  8. package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.d.ts.map +1 -1
  9. package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.js +0 -4
  10. package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.js.map +1 -1
  11. package/dist/predefinedMigrations/v2-v3/index.d.ts.map +1 -1
  12. package/dist/predefinedMigrations/v2-v3/index.js +1 -7
  13. package/dist/predefinedMigrations/v2-v3/index.js.map +1 -1
  14. package/dist/predefinedMigrations/v2-v3/migrateRelationships.d.ts.map +1 -1
  15. package/dist/predefinedMigrations/v2-v3/migrateRelationships.js +0 -1
  16. package/dist/predefinedMigrations/v2-v3/migrateRelationships.js.map +1 -1
  17. package/dist/types.d.ts +26 -105
  18. package/dist/types.d.ts.map +1 -1
  19. package/dist/types.js.map +1 -1
  20. package/package.json +8 -8
  21. package/dist/countDistinct.d.ts +0 -3
  22. package/dist/countDistinct.d.ts.map +0 -1
  23. package/dist/countDistinct.js +0 -26
  24. package/dist/countDistinct.js.map +0 -1
  25. package/dist/createJSONQuery/convertPathToJSONTraversal.d.ts +0 -2
  26. package/dist/createJSONQuery/convertPathToJSONTraversal.d.ts.map +0 -1
  27. package/dist/createJSONQuery/convertPathToJSONTraversal.js +0 -14
  28. package/dist/createJSONQuery/convertPathToJSONTraversal.js.map +0 -1
  29. package/dist/createJSONQuery/formatJSONPathSegment.d.ts +0 -2
  30. package/dist/createJSONQuery/formatJSONPathSegment.d.ts.map +0 -1
  31. package/dist/createJSONQuery/formatJSONPathSegment.js +0 -5
  32. package/dist/createJSONQuery/formatJSONPathSegment.js.map +0 -1
  33. package/dist/createJSONQuery/index.d.ts +0 -10
  34. package/dist/createJSONQuery/index.d.ts.map +0 -1
  35. package/dist/createJSONQuery/index.js +0 -54
  36. package/dist/createJSONQuery/index.js.map +0 -1
  37. package/dist/createMigration.d.ts +0 -3
  38. package/dist/createMigration.d.ts.map +0 -1
  39. package/dist/createMigration.js +0 -80
  40. package/dist/createMigration.js.map +0 -1
  41. package/dist/defaultSnapshot.d.ts +0 -3
  42. package/dist/defaultSnapshot.d.ts.map +0 -1
  43. package/dist/defaultSnapshot.js +0 -16
  44. package/dist/defaultSnapshot.js.map +0 -1
  45. package/dist/deleteWhere.d.ts +0 -3
  46. package/dist/deleteWhere.d.ts.map +0 -1
  47. package/dist/deleteWhere.js +0 -7
  48. package/dist/deleteWhere.js.map +0 -1
  49. package/dist/dropDatabase.d.ts +0 -3
  50. package/dist/dropDatabase.d.ts.map +0 -1
  51. package/dist/dropDatabase.js +0 -9
  52. package/dist/dropDatabase.js.map +0 -1
  53. package/dist/execute.d.ts +0 -3
  54. package/dist/execute.d.ts.map +0 -1
  55. package/dist/execute.js +0 -13
  56. package/dist/execute.js.map +0 -1
  57. package/dist/generateDrizzleJSON.d.ts +0 -3
  58. package/dist/generateDrizzleJSON.d.ts.map +0 -1
  59. package/dist/generateDrizzleJSON.js +0 -8
  60. package/dist/generateDrizzleJSON.js.map +0 -1
  61. package/dist/generateMigration.d.ts +0 -3
  62. package/dist/generateMigration.d.ts.map +0 -1
  63. package/dist/generateMigration.js +0 -8
  64. package/dist/generateMigration.js.map +0 -1
  65. package/dist/getMigrationTemplate.d.ts +0 -3
  66. package/dist/getMigrationTemplate.d.ts.map +0 -1
  67. package/dist/getMigrationTemplate.js +0 -12
  68. package/dist/getMigrationTemplate.js.map +0 -1
  69. package/dist/init.d.ts +0 -3
  70. package/dist/init.d.ts.map +0 -1
  71. package/dist/init.js +0 -91
  72. package/dist/init.js.map +0 -1
  73. package/dist/insert.d.ts +0 -3
  74. package/dist/insert.d.ts.map +0 -1
  75. package/dist/insert.js +0 -13
  76. package/dist/insert.js.map +0 -1
  77. package/dist/requireDrizzleKit.d.ts +0 -3
  78. package/dist/requireDrizzleKit.d.ts.map +0 -1
  79. package/dist/requireDrizzleKit.js +0 -5
  80. package/dist/requireDrizzleKit.js.map +0 -1
  81. package/dist/schema/build.d.ts +0 -34
  82. package/dist/schema/build.d.ts.map +0 -1
  83. package/dist/schema/build.js +0 -369
  84. package/dist/schema/build.js.map +0 -1
  85. package/dist/schema/createIndex.d.ts +0 -12
  86. package/dist/schema/createIndex.d.ts.map +0 -1
  87. package/dist/schema/createIndex.js +0 -18
  88. package/dist/schema/createIndex.js.map +0 -1
  89. package/dist/schema/idToUUID.d.ts +0 -3
  90. package/dist/schema/idToUUID.d.ts.map +0 -1
  91. package/dist/schema/idToUUID.js +0 -11
  92. package/dist/schema/idToUUID.js.map +0 -1
  93. package/dist/schema/parentIDColumnMap.d.ts +0 -4
  94. package/dist/schema/parentIDColumnMap.d.ts.map +0 -1
  95. package/dist/schema/parentIDColumnMap.js +0 -9
  96. package/dist/schema/parentIDColumnMap.js.map +0 -1
  97. package/dist/schema/setColumnID.d.ts +0 -11
  98. package/dist/schema/setColumnID.d.ts.map +0 -1
  99. package/dist/schema/setColumnID.js +0 -24
  100. package/dist/schema/setColumnID.js.map +0 -1
  101. package/dist/schema/traverseFields.d.ts +0 -36
  102. package/dist/schema/traverseFields.d.ts.map +0 -1
  103. package/dist/schema/traverseFields.js +0 -612
  104. package/dist/schema/traverseFields.js.map +0 -1
package/dist/types.d.ts CHANGED
@@ -1,120 +1,37 @@
1
- import type { Operators } from '@payloadcms/drizzle';
2
- import type { BuildQueryJoinAliases, DrizzleAdapter, TransactionPg } from '@payloadcms/drizzle/types';
3
- import type { DrizzleSnapshotJSON } from 'drizzle-kit/payload';
4
- import type { ColumnBaseConfig, ColumnDataType, DrizzleConfig, Relation, Relations, SQL } from 'drizzle-orm';
5
- import type { NodePgDatabase } from 'drizzle-orm/node-postgres';
6
- import type { PgColumn, PgEnum, PgInsertOnConflictDoUpdateConfig, PgSchema, PgTableWithColumns } from 'drizzle-orm/pg-core';
7
- import type { PgTableFn } from 'drizzle-orm/pg-core/table';
8
- import type { Payload, PayloadRequest } from 'payload';
9
- import type { Pool, PoolConfig, QueryResult } from 'pg';
1
+ import type { BasePostgresAdapter, GenericEnum, MigrateDownArgs, MigrateUpArgs, PostgresDB } from '@payloadcms/drizzle/postgres';
2
+ import type { DrizzleAdapter } from '@payloadcms/drizzle/types';
3
+ import type { DrizzleConfig } from 'drizzle-orm';
4
+ import type { PgSchema, PgTableFn, PgTransactionConfig } from 'drizzle-orm/pg-core';
5
+ import type { Pool, PoolConfig } from 'pg';
10
6
  export type Args = {
11
7
  idType?: 'serial' | 'uuid';
12
8
  localesSuffix?: string;
13
9
  logger?: DrizzleConfig['logger'];
14
10
  migrationDir?: string;
15
11
  pool: PoolConfig;
12
+ prodMigrations?: {
13
+ down: (args: MigrateDownArgs) => Promise<void>;
14
+ name: string;
15
+ up: (args: MigrateUpArgs) => Promise<void>;
16
+ }[];
16
17
  push?: boolean;
17
18
  relationshipsSuffix?: string;
18
- schemaName?: string;
19
- versionsSuffix?: string;
20
- };
21
- export type GenericColumn = PgColumn<ColumnBaseConfig<ColumnDataType, string>, Record<string, unknown>>;
22
- export type GenericColumns = {
23
- [x: string]: GenericColumn;
24
- };
25
- export type GenericTable = PgTableWithColumns<{
26
- columns: GenericColumns;
27
- dialect: string;
28
- name: string;
29
- schema: string;
30
- }>;
31
- export type GenericEnum = PgEnum<[string, ...string[]]>;
32
- export type GenericRelation = Relations<string, Record<string, Relation<string>>>;
33
- export type PostgresDB = NodePgDatabase<Record<string, unknown>>;
34
- export type CountDistinct = (args: {
35
- db: PostgresDB | TransactionPg;
36
- joins: BuildQueryJoinAliases;
37
- tableName: string;
38
- where: SQL;
39
- }) => Promise<number>;
40
- export type DeleteWhere = (args: {
41
- db: PostgresDB | TransactionPg;
42
- tableName: string;
43
- where: SQL;
44
- }) => Promise<void>;
45
- export type DropDatabase = (args: {
46
- adapter: PostgresAdapter;
47
- }) => Promise<void>;
48
- export type Execute<T> = (args: {
49
- db?: PostgresDB | TransactionPg;
50
- drizzle?: PostgresDB;
51
- raw?: string;
52
- sql?: SQL<unknown>;
53
- }) => Promise<QueryResult<Record<string, T>>>;
54
- export type GenerateDrizzleJSON = (args: {
55
- schema: Record<string, GenericRelation | GenericTable>;
56
- }) => PgSchema;
57
- export type Insert = (args: {
58
- db: PostgresDB | TransactionPg;
59
- onConflictDoUpdate?: PgInsertOnConflictDoUpdateConfig<any>;
60
- tableName: string;
61
- values: Record<string, unknown> | Record<string, unknown>[];
62
- }) => Promise<Record<string, unknown>[]>;
63
- type PostgresDrizzleAdapter = Omit<DrizzleAdapter, 'countDistinct' | 'deleteWhere' | 'drizzle' | 'dropDatabase' | 'execute' | 'insert' | 'operators' | 'relations'>;
64
- export type PostgresAdapter = PostgresDrizzleAdapter & {
65
- countDistinct: CountDistinct;
66
- defaultDrizzleSnapshot: DrizzleSnapshotJSON;
67
- deleteWhere: DeleteWhere;
68
- drizzle: PostgresDB;
69
- dropDatabase: DropDatabase;
70
- enums: Record<string, GenericEnum>;
71
- execute: Execute<unknown>;
72
19
  /**
73
- * An object keyed on each table, with a key value pair where the constraint name is the key, followed by the dot-notation field name
74
- * Used for returning properly formed errors from unique fields
20
+ * The schema name to use for the database
21
+ * @experimental This only works when there are not other tables or enums of the same name in the database under a different schema. Awaiting fix from Drizzle.
75
22
  */
76
- fieldConstraints: Record<string, Record<string, string>>;
77
- generateDrizzleJSON: GenerateDrizzleJSON;
78
- idType: Args['idType'];
79
- initializing: Promise<void>;
80
- insert: Insert;
81
- localesSuffix?: string;
82
- logger: DrizzleConfig['logger'];
83
- operators: Operators;
84
- pgSchema?: {
85
- table: PgTableFn;
86
- } | PgSchema;
87
- pool: Pool;
88
- poolOptions: Args['pool'];
89
- push: boolean;
90
- rejectInitializing: () => void;
91
- relations: Record<string, GenericRelation>;
92
- relationshipsSuffix?: string;
93
- resolveInitializing: () => void;
94
- schema: Record<string, GenericEnum | GenericRelation | GenericTable>;
95
- schemaName?: Args['schemaName'];
96
- sessions: {
97
- [id: string]: {
98
- db: PostgresDB | TransactionPg;
99
- reject: () => Promise<void>;
100
- resolve: () => Promise<void>;
101
- };
102
- };
103
- tableNameMap: Map<string, string>;
104
- tables: Record<string, GenericTable>;
23
+ schemaName?: string;
24
+ transactionOptions?: PgTransactionConfig | false;
105
25
  versionsSuffix?: string;
106
26
  };
107
- export type IDType = 'integer' | 'numeric' | 'uuid' | 'varchar';
108
- export type MigrateUpArgs = {
109
- payload: Payload;
110
- req?: Partial<PayloadRequest>;
111
- };
112
- export type MigrateDownArgs = {
113
- payload: Payload;
114
- req?: Partial<PayloadRequest>;
115
- };
27
+ export type PostgresAdapter = {
28
+ pool: Pool;
29
+ poolOptions: PoolConfig;
30
+ } & BasePostgresAdapter;
116
31
  declare module 'payload' {
117
32
  interface DatabaseAdapter extends Omit<Args, 'idType' | 'logger' | 'migrationDir' | 'pool'>, DrizzleAdapter {
33
+ beginTransaction: (options?: PgTransactionConfig) => Promise<null | number | string>;
34
+ drizzle: PostgresDB;
118
35
  enums: Record<string, GenericEnum>;
119
36
  /**
120
37
  * An object keyed on each table, with a key value pair where the constraint name is the key, followed by the dot-notation field name
@@ -130,15 +47,19 @@ declare module 'payload' {
130
47
  } | PgSchema;
131
48
  pool: Pool;
132
49
  poolOptions: Args['pool'];
50
+ prodMigrations?: {
51
+ down: (args: MigrateDownArgs) => Promise<void>;
52
+ name: string;
53
+ up: (args: MigrateUpArgs) => Promise<void>;
54
+ }[];
133
55
  push: boolean;
134
56
  rejectInitializing: () => void;
135
57
  relationshipsSuffix?: string;
136
58
  resolveInitializing: () => void;
137
- schema: Record<string, GenericEnum | GenericRelation | GenericTable>;
59
+ schema: Record<string, unknown>;
138
60
  schemaName?: Args['schemaName'];
139
61
  tableNameMap: Map<string, string>;
140
62
  versionsSuffix?: string;
141
63
  }
142
64
  }
143
- export {};
144
65
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,KAAK,EACV,qBAAqB,EACrB,cAAc,EACd,aAAa,EACd,MAAM,2BAA2B,CAAA;AAClC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAC9D,OAAO,KAAK,EACV,gBAAgB,EAChB,cAAc,EACd,aAAa,EACb,QAAQ,EACR,SAAS,EACT,GAAG,EACJ,MAAM,aAAa,CAAA;AACpB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAC/D,OAAO,KAAK,EACV,QAAQ,EACR,MAAM,EACN,gCAAgC,EAChC,QAAQ,EACR,kBAAkB,EACnB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAC1D,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AACtD,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,IAAI,CAAA;AAEvD,MAAM,MAAM,IAAI,GAAG;IACjB,MAAM,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAA;IAC1B,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,MAAM,CAAC,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAA;IAChC,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,IAAI,EAAE,UAAU,CAAA;IAChB,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB,CAAA;AAED,MAAM,MAAM,aAAa,GA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,EAAE,CAAC,IAAI,EAAE,aAAa,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;SAC3C,EAAE,CAAA;QACH,IAAI,EAAE,OAAO,CAAA;QACb,kBAAkB,EAAE,MAAM,IAAI,CAAA;QAC9B,mBAAmB,CAAC,EAAE,MAAM,CAAA;QAC5B,mBAAmB,EAAE,MAAM,IAAI,CAAA;QAC/B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;QAC/B,UAAU,CAAC,EAAE,IAAI,CAAC,YAAY,CAAC,CAAA;QAC/B,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;QACjC,cAAc,CAAC,EAAE,MAAM,CAAA;KACxB;CACF"}
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type { Operators } from '@payloadcms/drizzle'\nimport type {\n BuildQueryJoinAliases,\n DrizzleAdapter,\n TransactionPg,\n} from '@payloadcms/drizzle/types'\nimport type { DrizzleSnapshotJSON } from 'drizzle-kit/payload'\nimport type {\n ColumnBaseConfig,\n ColumnDataType,\n DrizzleConfig,\n Relation,\n Relations,\n SQL,\n} from 'drizzle-orm'\nimport type { NodePgDatabase } from 'drizzle-orm/node-postgres'\nimport type {\n PgColumn,\n PgEnum,\n PgInsertOnConflictDoUpdateConfig,\n PgSchema,\n PgTableWithColumns,\n} from 'drizzle-orm/pg-core'\nimport type { PgTableFn } from 'drizzle-orm/pg-core/table'\nimport type { Payload, PayloadRequest } from 'payload'\nimport type { Pool, PoolConfig, QueryResult } from 'pg'\n\nexport type Args = {\n idType?: 'serial' | 'uuid'\n localesSuffix?: string\n logger?: DrizzleConfig['logger']\n migrationDir?: string\n pool: PoolConfig\n push?: boolean\n relationshipsSuffix?: string\n schemaName?: string\n versionsSuffix?: string\n}\n\nexport type GenericColumn = PgColumn<\n ColumnBaseConfig<ColumnDataType, string>,\n Record<string, unknown>\n>\n\nexport type GenericColumns = {\n [x: string]: GenericColumn\n}\n\nexport type GenericTable = PgTableWithColumns<{\n columns: GenericColumns\n dialect: string\n name: string\n schema: string\n}>\n\nexport type GenericEnum = PgEnum<[string, ...string[]]>\n\nexport type GenericRelation = Relations<string, Record<string, Relation<string>>>\n\nexport type PostgresDB = NodePgDatabase<Record<string, unknown>>\n\nexport type CountDistinct = (args: {\n db: PostgresDB | TransactionPg\n joins: BuildQueryJoinAliases\n tableName: string\n where: SQL\n}) => Promise<number>\n\nexport type DeleteWhere = (args: {\n db: PostgresDB | TransactionPg\n tableName: string\n where: SQL\n}) => Promise<void>\n\nexport type DropDatabase = (args: { adapter: PostgresAdapter }) => Promise<void>\n\nexport type Execute<T> = (args: {\n db?: PostgresDB | TransactionPg\n drizzle?: PostgresDB\n raw?: string\n sql?: SQL<unknown>\n}) => Promise<QueryResult<Record<string, T>>>\n\nexport type GenerateDrizzleJSON = (args: {\n schema: Record<string, GenericRelation | GenericTable>\n}) => PgSchema\n\nexport type Insert = (args: {\n db: PostgresDB | TransactionPg\n onConflictDoUpdate?: PgInsertOnConflictDoUpdateConfig<any>\n tableName: string\n values: Record<string, unknown> | Record<string, unknown>[]\n}) => Promise<Record<string, unknown>[]>\n\ntype PostgresDrizzleAdapter = Omit<\n DrizzleAdapter,\n | 'countDistinct'\n | 'deleteWhere'\n | 'drizzle'\n | 'dropDatabase'\n | 'execute'\n | 'insert'\n | 'operators'\n | 'relations'\n>\n\nexport type PostgresAdapter = PostgresDrizzleAdapter & {\n countDistinct: CountDistinct\n defaultDrizzleSnapshot: DrizzleSnapshotJSON\n deleteWhere: DeleteWhere\n drizzle: PostgresDB\n dropDatabase: DropDatabase\n enums: Record<string, GenericEnum>\n execute: Execute<unknown>\n /**\n * An object keyed on each table, with a key value pair where the constraint name is the key, followed by the dot-notation field name\n * Used for returning properly formed errors from unique fields\n */\n fieldConstraints: Record<string, Record<string, string>>\n generateDrizzleJSON: GenerateDrizzleJSON\n idType: Args['idType']\n initializing: Promise<void>\n insert: Insert\n localesSuffix?: string\n logger: DrizzleConfig['logger']\n operators: Operators\n pgSchema?: { table: PgTableFn } | PgSchema\n pool: Pool\n poolOptions: Args['pool']\n push: boolean\n rejectInitializing: () => void\n relations: Record<string, GenericRelation>\n relationshipsSuffix?: string\n resolveInitializing: () => void\n schema: Record<string, GenericEnum | GenericRelation | GenericTable>\n schemaName?: Args['schemaName']\n sessions: {\n [id: string]: {\n db: PostgresDB | TransactionPg\n reject: () => Promise<void>\n resolve: () => Promise<void>\n }\n }\n tableNameMap: Map<string, string>\n tables: Record<string, GenericTable>\n versionsSuffix?: string\n}\n\nexport type IDType = 'integer' | 'numeric' | 'uuid' | 'varchar'\n\nexport type MigrateUpArgs = { payload: Payload; req?: Partial<PayloadRequest> }\nexport type MigrateDownArgs = { payload: Payload; req?: Partial<PayloadRequest> }\n\ndeclare module 'payload' {\n export interface DatabaseAdapter\n extends Omit<Args, 'idType' | 'logger' | 'migrationDir' | 'pool'>,\n DrizzleAdapter {\n enums: Record<string, GenericEnum>\n /**\n * An object keyed on each table, with a key value pair where the constraint name is the key, followed by the dot-notation field name\n * Used for returning properly formed errors from unique fields\n */\n fieldConstraints: Record<string, Record<string, string>>\n idType: Args['idType']\n initializing: Promise<void>\n localesSuffix?: string\n logger: DrizzleConfig['logger']\n pgSchema?: { table: PgTableFn } | PgSchema\n pool: Pool\n poolOptions: Args['pool']\n push: boolean\n rejectInitializing: () => void\n relationshipsSuffix?: string\n resolveInitializing: () => void\n schema: Record<string, GenericEnum | GenericRelation | GenericTable>\n schemaName?: Args['schemaName']\n tableNameMap: Map<string, string>\n versionsSuffix?: string\n }\n}\n"],"names":[],"mappings":"AAuJA,WAAiF"}
1
+ {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type {\n BasePostgresAdapter,\n GenericEnum,\n MigrateDownArgs,\n MigrateUpArgs,\n PostgresDB,\n} from '@payloadcms/drizzle/postgres'\nimport type { DrizzleAdapter } from '@payloadcms/drizzle/types'\nimport type { DrizzleConfig } from 'drizzle-orm'\nimport type { PgSchema, PgTableFn, PgTransactionConfig } from 'drizzle-orm/pg-core'\nimport type { Pool, PoolConfig } from 'pg'\n\nexport type Args = {\n idType?: 'serial' | 'uuid'\n localesSuffix?: string\n logger?: DrizzleConfig['logger']\n migrationDir?: string\n pool: PoolConfig\n prodMigrations?: {\n down: (args: MigrateDownArgs) => Promise<void>\n name: string\n up: (args: MigrateUpArgs) => Promise<void>\n }[]\n push?: boolean\n relationshipsSuffix?: string\n /**\n * The schema name to use for the database\n * @experimental This only works when there are not other tables or enums of the same name in the database under a different schema. Awaiting fix from Drizzle.\n */\n schemaName?: string\n transactionOptions?: PgTransactionConfig | false\n versionsSuffix?: string\n}\n\nexport type PostgresAdapter = {\n pool: Pool\n poolOptions: PoolConfig\n} & BasePostgresAdapter\n\ndeclare module 'payload' {\n export interface DatabaseAdapter\n extends Omit<Args, 'idType' | 'logger' | 'migrationDir' | 'pool'>,\n DrizzleAdapter {\n beginTransaction: (options?: PgTransactionConfig) => Promise<null | number | string>\n drizzle: PostgresDB\n enums: Record<string, GenericEnum>\n /**\n * An object keyed on each table, with a key value pair where the constraint name is the key, followed by the dot-notation field name\n * Used for returning properly formed errors from unique fields\n */\n fieldConstraints: Record<string, Record<string, string>>\n idType: Args['idType']\n initializing: Promise<void>\n localesSuffix?: string\n logger: DrizzleConfig['logger']\n pgSchema?: { table: PgTableFn } | PgSchema\n pool: Pool\n poolOptions: Args['pool']\n prodMigrations?: {\n down: (args: MigrateDownArgs) => Promise<void>\n name: string\n up: (args: MigrateUpArgs) => Promise<void>\n }[]\n push: boolean\n rejectInitializing: () => void\n relationshipsSuffix?: string\n resolveInitializing: () => void\n schema: Record<string, unknown>\n schemaName?: Args['schemaName']\n tableNameMap: Map<string, string>\n versionsSuffix?: string\n }\n}\n"],"names":[],"mappings":"AAkCA,WAGuB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/db-postgres",
3
- "version": "3.0.0-canary.ef0a8d0",
3
+ "version": "3.0.0-canary.f118ee4",
4
4
  "description": "The officially supported Postgres database adapter for Payload",
5
5
  "homepage": "https://payloadcms.com",
6
6
  "repository": {
@@ -36,24 +36,24 @@
36
36
  ],
37
37
  "dependencies": {
38
38
  "console-table-printer": "2.11.2",
39
- "drizzle-kit": "0.22.7",
40
- "drizzle-orm": "0.31.2",
39
+ "drizzle-kit": "0.23.2-df9e596",
40
+ "drizzle-orm": "0.32.1",
41
41
  "pg": "8.11.3",
42
42
  "prompts": "2.4.2",
43
43
  "to-snake-case": "1.0.0",
44
44
  "uuid": "10.0.0",
45
- "@payloadcms/drizzle": "3.0.0-canary.ef0a8d0"
45
+ "@payloadcms/drizzle": "3.0.0-canary.f118ee4"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@hyrious/esbuild-plugin-commonjs": "^0.2.4",
49
49
  "@types/pg": "8.10.2",
50
50
  "@types/to-snake-case": "1.0.0",
51
51
  "esbuild": "0.23.0",
52
- "payload": "3.0.0-canary.ef0a8d0",
53
- "@payloadcms/eslint-config": "3.0.0-beta.59"
52
+ "@payloadcms/eslint-config": "3.0.0-beta.59",
53
+ "payload": "3.0.0-canary.f118ee4"
54
54
  },
55
55
  "peerDependencies": {
56
- "payload": "3.0.0-canary.ef0a8d0"
56
+ "payload": "3.0.0-canary.f118ee4"
57
57
  },
58
58
  "scripts": {
59
59
  "build": "rimraf .dist && rimraf tsconfig.tsbuildinfo && pnpm build:types && pnpm build:swc && pnpm build:esbuild && pnpm renamePredefinedMigrations",
@@ -61,6 +61,6 @@
61
61
  "build:swc": "swc ./src -d ./dist --config-file .swcrc --strip-leading-paths",
62
62
  "build:types": "tsc --emitDeclarationOnly --outDir dist",
63
63
  "clean": "rimraf {dist,*.tsbuildinfo}",
64
- "renamePredefinedMigrations": "tsx ./scripts/renamePredefinedMigrations.ts"
64
+ "renamePredefinedMigrations": "node --no-deprecation --import @swc-node/register/esm-register ./scripts/renamePredefinedMigrations.ts"
65
65
  }
66
66
  }
@@ -1,3 +0,0 @@
1
- import type { CountDistinct } from './types.js';
2
- export declare const countDistinct: CountDistinct;
3
- //# sourceMappingURL=countDistinct.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"countDistinct.d.ts","sourceRoot":"","sources":["../src/countDistinct.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAmB,MAAM,YAAY,CAAA;AAEhE,eAAO,MAAM,aAAa,EAAE,aA2B3B,CAAA"}
@@ -1,26 +0,0 @@
1
- import { chainMethods } from '@payloadcms/drizzle';
2
- import { sql } from 'drizzle-orm';
3
- export const countDistinct = async function countDistinct({ db, joins, tableName, where }) {
4
- const chainedMethods = [];
5
- joins.forEach(({ condition, table })=>{
6
- chainedMethods.push({
7
- args: [
8
- table,
9
- condition
10
- ],
11
- method: 'leftJoin'
12
- });
13
- });
14
- const countResult = await chainMethods({
15
- methods: chainedMethods,
16
- query: db.select({
17
- // @ts-expect-error generic string is not matching union type from drizzle
18
- count: sql`count
19
- (DISTINCT ${this.tables[tableName].id})`
20
- }).from(this.tables[tableName])// @ts-expect-error where is picking up libsql types
21
- .where(where)
22
- });
23
- return Number(countResult[0].count);
24
- };
25
-
26
- //# sourceMappingURL=countDistinct.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/countDistinct.ts"],"sourcesContent":["import type { ChainedMethods, TransactionPg } from '@payloadcms/drizzle/types'\n\nimport { chainMethods } from '@payloadcms/drizzle'\nimport { sql } from 'drizzle-orm'\n\nimport type { CountDistinct, PostgresAdapter } from './types.js'\n\nexport const countDistinct: CountDistinct = async function countDistinct(\n this: PostgresAdapter,\n { db, joins, tableName, where },\n) {\n const chainedMethods: ChainedMethods = []\n\n joins.forEach(({ condition, table }) => {\n chainedMethods.push({\n args: [table, condition],\n method: 'leftJoin',\n })\n })\n\n const countResult = await chainMethods({\n methods: chainedMethods,\n query: (db as TransactionPg)\n .select({\n // @ts-expect-error generic string is not matching union type from drizzle\n count: sql<string>`count\n (DISTINCT ${this.tables[tableName].id})`,\n })\n .from(this.tables[tableName])\n // @ts-expect-error where is picking up libsql types\n .where(where),\n })\n\n return Number(countResult[0].count)\n}\n"],"names":["chainMethods","sql","countDistinct","db","joins","tableName","where","chainedMethods","forEach","condition","table","push","args","method","countResult","methods","query","select","count","tables","id","from","Number"],"mappings":"AAEA,SAASA,YAAY,QAAQ,sBAAqB;AAClD,SAASC,GAAG,QAAQ,cAAa;AAIjC,OAAO,MAAMC,gBAA+B,eAAeA,cAEzD,EAAEC,EAAE,EAAEC,KAAK,EAAEC,SAAS,EAAEC,KAAK,EAAE;IAE/B,MAAMC,iBAAiC,EAAE;IAEzCH,MAAMI,OAAO,CAAC,CAAC,EAAEC,SAAS,EAAEC,KAAK,EAAE;QACjCH,eAAeI,IAAI,CAAC;YAClBC,MAAM;gBAACF;gBAAOD;aAAU;YACxBI,QAAQ;QACV;IACF;IAEA,MAAMC,cAAc,MAAMd,aAAa;QACrCe,SAASR;QACTS,OAAO,AAACb,GACLc,MAAM,CAAC;YACN,0EAA0E;YAC1EC,OAAOjB,GAAW,CAAC;sBACL,EAAE,IAAI,CAACkB,MAAM,CAACd,UAAU,CAACe,EAAE,CAAC,CAAC,CAAC;QAC9C,GACCC,IAAI,CAAC,IAAI,CAACF,MAAM,CAACd,UAAU,CAC5B,oDAAoD;SACnDC,KAAK,CAACA;IACX;IAEA,OAAOgB,OAAOR,WAAW,CAAC,EAAE,CAACI,KAAK;AACpC,EAAC"}
@@ -1,2 +0,0 @@
1
- export declare const convertPathToJSONTraversal: (incomingSegments: string[]) => string;
2
- //# sourceMappingURL=convertPathToJSONTraversal.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"convertPathToJSONTraversal.d.ts","sourceRoot":"","sources":["../../src/createJSONQuery/convertPathToJSONTraversal.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,0BAA0B,qBAAsB,MAAM,EAAE,WAUpE,CAAA"}
@@ -1,14 +0,0 @@
1
- import { formatJSONPathSegment } from './formatJSONPathSegment.js';
2
- export const convertPathToJSONTraversal = (incomingSegments)=>{
3
- const segments = [
4
- ...incomingSegments
5
- ];
6
- segments.shift();
7
- return segments.reduce((res, segment, i)=>{
8
- const formattedSegment = formatJSONPathSegment(segment);
9
- if (i + 1 === segments.length) return `${res}->>${formattedSegment}`;
10
- return `${res}->${formattedSegment}`;
11
- }, '');
12
- };
13
-
14
- //# sourceMappingURL=convertPathToJSONTraversal.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/createJSONQuery/convertPathToJSONTraversal.ts"],"sourcesContent":["import { formatJSONPathSegment } from './formatJSONPathSegment.js'\n\nexport const convertPathToJSONTraversal = (incomingSegments: string[]) => {\n const segments = [...incomingSegments]\n segments.shift()\n\n return segments.reduce((res, segment, i) => {\n const formattedSegment = formatJSONPathSegment(segment)\n\n if (i + 1 === segments.length) return `${res}->>${formattedSegment}`\n return `${res}->${formattedSegment}`\n }, '')\n}\n"],"names":["formatJSONPathSegment","convertPathToJSONTraversal","incomingSegments","segments","shift","reduce","res","segment","i","formattedSegment","length"],"mappings":"AAAA,SAASA,qBAAqB,QAAQ,6BAA4B;AAElE,OAAO,MAAMC,6BAA6B,CAACC;IACzC,MAAMC,WAAW;WAAID;KAAiB;IACtCC,SAASC,KAAK;IAEd,OAAOD,SAASE,MAAM,CAAC,CAACC,KAAKC,SAASC;QACpC,MAAMC,mBAAmBT,sBAAsBO;QAE/C,IAAIC,IAAI,MAAML,SAASO,MAAM,EAAE,OAAO,CAAC,EAAEJ,IAAI,GAAG,EAAEG,iBAAiB,CAAC;QACpE,OAAO,CAAC,EAAEH,IAAI,EAAE,EAAEG,iBAAiB,CAAC;IACtC,GAAG;AACL,EAAC"}
@@ -1,2 +0,0 @@
1
- export declare const formatJSONPathSegment: (segment: string) => string;
2
- //# sourceMappingURL=formatJSONPathSegment.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"formatJSONPathSegment.d.ts","sourceRoot":"","sources":["../../src/createJSONQuery/formatJSONPathSegment.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,YAAa,MAAM,WAEpD,CAAA"}
@@ -1,5 +0,0 @@
1
- export const formatJSONPathSegment = (segment)=>{
2
- return Number.isNaN(parseInt(segment)) ? `'${segment}'` : segment;
3
- };
4
-
5
- //# sourceMappingURL=formatJSONPathSegment.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/createJSONQuery/formatJSONPathSegment.ts"],"sourcesContent":["export const formatJSONPathSegment = (segment: string) => {\n return Number.isNaN(parseInt(segment)) ? `'${segment}'` : segment\n}\n"],"names":["formatJSONPathSegment","segment","Number","isNaN","parseInt"],"mappings":"AAAA,OAAO,MAAMA,wBAAwB,CAACC;IACpC,OAAOC,OAAOC,KAAK,CAACC,SAASH,YAAY,CAAC,CAAC,EAAEA,QAAQ,CAAC,CAAC,GAAGA;AAC5D,EAAC"}
@@ -1,10 +0,0 @@
1
- type Args = {
2
- operator: string;
3
- pathSegments: string[];
4
- treatAsArray?: string[];
5
- treatRootAsArray?: boolean;
6
- value: unknown;
7
- };
8
- export declare const createJSONQuery: ({ operator, pathSegments, treatAsArray, treatRootAsArray, value, }: Args) => string;
9
- export {};
10
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/createJSONQuery/index.ts"],"names":[],"mappings":"AAmDA,KAAK,IAAI,GAAG;IACV,QAAQ,EAAE,MAAM,CAAA;IAChB,YAAY,EAAE,MAAM,EAAE,CAAA;IACtB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;IACvB,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,KAAK,EAAE,OAAO,CAAA;CACf,CAAA;AAED,eAAO,MAAM,eAAe,uEAMzB,IAAI,KAAG,MAqBT,CAAA"}
@@ -1,54 +0,0 @@
1
- import { convertPathToJSONTraversal } from './convertPathToJSONTraversal.js';
2
- import { formatJSONPathSegment } from './formatJSONPathSegment.js';
3
- const operatorMap = {
4
- contains: '~*',
5
- equals: '=',
6
- like: '~*'
7
- };
8
- const fromArray = ({ isRoot, operator, pathSegments, treatAsArray, value })=>{
9
- const newPathSegments = pathSegments.slice(isRoot ? 1 : 2);
10
- const alias = `${pathSegments[isRoot ? 0 : 1]}_alias_${newPathSegments.length}`;
11
- newPathSegments.unshift(alias);
12
- const arrayElements = isRoot ? pathSegments[0] : `${pathSegments[0]} -> ${formatJSONPathSegment(pathSegments[1])}`;
13
- return `EXISTS (
14
- SELECT 1
15
- FROM jsonb_array_elements(${arrayElements}) AS ${alias}
16
- WHERE ${createJSONQuery({
17
- operator,
18
- pathSegments: newPathSegments,
19
- treatAsArray,
20
- value
21
- })}
22
- )`;
23
- };
24
- const createConstraint = ({ operator, pathSegments, value })=>{
25
- const jsonQuery = convertPathToJSONTraversal(pathSegments);
26
- return `${pathSegments[0]}${jsonQuery} ${operatorMap[operator]} '${value}'`;
27
- };
28
- export const createJSONQuery = ({ operator, pathSegments, treatAsArray, treatRootAsArray, value })=>{
29
- if (treatRootAsArray) {
30
- return fromArray({
31
- isRoot: true,
32
- operator,
33
- pathSegments,
34
- treatAsArray,
35
- value
36
- });
37
- }
38
- if (treatAsArray.includes(pathSegments[1])) {
39
- return fromArray({
40
- operator,
41
- pathSegments,
42
- treatAsArray,
43
- value
44
- });
45
- }
46
- return createConstraint({
47
- operator,
48
- pathSegments,
49
- treatAsArray,
50
- value
51
- });
52
- };
53
-
54
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/createJSONQuery/index.ts"],"sourcesContent":["import { convertPathToJSONTraversal } from './convertPathToJSONTraversal.js'\nimport { formatJSONPathSegment } from './formatJSONPathSegment.js'\n\nconst operatorMap = {\n contains: '~*',\n equals: '=',\n like: '~*',\n}\n\ntype FromArrayArgs = {\n isRoot?: true\n operator: string\n pathSegments: string[]\n treatAsArray?: string[]\n value: unknown\n}\n\nconst fromArray = ({ isRoot, operator, pathSegments, treatAsArray, value }: FromArrayArgs) => {\n const newPathSegments = pathSegments.slice(isRoot ? 1 : 2)\n const alias = `${pathSegments[isRoot ? 0 : 1]}_alias_${newPathSegments.length}`\n\n newPathSegments.unshift(alias)\n\n const arrayElements = isRoot\n ? pathSegments[0]\n : `${pathSegments[0]} -> ${formatJSONPathSegment(pathSegments[1])}`\n\n return `EXISTS (\n SELECT 1\n FROM jsonb_array_elements(${arrayElements}) AS ${alias}\n WHERE ${createJSONQuery({\n operator,\n pathSegments: newPathSegments,\n treatAsArray,\n value,\n })}\n )`\n}\n\ntype CreateConstraintArgs = {\n operator: string\n pathSegments: string[]\n treatAsArray?: string[]\n value: unknown\n}\n\nconst createConstraint = ({ operator, pathSegments, value }: CreateConstraintArgs): string => {\n const jsonQuery = convertPathToJSONTraversal(pathSegments)\n return `${pathSegments[0]}${jsonQuery} ${operatorMap[operator]} '${value}'`\n}\n\ntype Args = {\n operator: string\n pathSegments: string[]\n treatAsArray?: string[]\n treatRootAsArray?: boolean\n value: unknown\n}\n\nexport const createJSONQuery = ({\n operator,\n pathSegments,\n treatAsArray,\n treatRootAsArray,\n value,\n}: Args): string => {\n if (treatRootAsArray) {\n return fromArray({\n isRoot: true,\n operator,\n pathSegments,\n treatAsArray,\n value,\n })\n }\n\n if (treatAsArray.includes(pathSegments[1])) {\n return fromArray({\n operator,\n pathSegments,\n treatAsArray,\n value,\n })\n }\n\n return createConstraint({ operator, pathSegments, treatAsArray, value })\n}\n"],"names":["convertPathToJSONTraversal","formatJSONPathSegment","operatorMap","contains","equals","like","fromArray","isRoot","operator","pathSegments","treatAsArray","value","newPathSegments","slice","alias","length","unshift","arrayElements","createJSONQuery","createConstraint","jsonQuery","treatRootAsArray","includes"],"mappings":"AAAA,SAASA,0BAA0B,QAAQ,kCAAiC;AAC5E,SAASC,qBAAqB,QAAQ,6BAA4B;AAElE,MAAMC,cAAc;IAClBC,UAAU;IACVC,QAAQ;IACRC,MAAM;AACR;AAUA,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ration } from 'payload';
2
- export declare const createMigration: CreateMigration;
3
- //# sourceMappingURL=createMigration.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createMigration.d.ts","sourceRoot":"","sources":["../src/createMigration.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAgB9C,eAAO,MAAM,eAAe,EAAE,eA6F7B,CAAA"}
@@ -1,80 +0,0 @@
1
- /* eslint-disable no-restricted-syntax, no-await-in-loop */ import fs from 'fs';
2
- import { createRequire } from 'module';
3
- import path from 'path';
4
- import { getPredefinedMigration } from 'payload';
5
- import prompts from 'prompts';
6
- import { fileURLToPath } from 'url';
7
- import { defaultDrizzleSnapshot } from './defaultSnapshot.js';
8
- import { getMigrationTemplate } from './getMigrationTemplate.js';
9
- const require = createRequire(import.meta.url);
10
- export const createMigration = async function createMigration({ file, forceAcceptWarning, migrationName, payload }) {
11
- const filename = fileURLToPath(import.meta.url);
12
- const dirname = path.dirname(filename);
13
- const dir = payload.db.migrationDir;
14
- if (!fs.existsSync(dir)) {
15
- fs.mkdirSync(dir);
16
- }
17
- const { generateDrizzleJson, generateMigration } = require('drizzle-kit/payload');
18
- const drizzleJsonAfter = generateDrizzleJson(this.schema);
19
- const [yyymmdd, hhmmss] = new Date().toISOString().split('T');
20
- const formattedDate = yyymmdd.replace(/\D/g, '');
21
- const formattedTime = hhmmss.split('.')[0].replace(/\D/g, '');
22
- let imports = '';
23
- let downSQL;
24
- let upSQL;
25
- ({ downSQL, imports, upSQL } = await getPredefinedMigration({
26
- dirname,
27
- file,
28
- migrationName,
29
- payload
30
- }));
31
- const timestamp = `${formattedDate}_${formattedTime}`;
32
- const name = migrationName || file?.split('/').slice(2).join('/');
33
- const fileName = `${timestamp}${name ? `_${name.replace(/\W/g, '_')}` : ''}`;
34
- const filePath = `${dir}/${fileName}`;
35
- let drizzleJsonBefore = defaultDrizzleSnapshot;
36
- if (!upSQL) {
37
- // Get latest migration snapshot
38
- const latestSnapshot = fs.readdirSync(dir).filter((file)=>file.endsWith('.json')).sort().reverse()?.[0];
39
- if (latestSnapshot) {
40
- drizzleJsonBefore = JSON.parse(fs.readFileSync(`${dir}/${latestSnapshot}`, 'utf8'));
41
- }
42
- const sqlStatementsUp = await generateMigration(drizzleJsonBefore, drizzleJsonAfter);
43
- const sqlStatementsDown = await generateMigration(drizzleJsonAfter, drizzleJsonBefore);
44
- const sqlExecute = 'await db.execute(sql`';
45
- if (sqlStatementsUp?.length) {
46
- upSQL = `${sqlExecute}\n ${sqlStatementsUp?.join('\n')}\`)`;
47
- }
48
- if (sqlStatementsDown?.length) {
49
- downSQL = `${sqlExecute}\n ${sqlStatementsDown?.join('\n')}\`)`;
50
- }
51
- if (!upSQL?.length && !downSQL?.length && !forceAcceptWarning) {
52
- const { confirm: shouldCreateBlankMigration } = await prompts({
53
- name: 'confirm',
54
- type: 'confirm',
55
- initial: false,
56
- message: 'No schema changes detected. Would you like to create a blank migration file?'
57
- }, {
58
- onCancel: ()=>{
59
- process.exit(0);
60
- }
61
- });
62
- if (!shouldCreateBlankMigration) {
63
- process.exit(0);
64
- }
65
- }
66
- // write schema
67
- fs.writeFileSync(`${filePath}.json`, JSON.stringify(drizzleJsonAfter, null, 2));
68
- }
69
- // write migration
70
- fs.writeFileSync(`${filePath}.ts`, getMigrationTemplate({
71
- downSQL: downSQL || ` // Migration code`,
72
- imports,
73
- upSQL: upSQL || ` // Migration code`
74
- }));
75
- payload.logger.info({
76
- msg: `Migration created at ${filePath}.ts`
77
- });
78
- };
79
-
80
- //# sourceMappingURL=createMigration.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/createMigration.ts"],"sourcesContent":["/* eslint-disable no-restricted-syntax, no-await-in-loop */\nimport type { DrizzleSnapshotJSON } from 'drizzle-kit/payload'\nimport type { CreateMigration } from 'payload'\n\nimport fs from 'fs'\nimport { createRequire } from 'module'\nimport path from 'path'\nimport { getPredefinedMigration } from 'payload'\nimport prompts from 'prompts'\nimport { fileURLToPath } from 'url'\n\nimport type { PostgresAdapter } 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: PostgresAdapter,\n { file, forceAcceptWarning, migrationName, payload },\n) {\n const filename = fileURLToPath(import.meta.url)\n const dirname = path.dirname(filename)\n const dir = payload.db.migrationDir\n if (!fs.existsSync(dir)) {\n fs.mkdirSync(dir)\n }\n const { generateDrizzleJson, generateMigration } = require('drizzle-kit/payload')\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 (!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(\n fs.readFileSync(`${dir}/${latestSnapshot}`, 'utf8'),\n ) as DrizzleSnapshotJSON\n }\n\n const sqlStatementsUp = await generateMigration(drizzleJsonBefore, drizzleJsonAfter)\n const sqlStatementsDown = await generateMigration(drizzleJsonAfter, drizzleJsonBefore)\n const sqlExecute = 'await db.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 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 upSQL: upSQL || ` // Migration code`,\n }),\n )\n payload.logger.info({ msg: `Migration created at ${filePath}.ts` })\n}\n"],"names":["fs","createRequire","path","getPredefinedMigration","prompts","fileURLToPath","defaultDrizzleSnapshot","getMigrationTemplate","require","url","createMigration","file","forceAcceptWarning","migrationName","payload","filename","dirname","dir","db","migrationDir","existsSync","mkdirSync","generateDrizzleJson","generateMigration","drizzleJsonAfter","schema","yyymmdd","hhmmss","Date","toISOString","split","formattedDate","replace","formattedTime","imports","downSQL","upSQL","timestamp","name","slice","join","fileName","filePath","drizzleJsonBefore","latestSnapshot","readdirSync","filter","endsWith","sort","reverse","JSON","parse","readFileSync","sqlStatementsUp","sqlStatementsDown","sqlExecute","length","confirm","shouldCreateBlankMigration","type","initial","message","onCancel","process","exit","writeFileSync","stringify","logger","info","msg"],"mappings":"AAAA,yDAAyD,GAIzD,OAAOA,QAAQ,KAAI;AACnB,SAASC,aAAa,QAAQ,SAAQ;AACtC,OAAOC,UAAU,OAAM;AACvB,SAASC,sBAAsB,QAAQ,UAAS;AAChD,OAAOC,aAAa,UAAS;AAC7B,SAASC,aAAa,QAAQ,MAAK;AAInC,SAASC,sBAAsB,QAAQ,uBAAsB;AAC7D,SAASC,oBAAoB,QAAQ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mB,CAAC;QACzCD;QACAE,OAAOA,SAAS,CAAC,mBAAmB,CAAC;IACvC;IAEFtB,QAAQqD,MAAM,CAACC,IAAI,CAAC;QAAEC,KAAK,CAAC,qBAAqB,EAAE3B,SAAS,GAAG,CAAC;IAAC;AACnE,EAAC"}
@@ -1,3 +0,0 @@
1
- import type { DrizzleSnapshotJSON } from 'drizzle-kit/payload';
2
- export declare const defaultDrizzleSnapshot: DrizzleSnapshotJSON;
3
- //# sourceMappingURL=defaultSnapshot.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"defaultSnapshot.d.ts","sourceRoot":"","sources":["../src/defaultSnapshot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAE9D,eAAO,MAAM,sBAAsB,EAAE,mBAapC,CAAA"}
@@ -1,16 +0,0 @@
1
- export const defaultDrizzleSnapshot = {
2
- id: '00000000-0000-0000-0000-000000000000',
3
- _meta: {
4
- columns: {},
5
- schemas: {},
6
- tables: {}
7
- },
8
- dialect: 'postgresql',
9
- enums: {},
10
- prevId: '00000000-0000-0000-0000-00000000000',
11
- schemas: {},
12
- tables: {},
13
- version: '7'
14
- };
15
-
16
- //# sourceMappingURL=defaultSnapshot.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/defaultSnapshot.ts"],"sourcesContent":["import type { DrizzleSnapshotJSON } from 'drizzle-kit/payload'\n\nexport const defaultDrizzleSnapshot: DrizzleSnapshotJSON = {\n id: '00000000-0000-0000-0000-000000000000',\n _meta: {\n columns: {},\n schemas: {},\n tables: {},\n },\n dialect: 'postgresql',\n enums: {},\n prevId: '00000000-0000-0000-0000-00000000000',\n schemas: {},\n tables: {},\n version: '7',\n}\n"],"names":["defaultDrizzleSnapshot","id","_meta","columns","schemas","tables","dialect","enums","prevId","version"],"mappings":"AAEA,OAAO,MAAMA,yBAA8C;IACzDC,IAAI;IACJC,OAAO;QACLC,SAAS,CAAC;QACVC,SAAS,CAAC;QACVC,QAAQ,CAAC;IACX;IACAC,SAAS;IACTC,OAAO,CAAC;IACRC,QAAQ;IACRJ,SAAS,CAAC;IACVC,QAAQ,CAAC;IACTI,SAAS;AACX,EAAC"}
@@ -1,3 +0,0 @@
1
- import type { DeleteWhere } from './types.js';
2
- export declare const deleteWhere: DeleteWhere;
3
- //# sourceMappingURL=deleteWhere.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"deleteWhere.d.ts","sourceRoot":"","sources":["../src/deleteWhere.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAE7C,eAAO,MAAM,WAAW,EAAE,WAMzB,CAAA"}
@@ -1,7 +0,0 @@
1
- export const deleteWhere = async function deleteWhere({ db, tableName, where }) {
2
- const table = this.tables[tableName];
3
- await db.delete(table)// @ts-expect-error where is picking up libsql types
4
- .where(where);
5
- };
6
-
7
- //# sourceMappingURL=deleteWhere.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/deleteWhere.ts"],"sourcesContent":["import type { TransactionPg } from '@payloadcms/drizzle/types'\n\nimport type { DeleteWhere } from './types.js'\n\nexport const deleteWhere: DeleteWhere = async function deleteWhere({ db, tableName, where }) {\n const table = this.tables[tableName]\n await (db as TransactionPg)\n .delete(table)\n // @ts-expect-error where is picking up libsql types\n .where(where)\n}\n"],"names":["deleteWhere","db","tableName","where","table","tables","delete"],"mappings":"AAIA,OAAO,MAAMA,cAA2B,eAAeA,YAAY,EAAEC,EAAE,EAAEC,SAAS,EAAEC,KAAK,EAAE;IACzF,MAAMC,QAAQ,IAAI,CAACC,MAAM,CAACH,UAAU;IACpC,MAAM,AAACD,GACJK,MAAM,CAACF,MACR,oDAAoD;KACnDD,KAAK,CAACA;AACX,EAAC"}
@@ -1,3 +0,0 @@
1
- import type { DropDatabase } from './types.js';
2
- export declare const dropDatabase: DropDatabase;
3
- //# sourceMappingURL=dropDatabase.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dropDatabase.d.ts","sourceRoot":"","sources":["../src/dropDatabase.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAE9C,eAAO,MAAM,YAAY,EAAE,YAM1B,CAAA"}
@@ -1,9 +0,0 @@
1
- export const dropDatabase = async function dropDatabase({ adapter }) {
2
- await adapter.execute({
3
- drizzle: adapter.drizzle,
4
- raw: `drop schema if exists ${this.schemaName || 'public'} cascade;
5
- create schema ${this.schemaName || 'public'};`
6
- });
7
- };
8
-
9
- //# sourceMappingURL=dropDatabase.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/dropDatabase.ts"],"sourcesContent":["import type { DropDatabase } from './types.js'\n\nexport const dropDatabase: DropDatabase = async function dropDatabase({ adapter }) {\n await adapter.execute({\n drizzle: adapter.drizzle,\n raw: `drop schema if exists ${this.schemaName || 'public'} cascade;\n create schema ${this.schemaName || 'public'};`,\n })\n}\n"],"names":["dropDatabase","adapter","execute","drizzle","raw","schemaName"],"mappings":"AAEA,OAAO,MAAMA,eAA6B,eAAeA,aAAa,EAAEC,OAAO,EAAE;IAC/E,MAAMA,QAAQC,OAAO,CAAC;QACpBC,SAASF,QAAQE,OAAO;QACxBC,KAAK,CAAC,sBAAsB,EAAE,IAAI,CAACC,UAAU,IAAI,SAAS;kBAC5C,EAAE,IAAI,CAACA,UAAU,IAAI,SAAS,CAAC,CAAC;IAChD;AACF,EAAC"}