diff --git a/ghost/core/core/server/data/exporter/table-lists.js b/ghost/core/core/server/data/exporter/table-lists.js index 00af696410a..ddbb4e0ba67 100644 --- a/ghost/core/core/server/data/exporter/table-lists.js +++ b/ghost/core/core/server/data/exporter/table-lists.js @@ -58,7 +58,9 @@ const BACKUP_TABLES = [ 'recommendation_click_events', 'recommendation_subscribe_events', 'outbox', - 'gifts' + 'gifts', + 'welcome_email_automations', + 'welcome_email_automated_emails' ]; // NOTE: exposing only tables which are going to be included in a "default" export file diff --git a/ghost/core/core/server/data/migrations/versions/6.27/2026-04-06-14-27-21-add-welcome-email-automation-tables.js b/ghost/core/core/server/data/migrations/versions/6.27/2026-04-06-14-27-21-add-welcome-email-automation-tables.js new file mode 100644 index 00000000000..86db7b9821c --- /dev/null +++ b/ghost/core/core/server/data/migrations/versions/6.27/2026-04-06-14-27-21-add-welcome-email-automation-tables.js @@ -0,0 +1,30 @@ +const {addTable, combineNonTransactionalMigrations} = require('../../utils'); + +// The default names are too long. +const WELCOME_EMAIL_AUTOMATED_EMAILS_AUTOMATION_FK = 'weae_automation_id_foreign'; +const WELCOME_EMAIL_AUTOMATED_EMAILS_NEXT_EMAIL_FK = 'weae_next_email_id_foreign'; + +module.exports = combineNonTransactionalMigrations( + addTable('welcome_email_automations', { + id: {type: 'string', maxlength: 24, nullable: false, primary: true}, + status: {type: 'string', maxlength: 50, nullable: false, defaultTo: 'inactive', validations: {isIn: [['active', 'inactive']]}}, + name: {type: 'string', maxlength: 191, nullable: false, unique: true}, + slug: {type: 'string', maxlength: 191, nullable: false, unique: true}, + created_at: {type: 'dateTime', nullable: false}, + updated_at: {type: 'dateTime', nullable: true} + }), + addTable('welcome_email_automated_emails', { + id: {type: 'string', maxlength: 24, nullable: false, primary: true}, + welcome_email_automation_id: {type: 'string', maxlength: 24, nullable: false, references: 'welcome_email_automations.id', constraintName: WELCOME_EMAIL_AUTOMATED_EMAILS_AUTOMATION_FK, cascadeDelete: true}, + next_welcome_email_automated_email_id: {type: 'string', maxlength: 24, nullable: true, references: 'welcome_email_automated_emails.id', constraintName: WELCOME_EMAIL_AUTOMATED_EMAILS_NEXT_EMAIL_FK, cascadeDelete: false}, + delay_days: {type: 'integer', nullable: false, unsigned: true}, + subject: {type: 'string', maxlength: 300, nullable: false}, + lexical: {type: 'text', maxlength: 1000000000, fieldtype: 'long', nullable: true}, + sender_name: {type: 'string', maxlength: 191, nullable: true}, + sender_email: {type: 'string', maxlength: 191, nullable: true, validations: {isEmail: true}}, + sender_reply_to: {type: 'string', maxlength: 191, nullable: true, validations: {isEmail: true}}, + email_design_setting_id: {type: 'string', maxlength: 24, nullable: false, references: 'email_design_settings.id'}, + created_at: {type: 'dateTime', nullable: false}, + updated_at: {type: 'dateTime', nullable: true} + }) +); diff --git a/ghost/core/core/server/data/schema/schema.js b/ghost/core/core/server/data/schema/schema.js index aa88739d5e8..12623095ad8 100644 --- a/ghost/core/core/server/data/schema/schema.js +++ b/ghost/core/core/server/data/schema/schema.js @@ -1167,6 +1167,28 @@ module.exports = { created_at: {type: 'dateTime', nullable: false}, updated_at: {type: 'dateTime', nullable: true} }, + welcome_email_automations: { + id: {type: 'string', maxlength: 24, nullable: false, primary: true}, + status: {type: 'string', maxlength: 50, nullable: false, defaultTo: 'inactive', validations: {isIn: [['active', 'inactive']]}}, + name: {type: 'string', maxlength: 191, nullable: false, unique: true}, + slug: {type: 'string', maxlength: 191, nullable: false, unique: true}, + created_at: {type: 'dateTime', nullable: false}, + updated_at: {type: 'dateTime', nullable: true} + }, + welcome_email_automated_emails: { + id: {type: 'string', maxlength: 24, nullable: false, primary: true}, + welcome_email_automation_id: {type: 'string', maxlength: 24, nullable: false, references: 'welcome_email_automations.id', constraintName: 'weae_automation_id_foreign', cascadeDelete: true}, + next_welcome_email_automated_email_id: {type: 'string', maxlength: 24, nullable: true, references: 'welcome_email_automated_emails.id', constraintName: 'weae_next_email_id_foreign', cascadeDelete: false}, + delay_days: {type: 'integer', nullable: false, unsigned: true}, + subject: {type: 'string', maxlength: 300, nullable: false}, + lexical: {type: 'text', maxlength: 1000000000, fieldtype: 'long', nullable: true}, + sender_name: {type: 'string', maxlength: 191, nullable: true}, + sender_email: {type: 'string', maxlength: 191, nullable: true, validations: {isEmail: true}}, + sender_reply_to: {type: 'string', maxlength: 191, nullable: true, validations: {isEmail: true}}, + email_design_setting_id: {type: 'string', maxlength: 24, nullable: false, references: 'email_design_settings.id'}, + created_at: {type: 'dateTime', nullable: false}, + updated_at: {type: 'dateTime', nullable: true} + }, automated_emails: { id: {type: 'string', maxlength: 24, nullable: false, primary: true}, status: {type: 'string', maxlength: 50, nullable: false, defaultTo: 'inactive', validations: {isIn: [['active', 'inactive']]}}, diff --git a/ghost/core/test/integration/exporter/exporter.test.js b/ghost/core/test/integration/exporter/exporter.test.js index da134343d0c..e5de548ecc0 100644 --- a/ghost/core/test/integration/exporter/exporter.test.js +++ b/ghost/core/test/integration/exporter/exporter.test.js @@ -101,7 +101,9 @@ describe('Exporter', function () { 'tags', 'tokens', 'users', - 'webhooks' + 'webhooks', + 'welcome_email_automated_emails', + 'welcome_email_automations' ]; assertExists(exportData); diff --git a/ghost/core/test/unit/server/data/schema/integrity.test.js b/ghost/core/test/unit/server/data/schema/integrity.test.js index 9c4d3488ae9..ee9585f80a4 100644 --- a/ghost/core/test/unit/server/data/schema/integrity.test.js +++ b/ghost/core/test/unit/server/data/schema/integrity.test.js @@ -35,7 +35,7 @@ const validateRouteSettings = require('../../../../../core/server/services/route */ describe('DB version integrity', function () { // Only these variables should need updating - const currentSchemaHash = '6c63467aae47d05d9a67e695905f08d4'; + const currentSchemaHash = '5af830f163cc019b1d29188c68c96990'; const currentFixturesHash = '2f86ab1e3820e86465f9ad738dd0ee93'; const currentSettingsHash = 'a102b80d2ab0cd92325ed007c94d7da6'; const currentRoutesHash = '3d180d52c663d173a6be791ef411ed01';