import type { BasePostgresAdapter, GenericEnum, MigrateDownArgs, MigrateUpArgs, PostgresSchemaHook } from '@payloadcms/drizzle/postgres'; import type { DrizzleAdapter } from '@payloadcms/drizzle/types'; import type { DrizzleConfig } from 'drizzle-orm'; import type { NodePgDatabase } from 'drizzle-orm/node-postgres'; import type { PgSchema, PgTableFn, PgTransactionConfig, PgWithReplicas } from 'drizzle-orm/pg-core'; import type { Pool, PoolConfig } from 'pg'; type PgDependency = typeof import('pg'); export type Args = { /** * Transform the schema after it's built. * You can use it to customize the schema with features that aren't supported by Payload. * Examples may include: composite indices, generated columns, vectors */ afterSchemaInit?: PostgresSchemaHook[]; /** * Enable this flag if you want to thread your own ID to create operation data, for example: * ```ts * // doc created with id 1 * const doc = await payload.create({ collection: 'posts', data: {id: 1, title: "my title"}}) * ``` */ allowIDOnCreate?: boolean; /** * Transform the schema before it's built. * You can use it to preserve an existing database schema and if there are any collissions Payload will override them. * To generate Drizzle schema from the database, see [Drizzle Kit introspection](https://orm.drizzle.team/kit-docs/commands#introspect--pull) */ beforeSchemaInit?: PostgresSchemaHook[]; /** * Store blocks as JSON column instead of storing them in relational structure. */ blocksAsJSON?: boolean; /** * Pass `true` to disale auto database creation if it doesn't exist. * @default false */ disableCreateDatabase?: boolean; extensions?: string[]; /** Generated schema from payload generate:db-schema file path */ generateSchemaOutputFile?: string; idType?: 'serial' | 'uuid'; localesSuffix?: string; logger?: DrizzleConfig['logger']; migrationDir?: string; pg?: PgDependency; pool: PoolConfig; prodMigrations?: { down: (args: MigrateDownArgs) => Promise; name: string; up: (args: MigrateUpArgs) => Promise; }[]; push?: boolean; readReplicas?: string[]; /** * How long (ms) after a write to keep routing reads to the primary instead * of a read replica. Prevents stale reads caused by replication lag. * Only relevant when `readReplicas` is set. * @default 2000 */ readReplicasAfterWriteInterval?: number; relationshipsSuffix?: string; /** * The schema name to use for the database * * @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. */ schemaName?: string; tablesFilter?: string[]; transactionOptions?: false | PgTransactionConfig; versionsSuffix?: string; }; export interface GeneratedDatabaseSchema { schemaUntyped: Record; } type ResolveSchemaType = 'schema' extends keyof T ? T['schema'] : GeneratedDatabaseSchema['schemaUntyped']; type Drizzle = NodePgDatabase> | PgWithReplicas>>; export type PostgresAdapter = { drizzle: Drizzle; pg: PgDependency; pool: Pool; poolOptions: PoolConfig; } & BasePostgresAdapter; declare module 'payload' { interface DatabaseAdapter extends Omit, DrizzleAdapter { afterSchemaInit: PostgresSchemaHook[]; beforeSchemaInit: PostgresSchemaHook[]; beginTransaction: (options?: PgTransactionConfig) => Promise; drizzle: Drizzle; enums: Record; extensions: Record; /** * 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 * Used for returning properly formed errors from unique fields */ fieldConstraints: Record>; idType: Args['idType']; initializing: Promise; localesSuffix?: string; logger: DrizzleConfig['logger']; /** Optionally inject your own node-postgres. This is required if you wish to instrument the driver with @payloadcms/plugin-sentry. */ pg?: PgDependency; pgSchema?: { table: PgTableFn; } | PgSchema; pool: Pool; poolOptions: Args['pool']; prodMigrations?: { down: (args: MigrateDownArgs) => Promise; name: string; up: (args: MigrateUpArgs) => Promise; }[]; push: boolean; rejectInitializing: () => void; relationshipsSuffix?: string; resolveInitializing: () => void; schema: Record; schemaName?: Args['schemaName']; tableNameMap: Map; tablesFilter?: string[]; versionsSuffix?: string; } } export {}; //# sourceMappingURL=types.d.ts.map