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

Don't populate settings defaults twice on startup #7121

Merged

Conversation

acburdine
Copy link
Member

@acburdine acburdine commented Jul 22, 2016

Slight regression that throws an error whenever a new setting is added. (only on the first boot of the blog, doesn't happen after that).

To reproduce the error (without this PR):

  1. Clear the SQLite DB
  2. Checkout commit 77464c5
  3. Start & setup blog
  4. Checkout master
  5. Start blog and see a SQLite constraint error

With these changes that doesn't happen.

@ErisDS
Copy link
Member

ErisDS commented Jul 22, 2016

This change causes the default settings to only be populated if there's a migration, and not in every other case?

@ErisDS
Copy link
Member

ErisDS commented Jul 22, 2016

Wait no, the way the code was collapsed was super confusing.

@acburdine
Copy link
Member Author

So this is good?

@acburdine
Copy link
Member Author

Oops, seems to be a bit of a test bug 😛

@kirrg001
Copy link
Contributor

i don't think this fix solves the underlying problem.
the populateDefaults fn tries to insert in this case the new property seenNotifications, because require('../data/schema/').defaultSettings discovers "oh yeah there is a new default setting to insert". In my opinion we should extend error handling to ensure: if we insert a key, which already exists in the database settings table, we could either update the key or ignore the error

@acburdine
Copy link
Member Author

Fair enough. I feel like removing the first settings populate call is still necessary though.

@kirrg001
Copy link
Contributor

kirrg001 commented Jul 22, 2016

i think we need the call, because migrations.update happens in parallel.
So it does

  1. getDatabaseVersion
  2. calls migrations.update (parallel, there is no return)
  3. but jumps directly to populate the settings, because the blog should already start

@acburdine acburdine closed this Jul 22, 2016
@acburdine acburdine deleted the dont-populate-settings-twice branch July 22, 2016 14:58
@acburdine acburdine restored the dont-populate-settings-twice branch July 22, 2016 17:23
@kevinansfield kevinansfield reopened this Jul 22, 2016
@kevinansfield
Copy link
Contributor

@acburdine it seems there's a test failure with the re-created branch 😞

@acburdine acburdine force-pushed the dont-populate-settings-twice branch from 5fdaf0f to cc3f0cc Compare July 22, 2016 18:28
@acburdine
Copy link
Member Author

@kevinansfield fixed it

@kevinansfield kevinansfield merged commit 218bc06 into TryGhost:master Jul 22, 2016
@acburdine acburdine deleted the dont-populate-settings-twice branch July 22, 2016 19:06
chris-brown pushed a commit to chris-brown/Ghost that referenced this pull request Aug 14, 2016
geekhuyang pushed a commit to geekhuyang/Ghost that referenced this pull request Nov 20, 2016
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

Successfully merging this pull request may close these issues.

4 participants