Skip to content

Conversation

mike182uk
Copy link
Member

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

Removed updated_by & created_by fields as they are deprecated and should not be being used anywhere meaningful in the codebase. Removal of these fields is a prerequisite for the work needed for https://linear.app/ghost/issue/PROD-1594 (removal of hardocded owner user id 1)

Copy link
Contributor

coderabbitai bot commented Jun 24, 2025

Walkthrough

This change set systematically removes the created_by and updated_by fields from the application's database schema, model logic, serialization, seeders, importers, and test fixtures. It introduces new migration scripts to drop these columns from all relevant tables and updates the schema definitions accordingly. All code paths that previously set, referenced, or manipulated these fields—such as model event hooks, import/export utilities, serializers, and data generators—have been revised to exclude them. Test cases and fixture data are updated to eliminate any references or assertions related to these fields. Documentation and typedefs are also revised to reflect the absence of created_by and updated_by throughout the codebase.

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ast-grep (0.38.1)
ghost/core/test/legacy/models/model_posts.test.js
🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ghost/admin/mirage/fixtures/settings.js

Oops! Something went wrong! :(

ESLint: 8.57.1

Error: Failed to load parser '@babel/eslint-parser' declared in 'ghost/admin/.eslintrc.js': Cannot find module '@babel/eslint-parser'
Require stack:

  • /ghost/admin/.eslintrc.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1405:15)
    at require.resolve (node:internal/modules/helpers:145:19)
    at Object.resolve (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2346:46)
    at ConfigArrayFactory._loadParser (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3325:39)
    at ConfigArrayFactory._normalizeObjectConfigDataBody (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3099:43)
    at _normalizeObjectConfigDataBody.next ()
    at ConfigArrayFactory._normalizeObjectConfigData (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3040:20)
    at _normalizeObjectConfigData.next ()
    at ConfigArrayFactory.loadInDirectory (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2886:28)
    at CascadingConfigArrayFactory._loadConfigInAncestors (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3871:46)
ghost/admin/mirage/fixtures/roles.js

Oops! Something went wrong! :(

ESLint: 8.57.1

Error: Failed to load parser '@babel/eslint-parser' declared in 'ghost/admin/.eslintrc.js': Cannot find module '@babel/eslint-parser'
Require stack:

  • /ghost/admin/.eslintrc.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1405:15)
    at require.resolve (node:internal/modules/helpers:145:19)
    at Object.resolve (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2346:46)
    at ConfigArrayFactory._loadParser (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3325:39)
    at ConfigArrayFactory._normalizeObjectConfigDataBody (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3099:43)
    at _normalizeObjectConfigDataBody.next ()
    at ConfigArrayFactory._normalizeObjectConfigData (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3040:20)
    at _normalizeObjectConfigData.next ()
    at ConfigArrayFactory.loadInDirectory (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2886:28)
    at CascadingConfigArrayFactory._loadConfigInAncestors (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3871:46)
✨ 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 Jun 24, 2025
Copy link
Contributor

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

General requirements

  • ⚠️ Tested on the staging database servers
  • 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

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

@mike182uk mike182uk force-pushed the remove-x-by-fields branch from 821c91d to 5de7e2a Compare June 24, 2025 16:17
Copy link

codecov bot commented Jun 24, 2025

Codecov Report

Attention: Patch coverage is 47.05882% with 18 lines in your changes missing coverage. Please review.

Project coverage is 71.32%. Comparing base (af664e1) to head (56a0a5e).
Report is 1 commits behind head on 6.x.

Files with missing lines Patch % Lines
ghost/core/core/server/models/post.js 45.45% 11 Missing and 1 partial ⚠️
...re/server/data/seeders/importers/EmailsImporter.js 0.00% 1 Missing ⚠️
...re/server/data/seeders/importers/LabelsImporter.js 0.00% 1 Missing ⚠️
...eeders/importers/MembersStripeCustomersImporter.js 0.00% 1 Missing ⚠️
...core/server/data/seeders/importers/TagsImporter.js 0.00% 1 Missing ⚠️
...ore/server/data/seeders/importers/UsersImporter.js 0.00% 1 Missing ⚠️
.../server/services/activitypub/ActivityPubService.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              6.x   #24053      +/-   ##
==========================================
- Coverage   71.34%   71.32%   -0.03%     
==========================================
  Files        1534     1534              
  Lines      114055   113998      -57     
  Branches    13700    13688      -12     
==========================================
- Hits        81373    81306      -67     
- Misses      31643    31653      +10     
  Partials     1039     1039              
Flag Coverage Δ
admin-tests 49.24% <ø> (-0.01%) ⬇️
e2e-tests 71.32% <47.05%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mike182uk mike182uk force-pushed the remove-x-by-fields branch 3 times, most recently from 6ec431d to ac86419 Compare June 24, 2025 19:33
mike182uk and others added 7 commits June 25, 2025 09:57
Removed the `updated_by` field from everywhere as it is deprecated and no longer
used. Removing this field also makes future changes related to the removal of
the hardcoded owner user id (`1`) by removing a code path that will use this
hardcoded owner user id.

There are still some references to `updated_by` and these are intentional:

