chore: allows disabling of push
This commit is contained in:
@@ -33,7 +33,12 @@ export const connect: Connect = async function connect(this: PostgresAdapter, pa
|
||||
}
|
||||
|
||||
// Only push schema if not in production
|
||||
if (process.env.NODE_ENV === 'production' || process.env.PAYLOAD_MIGRATING === 'true') return
|
||||
if (
|
||||
process.env.NODE_ENV === 'production' ||
|
||||
process.env.PAYLOAD_MIGRATING === 'true' ||
|
||||
this.push === false
|
||||
)
|
||||
return
|
||||
|
||||
// This will prompt if clarifications are needed for Drizzle to push new schema
|
||||
const { apply, hasDataLoss, statementsToExecute, warnings } = await pushSchema(
|
||||
|
||||
@@ -55,6 +55,7 @@ export function postgresAdapter(args: Args): PostgresAdapterResult {
|
||||
enums: {},
|
||||
pool: undefined,
|
||||
poolOptions: args.pool,
|
||||
push: args.push,
|
||||
relations: {},
|
||||
schema: {},
|
||||
sessions: {},
|
||||
|
||||
@@ -16,6 +16,7 @@ export type DrizzleDB = NodePgDatabase<Record<string, unknown>>
|
||||
export type Args = {
|
||||
migrationDir?: string
|
||||
pool: PoolConfig
|
||||
push?: boolean
|
||||
}
|
||||
|
||||
export type GenericColumn = PgColumn<
|
||||
@@ -49,6 +50,7 @@ export type PostgresAdapter = BaseDatabaseAdapter & {
|
||||
enums: Record<string, GenericEnum>
|
||||
pool: Pool
|
||||
poolOptions: Args['pool']
|
||||
push: boolean
|
||||
relations: Record<string, GenericRelation>
|
||||
schema: Record<string, GenericEnum | GenericRelation | GenericTable>
|
||||
sessions: {
|
||||
@@ -71,6 +73,7 @@ declare module 'payload' {
|
||||
drizzle: DrizzleDB
|
||||
enums: Record<string, GenericEnum>
|
||||
pool: Pool
|
||||
push: boolean
|
||||
relations: Record<string, GenericRelation>
|
||||
schema: Record<string, GenericEnum | GenericRelation | GenericTable>
|
||||
sessions: {
|
||||
|
||||
Reference in New Issue
Block a user