Skip to content

Added newsletters.button_style column #23322

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

Merged
merged 1 commit into from
May 14, 2025

Conversation

kevinansfield
Copy link
Member

ref https://linear.app/ghost/issue/PROD-1717

  • added newsletters.button_style column ready for controlling button styles in emails, with two options of fill (default, current production design) and outline which is a new option

ref https://linear.app/ghost/issue/PROD-1717

- added `newsletters.button_style` column ready for controlling button styles in emails, with two options of `fill` (default, current production design) and `outline` which is a new option
Copy link
Contributor

coderabbitai bot commented May 13, 2025

Walkthrough

A new migration script has been added to introduce a button_style column to the newsletters table. This column is a non-nullable string with a maximum length of 50 characters, a default value of 'fill', and a validation constraint allowing only the values 'fill' or 'outline'. The schema definition for the newsletters table and the Newsletter model's default attributes have been updated accordingly. Additionally, the schema integrity test's expected hash has been updated to reflect these schema changes.

Suggested labels

migration

Suggested reviewers

  • lsinger

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 901bded and 826241b.

⛔ Files ignored due to path filters (2)
  • ghost/core/test/e2e-api/admin/__snapshots__/members.test.js.snap is excluded by !**/*.snap
  • ghost/core/test/e2e-api/admin/__snapshots__/newsletters.test.js.snap is excluded by !**/*.snap
📒 Files selected for processing (4)
  • ghost/core/core/server/data/migrations/versions/5.120/2025-05-13-17-36-56-add-newsletters-button-style-column.js (1 hunks)
  • ghost/core/core/server/data/schema/schema.js (1 hunks)
  • ghost/core/core/server/models/newsletter.js (1 hunks)
  • ghost/core/test/unit/server/data/schema/integrity.test.js (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: Ghost-CLI tests
  • GitHub Check: Regression tests (Node 20.11.1, sqlite3)
  • GitHub Check: Unit tests (Node 22.13.1)
  • GitHub Check: Database tests (Node 20.11.1, sqlite3)
  • GitHub Check: Database tests (Node 22.13.1, mysql8)
  • GitHub Check: Unit tests (Node 20.11.1)
  • GitHub Check: Regression tests (Node 20.11.1, mysql8)
  • GitHub Check: Database tests (Node 20.11.1, mysql8)
  • GitHub Check: Lint
🔇 Additional comments (4)
ghost/core/core/server/models/newsletter.js (1)

34-35: LGTM: Added button_style default property correctly.

The addition of the button_style property with default value 'fill' to the Newsletter model properly aligns with the schema changes. This ensures new newsletters created will have the default button style set.

ghost/core/test/unit/server/data/schema/integrity.test.js (1)

38-38: LGTM: Updated schema hash to reflect the schema changes.

The schema hash has been correctly updated to account for the addition of the button_style column to the newsletters table.

ghost/core/core/server/data/migrations/versions/5.120/2025-05-13-17-36-56-add-newsletters-button-style-column.js (1)

1-8: LGTM: Well-structured migration for adding the new column.

The migration script properly utilizes the createAddColumnMigration utility to add the button_style column with appropriate constraints and default value.

ghost/core/core/server/data/schema/schema.js (1)

50-51: LGTM: Schema definition correctly specifies column constraints.

The schema properly defines the button_style column with appropriate type, length constraints, null handling, default value, and validation for allowed values ('fill' and 'outline').

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the migration [pull request] Includes migration for review label May 13, 2025
Copy link
Contributor

github-actions bot commented May 13, 2025

It looks like this PR contains a migration 👀
Here's the checklist for reviewing migrations:

General requirements

  • ⚠️ Tested on the staging database servers not necessary for this migration
  • Satisfies idempotency requirement (both up() and down())
  • Does not reference models
  • Filename is in the correct format (and correctly ordered)
  • Targets the next minor version
  • All code paths have appropriate log messages
  • Uses the correct utils
  • Contains a minimal changeset
  • Does not mix DDL/DML operations
  • Tested in MySQL and SQLite doesn't apply for this simple utility-using migration

Schema changes

  • Both schema change and related migration have been implemented
  • For index changes: has been performance tested for large tables
  • For new tables/columns: fields use the appropriate predefined field lengths
  • For new tables/columns: field names follow the appropriate conventions
  • Does not drop a non-alpha table outside of a major version

Data changes

  • Mass updates/inserts are batched appropriately
  • Does not loop over large tables/datasets
  • Defends against missing or invalid data
  • For settings updates: follows the appropriate guidelines

@kevinansfield kevinansfield requested a review from lsinger May 13, 2025 20:16
Copy link
Contributor

@lsinger lsinger left a comment

Choose a reason for hiding this comment

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

I was able to check most of the items from the checklist. The testing ones I think we're discussing on Slack.

Not sure about the filename for the migration. I didn't find specific guidelines, but judging from what we've done in the past, for adding a column we've often used the format YYYY-MM-dd-HH-mm-ss-add-column-name-to-table-name.js, so this migration should probably be called 2025-05-13-17-36-56-add-button-style-to-newsletters.js. What do you think @kevinansfield?

Copy link
Contributor

@lsinger lsinger left a comment

Choose a reason for hiding this comment

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

@kevinansfield as discussed on our call, please just use a recent convention that feels good for the filename. 🙂

@kevinansfield
Copy link
Member Author

kevinansfield commented May 14, 2025

please just use a recent convention that feels good for the filename. 🙂

Personally I like the add-{table}-{column}-column pattern. We've used something similar a number of times and it matches the add-{table}-{column}-index pattern we've used in the past too. There's really no consistent pattern we've had for either though 🙈

@ErisDS
Copy link
Member

ErisDS commented May 14, 2025

My 2c here is as long as we use hyphens, similar language (e.g. add and not adding or added) and the right date format it's fine.

Uppercase, snake case, spaces etc all cause real issues :D

@kevinansfield kevinansfield merged commit 915b52e into main May 14, 2025
25 checks passed
@kevinansfield kevinansfield deleted the newsletter-button_style-migration branch May 14, 2025 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
migration [pull request] Includes migration for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants