useMigrations() — drizzle-orm Function Reference
Architecture documentation for the useMigrations() function in migrator.ts from the drizzle-orm codebase.
Entity Profile
Dependency Diagram
graph TD e2806702_d7b1_7ed8_187b_8b73e80e8c0b["useMigrations()"] 7d4ff80f_0ea3_5189_875c_e681d73995cd["migrator.ts"] e2806702_d7b1_7ed8_187b_8b73e80e8c0b -->|defined in| 7d4ff80f_0ea3_5189_875c_e681d73995cd 0539c249_2af2_9651_a840_2b54f8869212["migrate()"] e2806702_d7b1_7ed8_187b_8b73e80e8c0b -->|calls| 0539c249_2af2_9651_a840_2b54f8869212 style e2806702_d7b1_7ed8_187b_8b73e80e8c0b fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
drizzle-orm/src/op-sqlite/migrator.ts lines 59–99
export const useMigrations = (db: OPSQLiteDatabase<any>, migrations: {
journal: {
entries: { idx: number; when: number; tag: string; breakpoints: boolean }[];
};
migrations: Record<string, string>;
}): State => {
const initialState: State = {
success: false,
error: undefined,
};
const fetchReducer = (state: State, action: Action): State => {
switch (action.type) {
case 'migrating': {
return { ...initialState };
}
case 'migrated': {
return { ...initialState, success: action.payload };
}
case 'error': {
return { ...initialState, error: action.payload };
}
default: {
return state;
}
}
};
const [state, dispatch] = useReducer(fetchReducer, initialState);
useEffect(() => {
dispatch({ type: 'migrating' });
migrate(db, migrations).then(() => {
dispatch({ type: 'migrated', payload: true });
}).catch((error) => {
dispatch({ type: 'error', payload: error as Error });
});
}, []);
return state;
};
Domain
Subdomains
Defined In
Calls
Source
Frequently Asked Questions
What does useMigrations() do?
useMigrations() is a function in the drizzle-orm codebase, defined in drizzle-orm/src/op-sqlite/migrator.ts.
Where is useMigrations() defined?
useMigrations() is defined in drizzle-orm/src/op-sqlite/migrator.ts at line 59.
What does useMigrations() call?
useMigrations() calls 1 function(s): migrate.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free