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

autoMigrate cause infinite loop in electron app #212

Closed
jonymei opened this issue Jul 2, 2017 · 3 comments
Closed

autoMigrate cause infinite loop in electron app #212

jonymei opened this issue Jul 2, 2017 · 3 comments

Comments

@jonymei
Copy link

jonymei commented Jul 2, 2017

old schema(without title filed):

const notesSchema = {
    version: 0,
    title: 'naotes schema',
    description: 'descript a note',
    type: 'object',
    properties: {
        id : {
            type: 'string',
            primary: true
        },
        content: {
            type: 'string'
        }
    },
    required: ['content']
}

new schema:

const notesSchema = {
    version: 1,
    title: 'naotes schema',
    description: 'descript a note',
    type: 'object',
    properties: {
        id : {
            type: 'string',
            primary: true
        },
        content: {
            type: 'string'
        },
        title: {
            type: 'string'
        }
    },
    required: ['content']
}

create collection:

db.collection({
    name: 'notes',
    schema: notesSchema,
    migrationStrategies: {
        1: (oldDoc) => {
            console.log('migrate from 0 to 1...' + oldDoc.id)
            oldDoc.title = 'test title'
            return oldDoc
        }
    }
})

run app and log will be print all the time.

@pubkey
Copy link
Owner

pubkey commented Jul 3, 2017

Hi @ahumeijun I tried to reproduce this but couldnt. Can you fork this repo and reproduce the problem in the electron-example?

jonymei added a commit to jonymei/rxdb that referenced this issue Jul 4, 2017
@jonymei
Copy link
Author

jonymei commented Jul 4, 2017

thanks for your reply.
I had reproduced this bug on my repo. But I got an error Uncaught Error: Cannot find module 'babel-runtime/helpers/typeof' when I run the eletron app use command npm start. So I use rxdb module instead of source code. Is this the cause of the bug?
my repo: rxdb

@pubkey pubkey closed this as completed in 61e75f3 Jul 4, 2017
@pubkey
Copy link
Owner

pubkey commented Jul 4, 2017

@ahumeijun thank you for sharing your repo. This helped a lot.
The problem was that the primary-key was not translated back, when the migrated document got deleted from the old pouchdb-instance.

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

2 participants