Skip to content

[Question] Migrate Data on Version Upgrade #23

@scottkuhl

Description

@scottkuhl

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions