-
-
Notifications
You must be signed in to change notification settings - Fork 11.5k
Created dormant automation runs table #27190
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
EvanHahn
wants to merge
5
commits into
main
Choose a base branch
from
NY-1189
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
fd1320b
Added dormant automation runs table
EvanHahn 1e82071
Merge branch 'main' into NY-1189
EvanHahn c062e2a
Merge branch 'main' into NY-1189
EvanHahn cff0b8a
Added index on `ready_at`
EvanHahn aebc379
Merge branch 'main' into NY-1189
EvanHahn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
...a/migrations/versions/6.28/2026-04-08-13-21-16-add-welcome-email-automation-runs-table.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| const {addTable} = require('../../utils'); | ||
|
|
||
| // The default names are too long for MySQL. | ||
| const WELCOME_EMAIL_AUTOMATION_RUNS_AUTOMATION_FK = 'wear_automation_id_foreign'; | ||
| const WELCOME_EMAIL_AUTOMATION_RUNS_MEMBER_FK = 'wear_member_id_foreign'; | ||
| const WELCOME_EMAIL_AUTOMATION_RUNS_NEXT_EMAIL_FK = 'wear_next_email_id_foreign'; | ||
|
|
||
| const welcomeEmailAutomationRunsSpec = { | ||
| 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_AUTOMATION_RUNS_AUTOMATION_FK, cascadeDelete: true}, | ||
| member_id: {type: 'string', maxlength: 24, nullable: false, references: 'members.id', constraintName: WELCOME_EMAIL_AUTOMATION_RUNS_MEMBER_FK, cascadeDelete: true}, | ||
| next_welcome_email_automated_email_id: {type: 'string', maxlength: 24, nullable: true, references: 'welcome_email_automated_emails.id', constraintName: WELCOME_EMAIL_AUTOMATION_RUNS_NEXT_EMAIL_FK, cascadeDelete: false}, | ||
| ready_at: {type: 'dateTime', nullable: true}, | ||
| step_started_at: {type: 'dateTime', nullable: true}, | ||
| step_attempts: {type: 'integer', unsigned: true, nullable: false, defaultTo: 0}, | ||
| exit_reason: {type: 'string', maxlength: 50, nullable: true, validations: {isIn: [['member not found', 'email send failed', 'member unsubscribed', 'member changed status', 'finished']]}}, | ||
| created_at: {type: 'dateTime', nullable: false}, | ||
| updated_at: {type: 'dateTime', nullable: true} | ||
| }; | ||
|
|
||
| module.exports = addTable('welcome_email_automation_runs', welcomeEmailAutomationRunsSpec); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
ghost/core/core/server/models/welcome-email-automation-run.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| const ghostBookshelf = require('./base'); | ||
|
|
||
| const WelcomeEmailAutomationRun = ghostBookshelf.Model.extend({ | ||
| tableName: 'welcome_email_automation_runs', | ||
|
|
||
| defaults() { | ||
| return { | ||
| stepAttempts: 0 | ||
| }; | ||
| }, | ||
|
|
||
| welcomeEmailAutomation() { | ||
| return this.belongsTo('WelcomeEmailAutomation', 'welcome_email_automation_id', 'id'); | ||
| }, | ||
|
|
||
| member() { | ||
| return this.belongsTo('Member', 'member_id', 'id'); | ||
| }, | ||
|
|
||
| nextWelcomeEmailAutomatedEmail() { | ||
| return this.belongsTo('WelcomeEmailAutomatedEmail', 'next_welcome_email_automated_email_id', 'id'); | ||
| } | ||
| }); | ||
|
|
||
| module.exports = { | ||
| WelcomeEmailAutomationRun: ghostBookshelf.model('WelcomeEmailAutomationRun', WelcomeEmailAutomationRun) | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
ghost/core/test/unit/server/models/welcome-email-automation-run.test.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| const assert = require('node:assert/strict'); | ||
| const models = require('../../../../core/server/models'); | ||
|
|
||
| describe('Unit: models/welcome-email-automation-run', function () { | ||
| before(function () { | ||
| models.init(); | ||
| }); | ||
|
|
||
| describe('tableName', function () { | ||
| it('uses the correct table name', function () { | ||
| const model = new models.WelcomeEmailAutomationRun(); | ||
| assert.equal(model.tableName, 'welcome_email_automation_runs'); | ||
| }); | ||
| }); | ||
|
|
||
| describe('defaults', function () { | ||
| it('sets stepAttempts to 0', function () { | ||
| const model = new models.WelcomeEmailAutomationRun(); | ||
| const defaults = model.defaults(); | ||
| assert.equal(defaults.stepAttempts, 0); | ||
| }); | ||
|
|
||
| it('returns only stepAttempts as a default', function () { | ||
| const model = new models.WelcomeEmailAutomationRun(); | ||
| const defaults = model.defaults(); | ||
| assert.deepEqual(Object.keys(defaults), ['stepAttempts']); | ||
| }); | ||
| }); | ||
|
|
||
| describe('relationships', function () { | ||
| it('has a welcomeEmailAutomation relationship', function () { | ||
| const model = new models.WelcomeEmailAutomationRun(); | ||
| assert.equal(typeof model.welcomeEmailAutomation, 'function'); | ||
| }); | ||
|
|
||
| it('has a member relationship', function () { | ||
| const model = new models.WelcomeEmailAutomationRun(); | ||
| assert.equal(typeof model.member, 'function'); | ||
| }); | ||
|
|
||
| it('has a nextWelcomeEmailAutomatedEmail relationship', function () { | ||
| const model = new models.WelcomeEmailAutomationRun(); | ||
| assert.equal(typeof model.nextWelcomeEmailAutomatedEmail, 'function'); | ||
| }); | ||
| }); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.