level-up-upgrade-v3

Migrates Laravel applications from cjmellor/level-up v2.x to v3.0 by applying all breaking changes.

673|54|Updated Apr 3, 2023
One-click install
npx skills add https://github.com/cjmellor/level-up --skill level-up-upgrade-v3
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: level-up-upgrade-v3
Source: https://github.com/cjmellor/level-up/tree/main/resources/boost/skills/level-up-upgrade-v3
Command: npx skills add https://github.com/cjmellor/level-up --skill level-up-upgrade-v3

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Upgrading the cjmellor/level-up Laravel gamification package from v2.x to v3.0 involves many breaking changes—removed models, renamed methods, new config keys, and changed leaderboard return types—that are tedious and error-prone to apply manually across a codebase.

Core Features & Use Cases

  • Automated Code Migration: Rewrites Multiplier::scopeTo() calls into scopeToUser/scopeToTier, replaces UserForeignKey::on() with the userForeignId() Blueprint macro, and updates leaderboard consumers to the new LeaderboardEntry shape.
  • Config and Migration Handling: Updates published config/level-up.php (new models bindings, typed multiplier pivot tables, removed keys) and runs the v3 migrations that backfill challenge_completions and convert multiplier_scopes into typed pivots.
  • Behavioral Audits: Flags setPoints() callsites affected by the new level-recalculation behavior, removes obsolete addPoints() exception handlers, and resolves trait method collisions on the User model.
  • Use Case: A developer runs composer require cjmellor/level-up:^3.0, then uses this Skill to systematically find and fix every breaking change, run the migrations, and verify the test suite passes.

Quick Start

Upgrade my Laravel app from cjmellor/level-up v2 to v3 and apply all the breaking changes to my codebase.

Frequently Asked Questions about level-up-upgrade-v3

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I upgrade cjmellor/level-up from v2 to v3?

Update the composer constraint to ^3.0, run composer update, then apply the breaking changes: rewrite scopeTo() calls, update the published config's models array, replace UserForeignKey usage, and update leaderboard consumers to LeaderboardEntry objects. Finally publish and run the new migrations and run your test suite.

What breaking changes are in level-up v3?

Leaderboard::generate() now returns LeaderboardEntry objects instead of User models, MultiplierScope is replaced by typed multiplier_user and multiplier_tier pivots, scopeTo() becomes scopeToUser/scopeToTier, the level-up.table config key is removed, and auditing defaults to enabled.

Does level-up v3 work with MySQL 5.7?

No, v3 leaderboard ranks are computed with SQL window functions, which require MySQL 8+, SQLite 3.25+, MariaDB 10.2+, or PostgreSQL. MySQL 5.7 cannot run v3 leaderboard queries, though other package features may still work.

What happens to my multiplier_scopes data when upgrading to v3?

A migration automatically converts multiplier_scopes rows into the new multiplier_user and multiplier_tier typed pivot tables and drops the old table. Rows with unrecognized scopeable_type values are skipped with a logged warning, so back up your database first.

Why does addPoints() no longer throw an exception in level-up v3?

In v3, addPoints() caps the user at the highest level instead of throwing the 'Points exceed the last level' exception. You should remove any catch blocks handling that exception or convert them into level-cap checks.

Can I upgrade from level-up v1 directly to v3?

No, you should first upgrade from v1.x to v2.x using the level-up-upgrade-v2 skill, then run the v2-to-v3 upgrade. The v3 migration steps assume the codebase is already on v2.x.