Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable createMigrate to handle async migrations #866 #1219

Closed
wants to merge 1 commit into from

Conversation

retyui
Copy link

@retyui retyui commented Jul 1, 2020

via: #806

const migrations = {
  0: (state) => {
    // migration clear out device state
    return {
      ...state,
      device: undefined   
    }
  },
  // You can use also `async () => {}` function
  // For example to move users to other storage
  1: async ({ users, ...state }) => {
    try {
      await insertToOtherStorage(users)

      return state
    } catch (e) {
      // Don't forget about exceptions
      return state
    }
  },
  2: (state) => {
    // migration to keep only device state
    return {
      device: state.device
    }
  }
}

@AlimovSV
Copy link

Any progress?

@retyui
Copy link
Author

retyui commented May 31, 2022

cc @ckalika

@retyui retyui closed this Nov 20, 2022
@retyui retyui deleted the async-migrations branch November 20, 2022 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants