fix: migrate error on windows (#7759)

handle windows compatible file names when reading migrations

---------

Co-authored-by: Alessio Gravili <alessio@gravili.de>
This commit is contained in:
Dan Ribbens
2024-08-19 15:46:40 -04:00
committed by GitHub
parent ab09f2aff5
commit bb09da08c2
2 changed files with 8 additions and 9 deletions

View File

@@ -121,24 +121,21 @@ describe('database', () => {
})
describe('migrations', () => {
beforeAll(async () => {
beforeEach(async () => {
if (process.env.PAYLOAD_DROP_DATABASE === 'true' && 'drizzle' in payload.db) {
const db = payload.db as unknown as PostgresAdapter
await db.dropDatabase({ adapter: db })
}
})
afterAll(() => {
removeFiles(path.join(dirname, './migrations'))
})
it('should run migrate:create', async () => {
await payload.db.createMigration({
forceAcceptWarning: true,
migrationName: 'test',
payload,
})
})
it('should run migrate:create', () => {
// read files names in migrationsDir
const migrationFile = path.normalize(fs.readdirSync(payload.db.migrationDir)[0])
expect(migrationFile).toContain('_test')