@payloadcms/db-postgres 3.0.0-alpha.62 → 3.0.0-alpha.64

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +3 -3
  2. package/src/index.ts +0 -157
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/db-postgres",
3
- "version": "3.0.0-alpha.62",
3
+ "version": "3.0.0-alpha.64",
4
4
  "description": "The officially supported Postgres database adapter for Payload",
5
5
  "repository": {
6
6
  "type": "git",
@@ -31,10 +31,10 @@
31
31
  "@types/pg": "8.10.2",
32
32
  "@types/to-snake-case": "1.0.0",
33
33
  "@payloadcms/eslint-config": "1.1.1",
34
- "payload": "3.0.0-alpha.62"
34
+ "payload": "3.0.0-alpha.64"
35
35
  },
36
36
  "peerDependencies": {
37
- "payload": "3.0.0-alpha.62"
37
+ "payload": "3.0.0-alpha.64"
38
38
  },
39
39
  "exports": {
40
40
  ".": {
package/src/index.ts DELETED
@@ -1,157 +0,0 @@
1
- import type { Payload } from 'payload'
2
- import type { DatabaseAdapterObj } from 'payload/database'
3
-
4
- import fs from 'fs'
5
- import path from 'path'
6
- import { createDatabaseAdapter } from 'payload/database'
7
-
8
- import type { Args, PostgresAdapter } from './types.js'
9
-
10
- import { connect } from './connect.js'
11
- import { count } from './count.js'
12
- import { create } from './create.js'
13
- import { createGlobal } from './createGlobal.js'
14
- import { createGlobalVersion } from './createGlobalVersion.js'
15
- import { createMigration } from './createMigration.js'
16
- import { createVersion } from './createVersion.js'
17
- import { deleteMany } from './deleteMany.js'
18
- import { deleteOne } from './deleteOne.js'
19
- import { deleteVersions } from './deleteVersions.js'
20
- import { destroy } from './destroy.js'
21
- import { find } from './find.js'
22
- import { findGlobal } from './findGlobal.js'
23
- import { findGlobalVersions } from './findGlobalVersions.js'
24
- import { findOne } from './findOne.js'
25
- import { findVersions } from './findVersions.js'
26
- import { init } from './init.js'
27
- import { migrate } from './migrate.js'
28
- import { migrateDown } from './migrateDown.js'
29
- import { migrateFresh } from './migrateFresh.js'
30
- import { migrateRefresh } from './migrateRefresh.js'
31
- import { migrateReset } from './migrateReset.js'
32
- import { migrateStatus } from './migrateStatus.js'
33
- import { queryDrafts } from './queryDrafts.js'
34
- import { beginTransaction } from './transactions/beginTransaction.js'
35
- import { commitTransaction } from './transactions/commitTransaction.js'
36
- import { rollbackTransaction } from './transactions/rollbackTransaction.js'
37
- import { updateOne } from './update.js'
38
- import { updateGlobal } from './updateGlobal.js'
39
- import { updateGlobalVersion } from './updateGlobalVersion.js'
40
- import { updateVersion } from './updateVersion.js'
41
-
42
- export type { MigrateDownArgs, MigrateUpArgs } from './types.js'
43
-
44
- export { sql } from 'drizzle-orm'
45
-
46
- export function postgresAdapter(args: Args): DatabaseAdapterObj<PostgresAdapter> {
47
- const postgresIDType = args.idType || 'serial'
48
- const payloadIDType = postgresIDType ? 'number' : 'text'
49
-
50
- function adapter({ payload }: { payload: Payload }) {
51
- const migrationDir = findMigrationDir(args.migrationDir)
52
-
53
- return createDatabaseAdapter<PostgresAdapter>({
54
- name: 'postgres',
55
-
56
- // Postgres-specific
57
- blockTableNames: {},
58
- drizzle: undefined,
59
- enums: {},
60
- fieldConstraints: {},
61
- idType: postgresIDType,
62
- localesSuffix: args.localesSuffix || '_locales',
63
- logger: args.logger,
64
- pgSchema: undefined,
65
- pool: undefined,
66
- poolOptions: args.pool,
67
- push: args.push,
68
- relations: {},
69
- relationshipsSuffix: args.relationshipsSuffix || '_rels',
70
- schema: {},
71
- schemaName: args.schemaName,
72
- sessions: {},
73
- tables: {},
74
- versionsSuffix: args.versionsSuffix || '_v',
75
-
76
- // DatabaseAdapter
77
- beginTransaction,
78
- commitTransaction,
79
- connect,
80
- count,
81
- create,
82
- createGlobal,
83
- createGlobalVersion,
84
- createMigration,
85
- createVersion,
86
- defaultIDType: payloadIDType,
87
- deleteMany,
88
- deleteOne,
89
- deleteVersions,
90
- destroy,
91
- find,
92
- findGlobal,
93
- findGlobalVersions,
94
- findOne,
95
- findVersions,
96
- init,
97
- migrate,
98
- migrateDown,
99
- migrateFresh,
100
- migrateRefresh,
101
- migrateReset,
102
- migrateStatus,
103
- migrationDir,
104
- payload,
105
- queryDrafts,
106
- rollbackTransaction,
107
- updateGlobal,
108
- updateGlobalVersion,
109
- updateOne,
110
- updateVersion,
111
- })
112
- }
113
-
114
- return {
115
- defaultIDType: payloadIDType,
116
- init: adapter,
117
- }
118
- }
119
-
120
- /**
121
- * Attempt to find migrations directory.
122
- *
123
- * Checks for the following directories in order:
124
- * - `migrationDir` argument from Payload config
125
- * - `src/migrations`
126
- * - `dist/migrations`
127
- * - `migrations`
128
- *
129
- * Defaults to `src/migrations`
130
- *
131
- * @param migrationDir
132
- * @returns
133
- */
134
- function findMigrationDir(migrationDir?: string): string {
135
- const cwd = process.cwd()
136
- const srcDir = path.resolve(cwd, 'src/migrations')
137
- const distDir = path.resolve(cwd, 'dist/migrations')
138
- const relativeMigrations = path.resolve(cwd, 'migrations')
139
-
140
- // Use arg if provided
141
- if (migrationDir) return migrationDir
142
-
143
- // Check other common locations
144
- if (fs.existsSync(srcDir)) {
145
- return srcDir
146
- }
147
-
148
- if (fs.existsSync(distDir)) {
149
- return distDir
150
- }
151
-
152
- if (fs.existsSync(relativeMigrations)) {
153
- return relativeMigrations
154
- }
155
-
156
- return srcDir
157
- }