PhoenixKit.Modules.Publishing.Workers.MigratePrimaryLanguageWorker (phoenix_kit v1.7.33)
Copy Markdown View SourceOban worker for migrating posts to a new primary language setting.
This worker updates the primary_language metadata field for all posts in a
publishing group that need migration. It processes posts in batches and
broadcasts progress updates via PubSub.
Usage
# Enqueue a migration job
MigratePrimaryLanguageWorker.enqueue("docs", "en")
# Or with options
MigratePrimaryLanguageWorker.enqueue("docs", "en", user_id: 123)Job Arguments
group_slug- The publishing group slugprimary_language- The new primary language to setuser_id- User ID for audit trail (optional)
PubSub Events
The worker broadcasts the following events to posts_topic(group_slug):
{:primary_language_migration_started, total_count}- Migration started{:primary_language_migration_progress, current, total}- Progress update{:primary_language_migration_completed, success_count, error_count}- Completed
Summary
Functions
Creates a new migration job.
Options
:user_id- User ID for audit trail
Examples
MigratePrimaryLanguageWorker.create_job("docs", "en")
MigratePrimaryLanguageWorker.create_job("docs", "en", user_id: 123)
Enqueues a migration job.
See create_job/3 for options.
Examples
{:ok, job} = MigratePrimaryLanguageWorker.enqueue("docs", "en")