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 521d5455_26a9_bc18_fbf7_9649e730267e["useMigrations()"] 0e92b232_8d9a_aa9d_3673_15b989e5e855["migrator.ts"] 521d5455_26a9_bc18_fbf7_9649e730267e -->|defined in| 0e92b232_8d9a_aa9d_3673_15b989e5e855 0f158df0_ad98_5b1b_6efc_788f1c0477cf["migrate()"] 521d5455_26a9_bc18_fbf7_9649e730267e -->|calls| 0f158df0_ad98_5b1b_6efc_788f1c0477cf style 521d5455_26a9_bc18_fbf7_9649e730267e fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
drizzle-orm/src/expo-sqlite/migrator.ts lines 59–99
export const useMigrations = (db: ExpoSQLiteDatabase<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 as any).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/expo-sqlite/migrator.ts.
Where is useMigrations() defined?
useMigrations() is defined in drizzle-orm/src/expo-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