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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃彈 Migrated unsplash setting to up to date convention #12632

Merged
merged 4 commits into from
Feb 17, 2021

Conversation

naz
Copy link
Member

@naz naz commented Feb 10, 2021

splits #12615 into "slack" and "unsplash" parts
refs closes TryGhost/Team#331
refs #10318

Note to reviewers: the part that needs thorough review is the migration located in 10-refactor-unsplash-setting.js file. The rest is optional if you feel like having a look 馃槈

TODO:

  • handling for v2/v3/v4(canary) APIs
  • importer compatibility
  • clarify the Object return type in v4 api

Change/compatibility table for this PR:

importer

unsplash 鉁旓笍 import from both boolean AND object

canary/v4

GET /settings/ (browse)

unsplash 鉁旓笍 present in response with boolean value

GET /settings/:settingName (read)

unsplash 鉁旓笍 present in response with boolean value

PUT /settings/ (edit)

unsplash 鉁旓笍 updates setting, accepts a boolean

v3 Admin API

GET /settings/ (browse)

unsplash 鉁旓笍 present in response with Object value

GET /settings/:settingName (read)

unsplash 鉁旓笍 present in response with Object value

PUT /settings/ (edit)

unsplash 鉁旓笍 updates setting, accepts either boolean or object

v2 Admin API

GET /settings/ (browse)

unsplash 鉁旓笍 present in response with object value

GET /settings/:settingName (read)

unsplash 鉁旓笍 present in response with object value

PUT /settings/ (edit)

unsplash 鉁旓笍 updates setting, accepts object

@naz naz marked this pull request as ready for review February 12, 2021 08:36
@naz naz requested review from allouis and tpatel February 12, 2021 08:37
Copy link
Contributor

@tpatel tpatel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would either add irreversible: true in the config (that would require an update to the helper) or return Promise.reject(); in down() like in

return Promise.reject();

I think it's better than doing nothing so that we can't run this migration twice.

@naz naz requested a review from tpatel February 12, 2021 10:13
@naz
Copy link
Member Author

naz commented Feb 12, 2021

@tpatel good spot! Changed the migration 馃槈

Copy link
Contributor

@tpatel tpatel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome 馃檶

Copy link
Contributor

@allouis allouis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All looks good, only the comment about duplicate id's is essential

core/server/data/schema/default-settings.json Show resolved Hide resolved
core/server/data/importer/importers/data/settings.js Outdated Show resolved Hide resolved
core/server/data/importer/importers/data/settings.js Outdated Show resolved Hide resolved
core/server/data/importer/importers/data/settings.js Outdated Show resolved Hide resolved
@naz naz force-pushed the unsplash-setting-migration branch 3 times, most recently from cbbf6a8 to c9795c5 Compare February 15, 2021 03:30
@naz naz requested a review from allouis February 15, 2021 04:54
@naz naz force-pushed the unsplash-setting-migration branch from f0777d7 to 7cfb38c Compare February 15, 2021 05:34
@naz
Copy link
Member Author

naz commented Feb 17, 2021

@daniellockyer @tpatel @allouis I've updated the migration here to follow idempotence rule. The commit which fixes is is this one - 0bb7be3

Copy link
Contributor

@tpatel tpatel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The migration looks great 馃檶

refs TryGhost#10318

- JSON object format used in previous "unsplash" setting was considered an
anti-pattern. Flat structure was extracted out of the "unsplash.isActive" JSON.
- The naming convention uses `amp` as  a precedent (TryGhost/Product#331 (comment))
@naz naz force-pushed the unsplash-setting-migration branch from 0bb7be3 to 7298f70 Compare February 17, 2021 20:33
allouis and others added 2 commits February 18, 2021 09:36
refs TryGhost#10318

- API changes introduced:

canary/v4 Admin API
GET /settings/ (browse)

+ "unsplash" present in response as boolean value

GET /settings/:settingName (read)

+ "unsplash" present in response as boolean value

PUT /settings/ (edit)

+ "unsplash" updates setting, accepts ONLY  boolean format

v3  Admin API
GET /settings/ (browse)

+ "unsplash" present in response with object value

GET /settings/:settingName (read)

+ "unsplash" present in response with object value

PUT /settings/ (edit)

+ "unsplash" updates setting, accepts either boolean or object formats

v2 Admin API
GET /settings/ (browse)

+ "unsplash" present in response with object value

GET /settings/:settingName (read)

+ "unsplash" present in response with object value

PUT /settings/ (edit)

+ "unsplash" updates setting, accepts object format
no issue

- The migration didn't want to go away after rebases combined with renames
refs TryGhost#10318

- Previous version of migration was not following the idempotence rule of migrations
@naz naz force-pushed the unsplash-setting-migration branch from 7298f70 to 394d204 Compare February 17, 2021 20:36
@naz naz merged commit abb8c1d into TryGhost:main Feb 17, 2021
naz added a commit to TryGhost/Admin that referenced this pull request Feb 17, 2021
refs TryGhost/Ghost#12632

- The `unsplash` setting has been migrated to a new format - plain boolean value. This is why it's no longer needed to do any serialization dances
naz added a commit to TryGhost/Admin that referenced this pull request Feb 18, 2021
refs TryGhost/Ghost#12632

- The `unsplash` setting has been migrated to a new format - plain boolean value. This is why it's no longer needed to do any serialization dances
naz added a commit to TryGhost/Admin that referenced this pull request Feb 18, 2021
refs TryGhost/Ghost#12632

- The `unsplash` setting has been migrated to a new format - plain boolean value. This is why it's no longer needed to do any serialization dances
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.

None yet

4 participants