Skip to content

autoMigrate cause infinite loop in electron app #212

Closed
@jonymei

Description

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.

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