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

[Question] Migrate Data on Version Upgrade #23

Open
scottkuhl opened this issue Feb 9, 2024 · 0 comments
Open

[Question] Migrate Data on Version Upgrade #23

scottkuhl opened this issue Feb 9, 2024 · 0 comments

Comments

@scottkuhl
Copy link

Simply changing the version number and updating some values seems to work well. For example, incrementing the version number and adding Indexes to the store schema seems to have added them without any data loss.

But how to you add a more complex migration?

For instance, here is the example from the dexie docs:

db.version(1).stores({
    friends: 'id, name, age'
});
db.version(2).stores({
    friends: 'id, name, firstName, lastName',
}).upgrade(tx => {
    return tx.table("friends").toCollection().modify(friend => {
        const names = friend.name.split(' ');
        friend.firstName = names.shift();
        friend.lastName = names.join(' ');
        delete friend.name;
    });
});

How would you replicate this using this BlazorDB library?

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

No branches or pull requests

1 participant