0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-17 23:44:39 -05:00
ghost/test/unit
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 Moved core/server/lib/url-utils to core/shared/url-utils (#11856) 2020-05-28 11:57:02 +01:00
api Added back compatible support for renamed settings types 2020-06-25 00:55:40 +12:00
apps 🐛 Fixed private blogging exposing 404 and robots (#11922) 2020-06-16 11:42:32 +01:00
data Added migration utils for permissions 2020-06-25 19:15:25 +02:00
helpers Renamed settings keys from default_locale to lang 2020-06-24 14:07:24 +12:00
lib Un-skipped populateImageSizes subdir test 2020-06-23 15:54:58 +01:00
models Updated Settings.populateDefaults() to account for available columns 2020-06-29 13:22:10 +00:00
services Renamed settings keys active_timezone to timezone 2020-06-24 14:11:20 +12:00
shared/config Updated tests locations and added linting of core/shared (#11872) 2020-06-01 22:06:50 +01:00
web Moved core/server/lib/common/logging to core/shared/logging (#11857) 2020-05-28 19:30:23 +01:00