spaanproductions/laravel-ai-usage
A Laravel package for tracking AI model usage, token consumption, and costs across your application. It helps log requests from AI providers, monitor spending, and gain visibility into usage through a simple, configurable integration.
Architecture fit: This package remains a standard Laravel package that ships publishable migrations and integrates via a service provider. The v0.1.6 change does not alter runtime architecture — it corrects the publish/migrate workflow so repeated vendor:publish --tag=ai-usage-migrations runs are idempotent (only new migrations are added rather than re-copying all under fresh timestamps).
Integration feasibility: Improves feasibility. The prior behavior caused php artisan migrate to fail on already-existing tables after any package update, which is a hard blocker in CI/CD and multi-environment promotion. Fixing this makes the package usable in an evolving codebase where the package version bumps between deploys. Feasible for a standard Laravel app on a single database; still requires the app to own its migration history.
Technical risk: Low-to-moderate. Core risks are procedural rather than code-level: teams that followed the v0.1.4 upgrade note must manually delete duplicated create_ai_usage_records_table and create_ai_usage_budget_alerts_table migrations that were never migrated. Left in place, those duplicate files will attempt to create tables that already exist and cause migration failures. There is also the general risk of a pre-1.0 package (0.1.x) changing publish semantics between patch releases, which signals the migration contract is not yet stable.
Key questions:
vendor:publish since v0.1.4 — i.e. where do we need cleanup?Stack fit: Unchanged — assumes Laravel with database-backed migrations, standard vendor:publish tags (ai-usage-migrations), and the usual migrate lifecycle. No new dependencies or framework version constraints are introduced by this patch.
Migration path: Straightforward but requires a deliberate cleanup step. On upgrade to v0.1.6:
composer update to pull v0.1.6.database/migrations for duplicated create_ai_usage_records_table and create_ai_usage_budget_alerts_table files carrying later timestamps.php artisan migrate to confirm a clean state.vendor:publish --tag=ai-usage-migrations and verify it is now additive/no-op when up to date.Compatibility: No API or schema changes are indicated; this is a tooling/publish-behavior fix. Applications that never re-published migrations after v0.1.4 are unaffected. Applications that did will have stale duplicate files that must be removed — treat this as a required pre-deploy checklist item rather than an optional tidy-up.
Sequencing: (1) Inventory duplicated files across local, staging, and production migration directories; (2) confirm which are unmigrated via migrate:status; (3) remove unmigrated duplicates in each environment, starting local → staging → production; (4) deploy v0.1.6; (5) validate migrate and migrate:status are clean; (6) only then begin regular package upgrades again. Do this before any further package version bumps, since the next publish would compound the duplicates.
Maintenance: Net positive long-term — future package upgrades no longer corrupt the migration set. Short-term maintenance cost is one cleanup pass per environment plus a documented procedure so the team doesn't recreate the problem on branches that still reference v0.1.4 behavior.
Support: Low support surface; the change reduces a class of "migrate fails on existing table" tickets. The main support need is an internal runbook for the duplicate-migration cleanup and clarity on who owns the audit per environment. Pre-1.0 status means publish-behavior changes should be watched release-to-release.
Scaling: No impact on runtime scaling or query performance. Scales fine with additional environments, provided each environment's publish step is audited rather than assumed idempotent in older versions.
Failure modes: Primary failure mode is a stale duplicate migration surviving in an environment and blocking migrate at deploy — highest risk in long-lived staging/production databases where the v0.1.4 publish already happened. Secondary failure mode is deleting the wrong file (a duplicate that is recorded as migrated), which would cause migration history drift; the release note's "not yet migrated" qualifier is the safeguard and must be verified with migrate:status, not assumed. A third, lower-probability risk is that a team skips the cleanup, upgrades, publishes again, and ends up with compounding duplicates that are harder to untangle.
Ramp-up: Minimal for engineers already familiar with Laravel migrations; the only new concept is idempotent publishing. Budget roughly an hour per engineer to read the release note and run the cleanup, plus a short team note that vendor:publish is now additive and safe to re-run. No new tooling or training required.
How can I help you explore Laravel packages today?