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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🏗️ Added meta fields to collections table #17769

Closed
wants to merge 2 commits into from

Conversation

naz
Copy link
Contributor

@naz naz commented Aug 21, 2023

refs https://github.com/TryGhost/Arch/issues/19

  • Adds "meta" fields similarly to the ones in "tags" table. We need these fields in collections as collections as a resource will be routable page - should be able to have customizable meta fields for the meta HTML headers and some extras like "accent_color"

Extra opinion to use the same table for meta fields by @ErisDS :

So for now I’m happy to keep storing the columns on the table as there’s no real reason not to other than neatness and easier maintenance if we did want to change one of the column types maybe.

🤖 Generated by Copilot at 7aabfb5

This pull request adds new meta fields to the collections table to enable collection customization. It includes a migration script, a schema update, and a test update to reflect the new columns and their properties.

closes https://github.com/TryGhost/Arch/issues/19

- Adds "meta" fields similarly to the ones in "tags" table. We need these fields in collections as collections as a resource will be routable page - should be able to have customizable meta fields for the meta HTML headers and some extras like "accent_color"
@naz naz requested a review from allouis August 21, 2023 07:20
@github-actions github-actions bot added the migration [pull request] Includes migration for review label Aug 21, 2023
@github-actions
Copy link
Contributor

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

General requirements

  • 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

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

@naz naz requested a review from ErisDS August 21, 2023 07:26
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.

Migration looks good - but there's some superfluous data in them (validations)

twitter_image: {type: 'string', maxlength: 2000, nullable: true},
twitter_title: {type: 'string', maxlength: 300, nullable: true},
twitter_description: {type: 'string', maxlength: 500, nullable: true},
meta_title: {type: 'string', maxlength: 2000, nullable: true, validations: {isLength: {max: 300}}},
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the reasoning behind having a validation here that doesn't match the column definition?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a "soft limit" which is set in all "meta_title" fields. More context here. My understanding it that we ha put a larger field size of 2000 chars to have a buffer just in case we ever need to increase the length of the field. In reality it's been 6 years and there was no need for increase. If we are concerned about optimal field sizes, might be a good idea to trim all meta_title fields to a length of 300 in Ghost v6 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

🤔 I see

Yeah that seems weird we don't do that with any other fields!

type: 'string',
maxlength: 2000,
nullable: true,
validations: {
Copy link
Contributor

Choose a reason for hiding this comment

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

This has no effect in a migration, it's used by bookshelf models only

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hm. true. we do use this syntax in other migrations too. I think it's here to match the syntax in schema to dot?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah I've seen it in other migrations, AFAIK they aren't there for a reason though, just misunderstanding or copy/paste errors!

IMO it will cause confusion by being there but 🤷

@naz
Copy link
Contributor Author

naz commented Oct 13, 2023

this should be picked up in few weeks time.

@naz naz closed this Oct 13, 2023
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.

None yet

2 participants