Performance: Database migrations
MEDIUM IMPACT
Database migrations affect the backend deployment speed and can indirectly impact frontend load times if migrations block API responses.
import { migrate } from 'some-migration-lib'; // Run migrations once during deployment or startup, not per request await migrate(); export async function getServerSideProps() { return { props: {} }; }
import { migrate } from 'some-migration-lib'; export async function getServerSideProps() { await migrate(); // runs migrations on every request return { props: {} }; }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Run migrations on every request | N/A | N/A | Blocks frontend rendering due to slow API | [X] Bad |
| Run migrations once during deployment | N/A | N/A | Fast API responses, smooth frontend rendering | [OK] Good |
| Run large migrations synchronously in API | N/A | N/A | Blocks API response, causes slow interaction | [X] Bad |
| Run large migrations asynchronously in background | N/A | N/A | Non-blocking API, fast user interaction | [OK] Good |