1. Old migration files (versions 4.x) - These should NOT be modified as they
represent historical database state
2. Test files checking that updated_by is stripped - These are correct and
should remain
3. Export/import JSON fixtures in content/data - These are data export files
and shouldn't be modified
4. Our new migration file - This is the file that removes `updated_by` columns,
so it correctly references them
5. Test fixtures - Some JSON test fixtures still contain updated_by but these
represent test data for import/export functionality
@mike182uk mike182uk force-pushed the remove-x-by-fields branch from fb5d623 to 8e0e130 Compare June 25, 2025 08:58
@mike182uk mike182uk force-pushed the remove-x-by-fields branch from 0873c94 to 56a0a5e Compare June 25, 2025 10:31
@mike182uk mike182uk marked this pull request as ready for review June 25, 2025 10:43
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🔭 Outside diff range comments (1)
ghost/core/core/server/data/schema/schema.js (1)

1-1100: Consider audit trail and compliance implications.

The systematic removal of created_by and updated_by fields eliminates user-level audit tracking capabilities. While this aligns with the goal of removing hardcoded user dependencies, consider the following implications:

  1. Compliance Requirements: Some regulatory frameworks require tracking of record modifications by user
  2. Forensic Capabilities: Loss of user attribution for data changes
  3. Migration Timing: Ensure schema changes are coordinated with application deployment to prevent runtime errors

Consider implementing alternative audit mechanisms if user-level tracking becomes necessary in the future, such as:

  • Event-sourcing patterns for critical operations
  • Application-level audit logs separate from the main schema
  • Integration with external audit systems
🧹 Nitpick comments (2)
ghost/core/test/utils/fixtures/urls/resources.json (1)

709-726: Fixture still contains duplicated tag records – consider deduplicating.

IDs 618ba1febe2896088840a6db, 9451f5fca366002ebd5dbea6, and 618ba1fdbe2896088840a675 each appear twice (reserved = true/false).
Unless a test explicitly relies on this duplication, trimming duplicates will speed up fixture loading and reduce cognitive overhead.

Also applies to: 763-780, 817-834

ghost/core/test/utils/fixtures/data-generator.js (1)

1290-1301: DRY-up opportunity: reuse createBasic to avoid timestamp/id duplication

createSetting re-implements the id, created_at, and updated_at fields that createBasic() already provides elsewhere in this file. Switching to the shared helper keeps the factories consistent and reduces maintenance effort.

-    return _.defaults(newObj, {
-        id: ObjectId().toHexString(),
-        uuid: '95ce1c53-69b0-4f5f-be91-d3aeb39046b5',
-        key: 'title',
-        value: null,
-        type: 'site',
-        created_at: new Date(),
-        updated_at: new Date()
-    });
+    return _.defaults(newObj, Object.assign({
+        uuid: '95ce1c53-69b0-4f5f-be91-d3aeb39046b5',
+        key: 'title',
+        value: null,
+        type: 'site'
+    }, createBasic()));
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between af664e1 and 56a0a5e.

