Skip to content

Commit fa3d250

Browse files
authored
feat: indent migration sql (#7475)
Properly indent migration sql
1 parent 4b2a9f7 commit fa3d250

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed
Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
import type { MigrationTemplateArgs } from 'payload'
22

3+
export const indent = (text: string) =>
4+
text
5+
.split('\n')
6+
.map((line) => ` ${line}`)
7+
.join('\n')
8+
39
export const getMigrationTemplate = ({
410
downSQL,
511
imports,
612
upSQL,
713
}: MigrationTemplateArgs): string => `import { MigrateUpArgs, MigrateDownArgs, sql } from '@payloadcms/db-postgres'
814
${imports ? `${imports}\n` : ''}
915
export async function up({ payload, req }: MigrateUpArgs): Promise<void> {
10-
${upSQL}
16+
${indent(upSQL)}
1117
}
1218
1319
export async function down({ payload, req }: MigrateDownArgs): Promise<void> {
14-
${downSQL}
20+
${indent(downSQL)}
1521
}
1622
`
Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
import type { MigrationTemplateArgs } from 'payload'
22

3+
export const indent = (text: string) =>
4+
text
5+
.split('\n')
6+
.map((line) => ` ${line}`)
7+
.join('\n')
8+
39
export const getMigrationTemplate = ({
410
downSQL,
511
imports,
612
upSQL,
713
}: MigrationTemplateArgs): string => `import { MigrateUpArgs, MigrateDownArgs, sql } from '@payloadcms/db-sqlite'
814
${imports ? `${imports}\n` : ''}
915
export async function up({ payload, req }: MigrateUpArgs): Promise<void> {
10-
${upSQL}
16+
${indent(upSQL)}
1117
}
1218
1319
export async function down({ payload, req }: MigrateDownArgs): Promise<void> {
14-
${downSQL}
20+
${indent(downSQL)}
1521
}
1622
`

0 commit comments

Comments
 (0)