chore: allows disabling of push

This commit is contained in:
James
2023-10-07 17:58:17 -04:00
parent 2f8d5dc628
commit 6c0eef3ec2
3 changed files with 10 additions and 1 deletions

View File

@@ -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(

View File

@@ -55,6 +55,7 @@ export function postgresAdapter(args: Args): PostgresAdapterResult {
enums: {},
pool: undefined,
poolOptions: args.pool,
push: args.push,
relations: {},
schema: {},
sessions: {},

View File

@@ -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: {