Skip to content

Conversation

progressions
Copy link
Owner

Summary

Adds CampaignTemplateSyncService to sync template content (schticks, weapons, template characters) from master template campaign to existing campaigns. This solves the problem of updating long-running campaigns that were created before images and template characters were added to the master template.

What Gets Updated

  • Schticks: Matches by name, updates all attributes + images (preserves record ID)
  • Weapons: Matches by name, updates all attributes + images (preserves record ID)
  • Template Characters: Copies characters with is_template: true (creates new records)

Features

  • Dry-run mode by default - Preview changes without modifying database
  • ID preservation - Schticks and weapons keep original IDs
  • Smart image handling - Compares checksums, only replaces when different
  • Transaction safety - All changes rolled back on error
  • Detailed logging - Shows exactly what will change before applying
  • Comprehensive tests - 33 passing RSpec tests

Usage

# List all campaigns with IDs
rails campaign:list

# Preview changes (safe, no modifications)
rails campaign:sync_template[campaign-id]

# Apply changes (live mode)
DRY_RUN=false rails campaign:sync_template[campaign-id]

Documentation

  • Quick start: docs/SYNC_QUICK_START.md
  • Complete guide: docs/TEMPLATE_SYNC_GUIDE.md

Test Plan

  • RSpec service tests (33 passing, 3 skipped edge cases)
  • Dry-run mode preserves database
  • Live mode updates schticks/weapons correctly
  • Template characters copied without duplicates
  • Images attached/replaced based on checksums
  • Transaction rollback on errors

🤖 Generated with Claude Code

Add service to sync template content (schticks, weapons, template characters) from master template campaign to existing campaigns. Enables updating long-running campaigns with latest images and content.

Features:
- Dry-run mode by default for safe preview
- Updates schticks/weapons by name match, preserving IDs
- Copies template characters (is_template: true)
- Attaches/replaces images based on checksum comparison
- Transaction-wrapped with rollback on error
- Detailed change logging and summary reporting

Usage:
  rails campaign:list
  rails campaign:sync_template[campaign-id]
  DRY_RUN=false rails campaign:sync_template[campaign-id]

Includes:
- CampaignTemplateSyncService with comprehensive RSpec tests (33 passing)
- Rake tasks for CLI usage
- Documentation in docs/TEMPLATE_SYNC_GUIDE.md

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant