0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00
ghost/core/server
Kevin Ansfield f45198245f Updated Settings.populateDefaults() to account for available columns
refs https://github.com/TryGhost/Ghost/issues/10318

`Settings.populateDefaults()` is run before migrations during Ghost's startup. This can cause problems when new settings table columns are added (and populated in `default-settings.json`) because `populateDefaults()` was using the model layer which assumes that those columns are available, resulting in `ER_BAD_FIELD_ERROR: Unknown column` type errors.

- query the database for the available `settings` table columns
- switch to using raw knex queries without Bookshelf for insertions so that we're in control of the columns that are added
- use `_.pick` to skip any properties in `default-settings.json` that do not match to an available column - those columns will be added and populated by later migrations
- moving away from using the model to insert settings has the side-effect of not emitting `settings.added/edited` and `settings.x.added/edited` events, this should be fine because `populateDefaults()` is called before anything else is set up and listening
- added a call to `populateDefaults()` in our knex-migrator "before migration" hook so that we have consistent db state across both startup initialised migrations and manually triggered knex migrations
2020-06-29 13:22:10 +00:00
..
adapters
api Fixed grouping error in members CSV importer 2020-06-30 00:22:52 +12:00
data Updated Settings.populateDefaults() to account for available columns 2020-06-29 13:22:10 +00:00
lib Fixed populateImageSizes handling of images in subdir setups 2020-06-23 12:47:20 +01:00
models Updated Settings.populateDefaults() to account for available columns 2020-06-29 13:22:10 +00:00
public
services Renamed settings key brand.primaryColor to accent_color 2020-06-24 14:18:13 +12:00
translations Fixed grouping error in members CSV importer 2020-06-30 00:22:52 +12:00
views
web Added API endpoints for disconnecting Stripe 2020-06-18 18:42:20 +02:00
analytics-events.js
ghost-server.js
index.js
overrides.js
update-check.js