⛔ Files ignored due to path filters (1)
  • ghost/core/test/e2e-api/admin/__snapshots__/session.test.js.snap is excluded by !**/*.snap
📒 Files selected for processing (58)
  • ghost/admin/app/serializers/application.js (0 hunks)
  • ghost/admin/mirage/fixtures/roles.js (1 hunks)
  • ghost/admin/mirage/fixtures/settings.js (1 hunks)
  • ghost/core/core/server/api/endpoints/utils/serializers/output/all.js (1 hunks)
  • ghost/core/core/server/api/endpoints/utils/serializers/output/mappers/snippets.js (1 hunks)
  • ghost/core/core/server/api/endpoints/utils/serializers/output/members.js (0 hunks)
  • ghost/core/core/server/data/importer/importers/data/Base.js (1 hunks)
  • ghost/core/core/server/data/importer/importers/data/SettingsImporter.js (0 hunks)
  • ghost/core/core/server/data/migrations/utils/permissions.js (1 hunks)
  • ghost/core/core/server/data/migrations/utils/settings.js (2 hunks)
  • ghost/core/core/server/data/migrations/versions/6.0/2025-06-20-01-41-54-remove-updated-by-column.js (1 hunks)
  • ghost/core/core/server/data/migrations/versions/6.0/2025-06-20-13-41-55-remove-created-by-column.js (1 hunks)
  • ghost/core/core/server/data/schema/fixtures/fixtures.json (0 hunks)
  • ghost/core/core/server/data/schema/schema.js (13 hunks)
  • ghost/core/core/server/data/seeders/importers/EmailsImporter.js (1 hunks)
  • ghost/core/core/server/data/seeders/importers/LabelsImporter.js (1 hunks)
  • ghost/core/core/server/data/seeders/importers/MembersImporter.js (0 hunks)
  • ghost/core/core/server/data/seeders/importers/MembersStripeCustomersImporter.js (1 hunks)
  • ghost/core/core/server/data/seeders/importers/MembersStripeCustomersSubscriptionsImporter.js (0 hunks)
  • ghost/core/core/server/data/seeders/importers/PostsImporter.js (0 hunks)
  • ghost/core/core/server/data/seeders/importers/TagsImporter.js (1 hunks)
  • ghost/core/core/server/data/seeders/importers/UsersImporter.js (1 hunks)
  • ghost/core/core/server/models/base/plugins/events.js (0 hunks)
  • ghost/core/core/server/models/post.js (1 hunks)
  • ghost/core/core/server/models/settings.js (1 hunks)
  • ghost/core/core/server/models/user.js (2 hunks)
  • ghost/core/core/server/services/activitypub/ActivityPubService.ts (1 hunks)
  • ghost/core/core/server/services/link-redirection/README.md (1 hunks)
  • ghost/core/test/e2e-api/admin/posts-legacy.test.js (16 hunks)
  • ghost/core/test/e2e-api/admin/utils.js (0 hunks)
  • ghost/core/test/integration/importer/v2.test.js (5 hunks)
  • ghost/core/test/integration/services/email-service/batch-sending.test.js (1 hunks)
  • ghost/core/test/legacy/api/admin/posts.test.js (1 hunks)
  • ghost/core/test/legacy/api/admin/schedules.test.js (0 hunks)
  • ghost/core/test/legacy/api/content/authors.test.js (2 hunks)
  • ghost/core/test/legacy/api/content/pages.test.js (2 hunks)
  • ghost/core/test/legacy/api/content/posts.test.js (2 hunks)
  • ghost/core/test/legacy/api/content/utils.js (0 hunks)
  • ghost/core/test/legacy/models/model_posts.test.js (1 hunks)
  • ghost/core/test/legacy/models/model_settings.test.js (1 hunks)
  • ghost/core/test/unit/api/canary/utils/serializers/output/all.test.js (4 hunks)
  • ghost/core/test/unit/api/canary/utils/serializers/output/mapper.test.js (1 hunks)
  • ghost/core/test/unit/api/canary/utils/validators/input/pages.test.js (0 hunks)
  • ghost/core/test/unit/api/canary/utils/validators/input/posts.test.js (0 hunks)
  • ghost/core/test/unit/api/canary/utils/validators/input/tags.test.js (1 hunks)
  • ghost/core/test/unit/api/canary/utils/validators/input/webhooks.test.js (1 hunks)
  • ghost/core/test/unit/server/data/migrations/utils.test.js (3 hunks)
  • ghost/core/test/unit/server/data/schema/integrity.test.js (1 hunks)
  • ghost/core/test/unit/server/data/schema/validator.test.js (1 hunks)
  • ghost/core/test/unit/server/services/activitypub/ActivityPubService.test.ts (0 hunks)
  • ghost/core/test/utils/batch-email-utils.js (0 hunks)
  • ghost/core/test/utils/fixtures/data-generator.js (1 hunks)
  • ghost/core/test/utils/fixtures/filter-param/index.js (1 hunks)
  • ghost/core/test/utils/fixtures/fixtures.json (0 hunks)
  • ghost/core/test/utils/fixtures/import/import-data-1.json (1 hunks)
  • ghost/core/test/utils/fixtures/import/import-data-lts.json (1 hunks)
  • ghost/core/test/utils/fixtures/urls/resources.json (9 hunks)
  • ghost/core/test/utils/fixtures/urls/urls.json (6 hunks)
💤 Files with no reviewable changes (16)
  • ghost/core/core/server/data/seeders/importers/MembersStripeCustomersSubscriptionsImporter.js
  • ghost/core/test/unit/server/services/activitypub/ActivityPubService.test.ts
  • ghost/core/test/legacy/api/admin/schedules.test.js
  • ghost/core/test/unit/api/canary/utils/validators/input/pages.test.js
  • ghost/core/core/server/data/schema/fixtures/fixtures.json
  • ghost/core/core/server/data/seeders/importers/MembersImporter.js
  • ghost/core/core/server/data/seeders/importers/PostsImporter.js
  • ghost/core/test/legacy/api/content/utils.js
  • ghost/core/test/e2e-api/admin/utils.js
  • ghost/admin/app/serializers/application.js
  • ghost/core/core/server/data/importer/importers/data/SettingsImporter.js
  • ghost/core/test/utils/fixtures/fixtures.json
  • ghost/core/core/server/api/endpoints/utils/serializers/output/members.js
  • ghost/core/test/unit/api/canary/utils/validators/input/posts.test.js
  • ghost/core/test/utils/batch-email-utils.js
  • ghost/core/core/server/models/base/plugins/events.js
🔇 Additional comments (57)
ghost/core/core/server/services/activitypub/ActivityPubService.ts (1)

130-130: Clean removal of deprecated user attribution field.

The removal of created_by: '1' from webhook insertion aligns perfectly with the PR objectives to eliminate hardcoded user references and deprecated attribution fields. Preserving created_at maintains proper audit trails.

ghost/core/core/server/data/seeders/importers/MembersStripeCustomersImporter.js (1)

54-54: Consistent removal of unused attribution field.

The removal of created_by: 'unused' from the data generation aligns with the systematic cleanup effort. The field was not providing meaningful value and its removal simplifies the data model.

ghost/core/core/server/data/seeders/importers/UsersImporter.js (1)

25-25: Proper removal of deprecated field in user data generation.

The removal of created_by: 'unused' follows the consistent pattern across all importers. The preservation of created_at with realistic timestamp generation maintains data integrity for testing purposes.

ghost/core/core/server/data/seeders/importers/EmailsImporter.js (1)

92-92: Complete removal of both deprecated attribution fields.

The removal of both created_by: 'unused' and updated_by: 'unused' demonstrates thorough cleanup. Preserving updated_at maintains proper audit trails for email tracking and status updates.

ghost/core/core/server/api/endpoints/utils/serializers/output/all.js (1)

9-9: Logical update to serialization filtering.

The modification to only filter published_by is correct since created_by and updated_by fields are being removed from the database schema entirely. This change aligns the serialization logic with the new data model.

ghost/core/test/utils/fixtures/import/import-data-1.json (1)

67-67: LGTM: Clean removal of deprecated fields

The JSON structure is properly maintained after removing the created_by and updated_by fields from the tag object, with correct comma handling.

ghost/admin/mirage/fixtures/roles.js (1)

8-8: LGTM: Consistent field removal across all role fixtures

All role objects have been properly updated to remove the deprecated created_by and updated_by fields while maintaining correct JavaScript object syntax.

Also applies to: 15-15, 22-22, 29-29, 36-36, 43-43

ghost/core/test/utils/fixtures/filter-param/index.js (1)

42-42: LGTM: Clean removal of created_by fields from tag fixtures

The created_by fields have been properly removed from all tag objects in the test fixture data, maintaining correct JavaScript syntax and consistency with the PR objective.

Also applies to: 49-49, 56-56, 64-64, 69-69, 74-74

ghost/core/test/legacy/api/content/pages.test.js (1)

34-34: LGTM: Proper removal of deprecated created_by field from test user insertions

The created_by field has been correctly removed from user insertions in both test cases. The test logic for filtering functionality remains unaffected.

Also applies to: 73-73

ghost/core/test/legacy/api/content/authors.test.js (1)

33-33: LGTM: Consistent removal of deprecated created_by field

The created_by field has been properly removed from user insertions in both test cases, aligning with the broader effort to eliminate these deprecated fields while preserving test functionality.

Also applies to: 72-72

ghost/core/test/utils/fixtures/import/import-data-lts.json (1)

58-59: LGTM! Consistent field removal in test fixture.

The removal of created_by and updated_by fields from the tags object aligns with the systematic deprecation of these user attribution fields while preserving the timestamp field.

ghost/core/test/unit/api/canary/utils/validators/input/tags.test.js (1)

107-128: LGTM! Test correctly reflects validation changes.

The test data and assertions are properly updated to match the removal of created_by and updated_by fields from the validation logic. The test now only verifies stripping of the remaining fields that should be excluded from tag input.

ghost/core/test/legacy/api/content/posts.test.js (2)

30-38: LGTM! Consistent field removal from test user data.

The removal of created_by field from the test user record aligns with the schema changes while maintaining all necessary fields for the test functionality.


69-77: LGTM! Consistent field removal from test user data.

The removal of created_by field from the second test user record maintains consistency with the schema changes while preserving test functionality.

ghost/core/test/utils/fixtures/urls/urls.json (6)

19-19: LGTM! Systematic removal of deprecated user attribution fields.

The removal of created_by and updated_by fields from the author object is consistent with the broader deprecation effort while preserving necessary timestamp fields.


563-563: LGTM! Consistent field removal from tag fixtures.

The removal of created_by and updated_by fields from the tag object maintains consistency with the schema changes while preserving timestamp fields.


588-588: LGTM! Consistent field removal from author fixtures.

The removal of created_by and updated_by fields from the author object aligns with the systematic deprecation of these user attribution fields.


709-709: LGTM! Consistent field removal from tag fixtures.

The removal of created_by and updated_by fields from the tag object maintains consistency across all fixture data.


740-740: LGTM! Consistent field removal from tag fixtures.

The removal of created_by and updated_by fields from the tag object completes the systematic cleanup of these deprecated fields.


812-812: LGTM! Consistent field removal from tag fixtures.

The removal of created_by and updated_by fields from the final tag object maintains consistency throughout the fixture file.

ghost/core/core/server/models/user.js (2)

79-79: LGTM! Minor formatting improvement.

The added space in the if condition improves code readability without any functional change.


779-779: LGTM! Documentation formatting fix.

The whitespace correction in the JSDoc comment improves documentation consistency.

ghost/core/core/server/services/link-redirection/README.md (1)

80-80: Documentation updated correctly to reflect field removal.

The SQL statement documentation has been appropriately updated to exclude the deprecated created_by and updated_by fields from the member update query.

ghost/core/test/unit/api/canary/utils/serializers/output/mapper.test.js (1)

183-183: Test expectation correctly updated to reflect serializer changes.

The test now properly excludes created_by and updated_by from the expected snippet mapper output, aligning with the updated serialization logic.

ghost/admin/mirage/fixtures/settings.js (1)

15-15: Fixture function correctly updated to exclude deprecated fields.

The setting fixture function has been properly modified to remove created_by and updated_by properties while retaining the timestamp fields.

ghost/core/test/unit/server/data/schema/validator.test.js (2)

26-26: Validation error count correctly updated.

The expected error count has been appropriately reduced from 6 to 5 to reflect the removal of the created_by field validation requirement.


33-33: Field validation list properly updated.

The test now correctly validates only the remaining required fields: id, uuid, slug, title, and created_at, excluding the removed created_by field.

ghost/core/test/legacy/models/model_settings.test.js (1)

36-36: Test database insertion correctly updated.

The test has been properly modified to exclude the deprecated created_by and updated_by fields from the database insertion, preventing potential test failures due to missing columns.

ghost/core/core/server/data/seeders/importers/TagsImporter.js (1)

35-35: LGTM: Clean removal of deprecated field.

The removal of the created_by field assignment aligns perfectly with the PR objective to eliminate deprecated user attribution fields. The essential created_at timestamp is preserved, maintaining proper audit trail functionality.

ghost/core/test/unit/api/canary/utils/validators/input/webhooks.test.js (1)

124-124: LGTM: Test updated to reflect removal of deprecated fields.

The test correctly removes created_by and updated_by from the webhook test data, aligning with their systematic removal across the codebase. The test logic for field stripping validation remains intact and appropriate.

ghost/core/core/server/data/importer/importers/data/Base.js (1)

289-290: LGTM: User reference processing updated correctly.

The removal of 'created_by' and 'updated_by' from the user reference fields array is appropriate since these fields are being eliminated from the database schema. The remaining user references ('author_id' and 'published_by') continue to be processed correctly during import operations.

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

38-39: LGTM: Schema and fixtures integrity hashes updated correctly.

The updated MD5 hash values appropriately reflect the systematic removal of created_by and updated_by fields from the database schema and fixtures. This ensures the integrity test continues to function properly after the schema modifications.

ghost/core/test/integration/services/email-service/batch-sending.test.js (1)

534-534: LGTM: Test data cleaned up to remove deprecated fields.

The removal of created_by and updated_by fields from the test post object correctly reflects the updated data model. The test maintains its core functionality for email verification requirements while using consistent data structures.

ghost/core/test/utils/fixtures/urls/resources.json (1)

670-672: Confirm all downstream code/tests no longer expect created_by / updated_by.

The fixture update looks correct, but any reader that still dereferences the removed keys will now raise undefined/null errors.
Please sanity-check the entire codebase (migrations, serializers, import/export helpers, and test assertions) for lingering references.

#!/bin/bash
# Search the whole repo for any remaining `created_by` / `updated_by` references.
rg -n --no-heading -e '"created_by"' -e '"updated_by"' -e '\.created_by' -e '\.updated_by'

Also applies to: 697-699, 725-726, 752-753, 806-807, 833-834, 856-857, 877-878

ghost/core/test/legacy/models/model_posts.test.js (1)

1833-1834: LGTM: Test correctly updated to remove deprecated fields.

The test properly removes assertions for created_by and updated_by properties, which aligns with their systematic removal from the codebase.

ghost/core/core/server/data/seeders/importers/LabelsImporter.js (1)

27-36: LGTM: Correctly removes deprecated user attribution fields.

The generate() method appropriately removes created_by and updated_by fields while preserving the necessary timestamp fields (created_at and updated_at). This aligns with the systematic removal of these deprecated fields across the codebase.

ghost/core/test/unit/api/canary/utils/serializers/output/all.test.js (1)

6-63: LGTM: Test correctly updated to reflect new serialization behavior.

The test properly updates all references from created_by/updated_by to published_by, which aligns with the changes to the serializer's removeXBY function that now only removes published_by fields. The test coverage remains comprehensive while reflecting the new field filtering behavior.

ghost/core/core/server/api/endpoints/utils/serializers/output/mappers/snippets.js (1)

7-29: LGTM: Correctly removes deprecated fields from snippet serialization.

The mapper function and JSDoc typedef are properly updated to exclude created_by and updated_by fields from the serialized snippet output. This maintains consistency with the systematic removal of these deprecated user attribution fields across the codebase.

ghost/core/test/legacy/api/admin/posts.test.js (1)

796-796: LGTM! Test name accurately reflects updated scope.

The test name change from "update dates & x_by" to "update dates" correctly reflects that the test now only verifies the immutability of created_at and updated_at fields, aligning with the removal of created_by and updated_by fields from the codebase.

ghost/core/core/server/data/migrations/utils/permissions.js (1)

33-50: Excellent backward-compatible migration pattern.

The conditional logic for created_by and updated_by fields is well-implemented:

  • Uses connection.schema.hasColumn to check column existence before inclusion
  • Ensures migrations work both before and after column removal
  • Maintains consistency between both audit fields
  • Follows defensive programming practices for schema evolution

This approach prevents migration failures during the transition period when these columns may or may not exist.

ghost/core/test/e2e-api/admin/posts-legacy.test.js (1)

269-270: Removal of obsolete attribution fields looks good

All touched object literals have dropped the deprecated created_by/updated_by fields while retaining updated_at for optimistic-locking. Nothing else in the tests relies on those removed fields, so behaviour and assertions remain intact.

No further action needed.

Also applies to: 605-606, 647-648, 703-704, 772-773, 840-841, 912-913, 982-983, 1050-1051, 1120-1121, 1212-1214, 1300-1301, 1390-1391, 1487-1488, 1668-1669, 1730-1731

ghost/core/test/utils/fixtures/data-generator.js (2)

1293-1301: Removal of created_by/updated_by attributes is consistent – LGTM

The createSetting factory now limits itself to created_at/updated_at timestamps, aligning with the wider schema change. No functional issues spotted.


1290-1301: Sanity-check: ensure no stray created_by/updated_by usages remain

To be extra safe after this large-scale removal, run a quick grep to verify the repo is now free of the deprecated columns.

#!/bin/bash
# Find any remaining references to removed audit columns
rg -n --ignore-case --no-heading 'created_by|updated_by'
ghost/core/test/integration/importer/v2.test.js (2)

419-423: LGTM! Test expectations updated correctly for removed fields.

The test now expects only 1 problem instead of 3, correctly accounting for the removal of created_by and updated_by from user reference validation. The error message appropriately excludes these fields and focuses only on author_id and published_by references.


534-536: LGTM! Test data generation updated consistently.

The test data generation has been correctly updated to exclude created_by and updated_by fields from user and tag creation. These changes are consistent with the schema updates and ensure tests align with the new data model.

Also applies to: 578-585, 1203-1212

ghost/core/test/unit/server/data/migrations/utils.test.js (2)

224-225: LGTM! Test database schema updated correctly.

The test database setup functions have been properly updated to exclude created_by and updated_by fields from both schema creation and data insertion. This ensures migration utility tests work correctly with the updated database schema.

Also applies to: 232-233, 241-242


661-661: LGTM! Test data insertion updated consistently.

The settings test data insertion correctly excludes the created_by field, maintaining consistency with the schema changes throughout the test utilities.

ghost/core/core/server/models/settings.js (1)

300-300: LGTM! Settings model updated correctly for field removal.

The populateDefaults method has been properly updated to exclude created_by and updated_by field assignment. This change aligns with the database schema modifications and the removal of owner user retrieval logic earlier in the method.

ghost/core/core/server/data/migrations/versions/6.0/2025-06-20-01-41-54-remove-updated-by-column.js (2)

4-16: LGTM! Robust helper function with proper safety checks.

The dropUpdatedBy helper function correctly checks for column existence before attempting to drop it, which prevents errors in environments where the migration might be run multiple times. The logging provides good visibility into the migration progress.


18-46: LGTM! Comprehensive migration covering all relevant tables.

The migration properly covers all tables that had updated_by columns, uses non-transactional migration appropriately for schema changes, and correctly indicates that the down migration is not supported for this major version change. The logging provides clear feedback on migration progress.

ghost/core/core/server/data/migrations/utils/settings.js (2)

31-49: LGTM! Excellent backward-compatible migration pattern.

The conditional schema checks ensure this migration utility works correctly both before and after the created_by/updated_by columns are removed. This is the proper approach for phased field removal.


110-129: Consistent implementation in the down migration.

The same conditional logic is properly applied in the removeSetting down function, maintaining consistency with the up migration pattern.

ghost/core/core/server/models/post.js (1)

604-624: Well-implemented scheduler touch logic.

This logic effectively handles the edge case where scheduled posts are updated close to their publish time. The implementation is safe and efficient:

  • Clear conditional checks for the specific scenario
  • Safe "touch" mechanism that doesn't persist dummy data
  • Proper event detection through the changed object
ghost/core/core/server/data/migrations/versions/6.0/2025-06-20-13-41-55-remove-created-by-column.js (3)

4-16: Robust helper function with proper safeguards.

The dropCreatedBy helper function correctly checks for column existence before attempting to drop it, preventing errors if the column has already been removed. The logging provides good visibility into the migration process.


18-41: Comprehensive table coverage with proper coordination.

The migration systematically removes created_by from all relevant tables. The sequential approach and logging ensure transparency during the migration process.


43-46: Appropriate handling of irreversible migration.

The down migration correctly acknowledges that this is a major version change that cannot be safely reverted, which aligns with the nature of removing core schema columns.

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

184-184: ```shell
#!/bin/bash
echo "=== remove-created-by migration ==="
sed -n '1,200p' ghost/core/core/server/data/migrations/versions/6.0/2025-06-20-13-41-55-remove-created-by-column.js

echo -e "\n=== remove-updated-by migration ==="
sed -n '1,200p' ghost/core/core/server/data/migrations/versions/6.0/2025-06-20-01-41-54-remove-updated-by-column.js


</details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->

@mike182uk mike182uk merged commit cce1d06 into 6.x Jun 25, 2025
27 checks passed
@mike182uk mike182uk deleted the remove-x-by-fields branch June 25, 2025 11:09
mike182uk added a commit that referenced this pull request Jun 26, 2025
ref https://linear.app/ghost/issue/PROD-1597
ref #24053

Removed `updatedBy` & `createdBy` fields in the admin app as they are deprecated
and should not be being used anywhere meaningful in the codebase
mike182uk added a commit that referenced this pull request Jun 26, 2025
ref https://linear.app/ghost/issue/PROD-1597
ref #24053

Removed `updatedBy` & `createdBy` fields in the admin app as they are
deprecated and should not be being used anywhere meaningful in the
codebase
ErisDS pushed a commit that referenced this pull request Jun 30, 2025
ref https://linear.app/ghost/issue/PROD-1597
ref #24053

Removed `updatedBy` & `createdBy` fields in the admin app as they are
deprecated and should not be being used anywhere meaningful in the
codebase
ErisDS added a commit that referenced this pull request Jul 1, 2025
ref https://linear.app/ghost/issue/PROD-1597

Removed `updated_by` & `created_by` fields as they are deprecated and
should not be being used anywhere meaningful in the codebase. Removal of
these fields is a prerequisite for the work needed for
https://linear.app/ghost/issue/PROD-1594 (removal of hardocded owner
user id `1`)

---------

Co-authored-by: Hannah Wolfe <github.erisds@gmail.com>
ErisDS pushed a commit that referenced this pull request Jul 1, 2025
ref https://linear.app/ghost/issue/PROD-1597
ref #24053

Removed `updatedBy` & `createdBy` fields in the admin app as they are
deprecated and should not be being used anywhere meaningful in the
codebase
ErisDS added a commit that referenced this pull request Jul 2, 2025
ref https://linear.app/ghost/issue/PROD-1597

Removed `updated_by` & `created_by` fields as they are deprecated and
should not be being used anywhere meaningful in the codebase. Removal of
these fields is a prerequisite for the work needed for
https://linear.app/ghost/issue/PROD-1594 (removal of hardocded owner
user id `1`)

---------

Co-authored-by: Hannah Wolfe <github.erisds@gmail.com>
ErisDS pushed a commit that referenced this pull request Jul 2, 2025
ref https://linear.app/ghost/issue/PROD-1597
ref #24053

Removed `updatedBy` & `createdBy` fields in the admin app as they are
deprecated and should not be being used anywhere meaningful in the
codebase
ErisDS added a commit that referenced this pull request Jul 2, 2025
ref https://linear.app/ghost/issue/PROD-1597

Removed `updated_by` & `created_by` fields as they are deprecated and
should not be being used anywhere meaningful in the codebase. Removal of
these fields is a prerequisite for the work needed for
https://linear.app/ghost/issue/PROD-1594 (removal of hardocded owner
user id `1`)

---------

Co-authored-by: Hannah Wolfe <github.erisds@gmail.com>
ErisDS pushed a commit that referenced this pull request Jul 2, 2025
ref https://linear.app/ghost/issue/PROD-1597
ref #24053

Removed `updatedBy` & `createdBy` fields in the admin app as they are
deprecated and should not be being used anywhere meaningful in the
codebase
ErisDS added a commit that referenced this pull request Jul 10, 2025
ref https://linear.app/ghost/issue/PROD-1597

Removed `updated_by` & `created_by` fields as they are deprecated and
should not be being used anywhere meaningful in the codebase. Removal of
these fields is a prerequisite for the work needed for
https://linear.app/ghost/issue/PROD-1594 (removal of hardocded owner
user id `1`)

---------

Co-authored-by: Hannah Wolfe <github.erisds@gmail.com>
ErisDS pushed a commit that referenced this pull request Jul 10, 2025
ref https://linear.app/ghost/issue/PROD-1597
ref #24053

Removed `updatedBy` & `createdBy` fields in the admin app as they are
deprecated and should not be being used anywhere meaningful in the
codebase
ErisDS added a commit that referenced this pull request Jul 10, 2025
ref https://linear.app/ghost/issue/PROD-1597

Removed `updated_by` & `created_by` fields as they are deprecated and
should not be being used anywhere meaningful in the codebase. Removal of
these fields is a prerequisite for the work needed for
https://linear.app/ghost/issue/PROD-1594 (removal of hardocded owner
user id `1`)

---------

Co-authored-by: Hannah Wolfe <github.erisds@gmail.com>
ErisDS pushed a commit that referenced this pull request Jul 10, 2025
ref https://linear.app/ghost/issue/PROD-1597
ref #24053

Removed `updatedBy` & `createdBy` fields in the admin app as they are
deprecated and should not be being used anywhere meaningful in the
codebase
ErisDS added a commit that referenced this pull request Jul 11, 2025
ref https://linear.app/ghost/issue/PROD-1597

Removed `updated_by` & `created_by` fields as they are deprecated and
should not be being used anywhere meaningful in the codebase. Removal of
these fields is a prerequisite for the work needed for
https://linear.app/ghost/issue/PROD-1594 (removal of hardocded owner
user id `1`)

---------

Co-authored-by: Hannah Wolfe <github.erisds@gmail.com>
ErisDS pushed a commit that referenced this pull request Jul 11, 2025
ref https://linear.app/ghost/issue/PROD-1597
ref #24053

Removed `updatedBy` & `createdBy` fields in the admin app as they are
deprecated and should not be being used anywhere meaningful in the
codebase
ErisDS added a commit that referenced this pull request Jul 14, 2025
ref https://linear.app/ghost/issue/PROD-1597

Removed `updated_by` & `created_by` fields as they are deprecated and
should not be being used anywhere meaningful in the codebase. Removal of
these fields is a prerequisite for the work needed for
https://linear.app/ghost/issue/PROD-1594 (removal of hardocded owner
user id `1`)

---------

Co-authored-by: Hannah Wolfe <github.erisds@gmail.com>
ErisDS pushed a commit that referenced this pull request Jul 14, 2025
ref https://linear.app/ghost/issue/PROD-1597
ref #24053

Removed `updatedBy` & `createdBy` fields in the admin app as they are
deprecated and should not be being used anywhere meaningful in the
codebase
ErisDS added a commit that referenced this pull request Jul 15, 2025
ref https://linear.app/ghost/issue/PROD-1597

Removed `updated_by` & `created_by` fields as they are deprecated and
should not be being used anywhere meaningful in the codebase. Removal of
these fields is a prerequisite for the work needed for
https://linear.app/ghost/issue/PROD-1594 (removal of hardocded owner
user id `1`)

---------

Co-authored-by: Hannah Wolfe <github.erisds@gmail.com>
ErisDS pushed a commit that referenced this pull request Jul 15, 2025
ref https://linear.app/ghost/issue/PROD-1597
ref #24053

Removed `updatedBy` & `createdBy` fields in the admin app as they are
deprecated and should not be being used anywhere meaningful in the
codebase
ErisDS added a commit that referenced this pull request Jul 16, 2025
ref https://linear.app/ghost/issue/PROD-1597

Removed `updated_by` & `created_by` fields as they are deprecated and
should not be being used anywhere meaningful in the codebase. Removal of
these fields is a prerequisite for the work needed for
https://linear.app/ghost/issue/PROD-1594 (removal of hardocded owner
user id `1`)

---------

Co-authored-by: Hannah Wolfe <github.erisds@gmail.com>
ErisDS pushed a commit that referenced this pull request Jul 16, 2025
ref https://linear.app/ghost/issue/PROD-1597
ref #24053

Removed `updatedBy` & `createdBy` fields in the admin app as they are
deprecated and should not be being used anywhere meaningful in the
codebase
ErisDS added a commit that referenced this pull request Jul 17, 2025
ref https://linear.app/ghost/issue/PROD-1597

Removed `updated_by` & `created_by` fields as they are deprecated and
should not be being used anywhere meaningful in the codebase. Removal of
these fields is a prerequisite for the work needed for
https://linear.app/ghost/issue/PROD-1594 (removal of hardocded owner
user id `1`)

---------

Co-authored-by: Hannah Wolfe <github.erisds@gmail.com>
ErisDS pushed a commit that referenced this pull request Jul 17, 2025
ref https://linear.app/ghost/issue/PROD-1597
ref #24053

Removed `updatedBy` & `createdBy` fields in the admin app as they are
deprecated and should not be being used anywhere meaningful in the
codebase
ErisDS added a commit that referenced this pull request Jul 17, 2025
ref https://linear.app/ghost/issue/PROD-1597

Removed `updated_by` & `created_by` fields as they are deprecated and
should not be being used anywhere meaningful in the codebase. Removal of
these fields is a prerequisite for the work needed for
https://linear.app/ghost/issue/PROD-1594 (removal of hardocded owner
user id `1`)

---------

Co-authored-by: Hannah Wolfe <github.erisds@gmail.com>
ErisDS pushed a commit that referenced this pull request Jul 17, 2025
ref https://linear.app/ghost/issue/PROD-1597
ref #24053

Removed `updatedBy` & `createdBy` fields in the admin app as they are
deprecated and should not be being used anywhere meaningful in the
codebase
ErisDS added a commit that referenced this pull request Jul 18, 2025
ref https://linear.app/ghost/issue/PROD-1597

Removed `updated_by` & `created_by` fields as they are deprecated and
should not be being used anywhere meaningful in the codebase. Removal of
these fields is a prerequisite for the work needed for
https://linear.app/ghost/issue/PROD-1594 (removal of hardocded owner
user id `1`)

---------

Co-authored-by: Hannah Wolfe <github.erisds@gmail.com>
ErisDS pushed a commit that referenced this pull request Jul 18, 2025
ref https://linear.app/ghost/issue/PROD-1597
ref #24053

Removed `updatedBy` & `createdBy` fields in the admin app as they are
deprecated and should not be being used anywhere meaningful in the
codebase
ErisDS added a commit that referenced this pull request Jul 20, 2025
ref https://linear.app/ghost/issue/PROD-1597

Removed `updated_by` & `created_by` fields as they are deprecated and
should not be being used anywhere meaningful in the codebase. Removal of
these fields is a prerequisite for the work needed for
https://linear.app/ghost/issue/PROD-1594 (removal of hardocded owner
user id `1`)

---------

Co-authored-by: Hannah Wolfe <github.erisds@gmail.com>
ErisDS pushed a commit that referenced this pull request Jul 20, 2025
ref https://linear.app/ghost/issue/PROD-1597
ref #24053

Removed `updatedBy` & `createdBy` fields in the admin app as they are
deprecated and should not be being used anywhere meaningful in the
codebase
ErisDS added a commit that referenced this pull request Jul 21, 2025
ref https://linear.app/ghost/issue/PROD-1597

Removed `updated_by` & `created_by` fields as they are deprecated and
should not be being used anywhere meaningful in the codebase. Removal of
these fields is a prerequisite for the work needed for
https://linear.app/ghost/issue/PROD-1594 (removal of hardocded owner
user id `1`)

---------

Co-authored-by: Hannah Wolfe <github.erisds@gmail.com>
ErisDS pushed a commit that referenced this pull request Jul 21, 2025
ref https://linear.app/ghost/issue/PROD-1597
ref #24053

Removed `updatedBy` & `createdBy` fields in the admin app as they are
deprecated and should not be being used anywhere meaningful in the
codebase
ErisDS pushed a commit that referenced this pull request Jul 21, 2025
ref https://linear.app/ghost/issue/PROD-1597
ref #24053

Removed `updatedBy` & `createdBy` fields in the admin app as they are
deprecated and should not be being used anywhere meaningful in the
codebase
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.

2 participants