Function: useSchemaMigration()
useSchemaMigration():
UseMutationResult<MigrationSuccess,SchemaMigrationError,MigrateRecordParams,unknown>
Defined in: web/lib/hooks/use-schema-migration.ts:161
Hook for migrating eprint records to the current schema.
Returns
UseMutationResult<MigrationSuccess, SchemaMigrationError, MigrateRecordParams, unknown>
Mutation object with migrateRecord, loading state, and error
Remarks
This hook handles the complete migration flow:
- Validates the user is authenticated
- Fetches the current record from the PDS
- Transforms deprecated fields using schema migration utilities
- Updates the record in the PDS via
putRecord - Invalidates relevant queries to refresh the UI
The mutation requires the user to be the record owner (same DID).
Example
const { mutate: migrateRecord, isPending, error, isSuccess } = useSchemaMigration();
const handleMigrate = async () => {
try {
await migrateRecord({ uri: eprint.uri });
toast.success('Record updated to latest format');
} catch (error) {
toast.error('Failed to update record');
}
};
return (
<Button onClick={handleMigrate} disabled={isPending}>
{isPending ? 'Updating...' : 'Update to Latest Format'}
</Button>
);