Skip to content

fix: migration class names must match the RcrewAI acronym inflection - #25

Merged
gkosmo merged 1 commit into
masterfrom
fix/migration-class-inflection
Aug 13, 2026
Merged

gkosmo merged 1 commit into
masterfrom
fix/migration-class-inflection

Conversation

@gkosmo

@gkosmo gkosmo commented Aug 13, 2026

Copy link
Copy Markdown
Owner

Reported by a user installing 0.7.0. Following the documented install verbatim fails:

NameError: uninitialized constant CreateRcrewAITables

Cause

The engine registers an RcrewAI acronym inflection — Zeitwerk needs it to resolve rcrewai/rails/span.rb to RcrewAI::Rails::Span, so it cannot simply be removed.

That same inflection makes Rails camelize create_rcrewai_tables to CreateRcrewAITables, while the shipped migrations declared CreateRcrewaiTables. Rails resolves a migration's class from its filename, so rails db:migrate raises NameError.

Nine of eleven migrations in db/migrate were affected, plus the install template — every one whose name contains rcrewai. This broke both paths: fresh installs via the generator, and upgrades via rcrew_ai_rails:install:migrations.

Why the tests missed it

Two compounding gaps, both now closed:

  1. The generator spec claimed to check "the Rails migration filename convention" but hardcoded CreateRcrewaiTables — the wrong name. It asserted the bug was correct and passed while the gem was broken.
  2. My end-to-end verification called CreateRcrewaiTables.new.exec_migration directly after load. Referring to the class by name skips the filename→constant resolution entirely, which is exactly where the failure lives.

Fix

  • All 9 affected db/migrate files and the install template now declare the name Rails derives.
  • spec/migrations_spec.rb (new) checks every shipped migration, deriving the expected name via ActiveSupport::Inflector rather than hardcoding it — so it stays correct if the inflection changes.
  • spec/real_migrate_spec.rb (new) runs the generated migration through ActiveRecord::MigrationContext#migrate, the real resolution path.
  • The generator spec's hardcoded assertion is replaced with a derived one.

Verified

Mutation-tested: restoring the 0.7.0 class name makes the new spec fail with the user's exact error —

expected no Exception, got #<NameError: uninitialized constant CreateRcrewAITables

221 examples, 0 failures.

Release

Bumps to 0.7.1. The CHANGELOG tells anyone already on 0.7.0 that a hand-renamed class needs no action, and otherwise to delete the copied migration and re-run the install.

The engine registers an RcrewAI acronym so Zeitwerk resolves
rcrewai/rails/span.rb to RcrewAI::Rails::Span. That same inflection makes
Rails camelize create_rcrewai_tables to CreateRcrewAITables, but the
migrations declared CreateRcrewaiTables. Rails resolves a migration class
from its filename, so rails db:migrate raised NameError on a verbatim
install of 0.7.0.

Nine db/migrate files and the install template were affected. The prior
generator spec hardcoded the wrong name and so asserted the bug was
correct; it now derives the expected name the way Rails does, and a new
spec runs the generated migration through ActiveRecord::MigrationContext
- the resolution step a hand-rolled load-and-call skips.
@gkosmo
gkosmo merged commit b158b96 into master Aug 13, 2026
3 checks passed
@gkosmo
gkosmo deleted the fix/migration-class-inflection branch August 13, 2026 09:45
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