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

Can't get the right version when use migrations. #247

Open
Penggeor opened this issue Jan 10, 2023 · 2 comments
Open

Can't get the right version when use migrations. #247

Penggeor opened this issue Jan 10, 2023 · 2 comments

Comments

@Penggeor
Copy link

Penggeor commented Jan 10, 2023

I am encountering the same in #108 . The __internal__.migrations.version always is 8.1.01 from electron-store instead of my project. I have to resort to the workaround by add projectVersion to get the right version:

const store = new Store({
  projectVersion: app.getVersion(), 
  schema,
  beforeEachMigration: (store, context) => {
    console.log(
      `[main-config] migrate from ${context.fromVersion} → ${context.toVersion}`,
    )
  },
  migrations: {
    '<1.2.2': (store) => {
      console.log('[<1.2.2]')
    },
    '>=1.2.2': (store) => {
      // ...
    },
    '>=1.2.3': (store) => {
      console.log('[>=1.2.3]')
    },
  },
})
@sindresorhus
Copy link
Owner

Try logging what appVersion is here:

options.projectVersion = appVersion;

And make sure you are calling initRenderer() if required. See readme.

@Penggeor
Copy link
Author

Penggeor commented Feb 6, 2023

I found another problem, the config.json stores in ~/Library/Preferences/electron-store-nodejs/config.json @sindresorhus

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