From 4994e2783863c450870dcf3befc52e45eecb455f Mon Sep 17 00:00:00 2001 From: Daniel Lockyer Date: Mon, 17 Jan 2022 17:50:19 +0000 Subject: [PATCH] Refined database warning message to reflect specific versions refs https://github.com/TryGhost/Toolbox/issues/175 refs https://github.com/TryGhost/Admin/commit/c4083967dfd1863473b4f39fd0b5a21f7e4b99ad - the referenced commit added a warning message to the What's New page to notify the user that we're going to be requiring MySQL 8 in production as of v5 - this would also show if the user was already using MySQL 8, which isn't ideal - I've added a library to Ghost which will return the specific version of MySQL used, so we can now detect that - https://github.com/TryGhost/Ghost/commit/eb68e8d339ae447eafd9aa48d957a607252f7e4f has updated the config endpoint to return `mysql5`, `mysql8` etc, so we can now change the logic here to reflect that - this commit also adds another warning if we're in development mode and using mysql5, as this will not be supported as of v5 --- ghost/admin/app/controllers/whatsnew.js | 13 ++++++++++--- ghost/admin/app/templates/whatsnew.hbs | 4 ++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/ghost/admin/app/controllers/whatsnew.js b/ghost/admin/app/controllers/whatsnew.js index 11c94a1576..9f1fb4d5b5 100644 --- a/ghost/admin/app/controllers/whatsnew.js +++ b/ghost/admin/app/controllers/whatsnew.js @@ -13,12 +13,19 @@ export default class WhatsNewController extends Controller { return date.getFullYear(); } - get showDatabaseWarning() { + get databaseWarning() { const isProduction = !!this.config.get('environment').match?.(/production/i); const isPro = !!this.config.get('hostSettings')?.siteId; + const database = this.config.get('database'); - if (isProduction && !isPro) { - return true; + // Show a warning if we're in production and not using MySQL 8 + if (isProduction && !isPro && database !== 'mysql8') { + return 'MySQL 8 will be the required database in the next major release of Ghost.'; + } + + // Show a warning if we're in development and using MySQL 5 + if (!isProduction && !isPro && database === 'mysql5') { + return 'MySQL 5 will no longer be supported in the next major release of Ghost.'; } return false; diff --git a/ghost/admin/app/templates/whatsnew.hbs b/ghost/admin/app/templates/whatsnew.hbs index 7494d38b3f..b2897b5a71 100644 --- a/ghost/admin/app/templates/whatsnew.hbs +++ b/ghost/admin/app/templates/whatsnew.hbs @@ -59,10 +59,10 @@ {{/if}} - {{#if this.showDatabaseWarning}} + {{#if this.databaseWarning}}

- Warning: MySQL 8 will be the required database in the next major release of Ghost. Make sure your database is up to date to ensure forwards compatibility. + Warning: {{this.databaseWarning}} Make sure your database is up to date to ensure forwards compatibility.

{{/if}}