/
githubmirror
/
strapi
Обзор
Документация
Войти
/
githubmirror
/
strapi
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
packages/core/database/src/migrations/index.ts
40 строк
1 KB
Marc Roig
feat: migrate document published entries from v4 (#19813)
17 апр 2024, 14:41
Не верифицирован
17 апр 2024, 14:41
7644729
Код
Авторство
О чём код?
import { createUserMigrationProvider } from './users'; import { createInternalMigrationProvider } from './internal'; import type { MigrationProvider, Migration } from './common'; import type { Database } from '..'; export type { MigrationProvider, Migration }; export const createMigrationsProvider = (db: Database): MigrationProvider => { const userProvider = createUserMigrationProvider(db); const internalProvider = createInternalMigrationProvider(db); const providers = [userProvider, internalProvider]; return { providers: { internal: internalProvider, }, async shouldRun() { const shouldRunResponses = await Promise.all( providers.map((provider) => provider.shouldRun()) ); return shouldRunResponses.some((shouldRun) => shouldRun); }, async up() { for (const provider of providers) { if (await provider.shouldRun()) { await provider.up(); } } }, async down() { for (const provider of providers) { if (await provider.shouldRun()) { await provider.down(); } } }, }; };