diff --git a/ghost/core/core/server/data/migrations/versions/5.100/2024-11-06-04-45-15-add-activitypub-integration.js b/ghost/core/core/server/data/migrations/versions/5.100/2024-11-06-04-45-15-add-activitypub-integration.js new file mode 100644 index 0000000000..6ed57c7fce --- /dev/null +++ b/ghost/core/core/server/data/migrations/versions/5.100/2024-11-06-04-45-15-add-activitypub-integration.js @@ -0,0 +1,40 @@ +const logging = require('@tryghost/logging'); +const {createTransactionalMigration, meta} = require('../../utils'); +const ObjectID = require('bson-objectid').default; + +module.exports = createTransactionalMigration( + async function up(knex) { + logging.info('Adding Ghost ActivityPub integration'); + const existing = await knex + .select('id') + .from('integrations') + .where('slug', '=', 'ghost-activitypub') + .andWhere('type', '=', 'internal') + .first(); + + if (existing) { + logging.warn('Found existing Ghost ActivityPub integration'); + return; + } + + await knex + .insert({ + id: (new ObjectID).toHexString(), + type: 'internal', + slug: 'ghost-activitypub', + name: 'Ghost ActivityPub', + description: 'Internal Integration for ActivityPub', + created_at: knex.raw('current_timestamp'), + created_by: meta.MIGRATION_USER + }) + .into('integrations'); + }, + async function down(knex) { + logging.info('Removing Ghost ActivityPub integration'); + await knex + .del() + .from('integrations') + .where('slug', '=', 'ghost-activitypub') + .andWhere('type', '=', 'internal'); + } +); diff --git a/ghost/core/core/server/data/schema/fixtures/fixtures.json b/ghost/core/core/server/data/schema/fixtures/fixtures.json index 1d83925ad0..f69a0c79a7 100644 --- a/ghost/core/core/server/data/schema/fixtures/fixtures.json +++ b/ghost/core/core/server/data/schema/fixtures/fixtures.json @@ -814,6 +814,13 @@ "description": "Internal Content API integration for Admin access", "type": "core", "api_keys": [{"type": "content"}] + }, + { + "slug": "ghost-activitypub", + "name": "Ghost ActivityPub", + "description": "Internal Integration for ActivityPub", + "type": "internal", + "api_keys": [] } ] } 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 c066a50308..8b1f114df9 100644 --- a/ghost/core/test/unit/server/data/schema/integrity.test.js +++ b/ghost/core/test/unit/server/data/schema/integrity.test.js @@ -36,7 +36,7 @@ const validateRouteSettings = require('../../../../../core/server/services/route describe('DB version integrity', function () { // Only these variables should need updating const currentSchemaHash = 'f12341a0c74998eeb4628322fd0982fb'; - const currentFixturesHash = '475f488105c390bb0018db90dce845f1'; + const currentFixturesHash = '80e79d1efd5da275e19cb375afb4ad04'; const currentSettingsHash = '47a75e8898fab270174a0c905cb3e914'; const currentRoutesHash = '3d180d52c663d173a6be791ef411ed01';