Skip to content

Conversation

@janko
Copy link
Contributor

@janko janko commented Dec 10, 2025

Active Record migrations define method_missing that delegates any unknown methods to the underlying connection adapter. That means that implementing autocompletion of schema statements is mostly achieved by completing connection adapter methods.

Because Active Record migrations inherit from ActiveRecord::Migration[<version>], which is not a direct class reference, I couldn't use NodeContext#nesting, as that returns strings. I had to inspect the nesting nodes in Prism, which is available via the @nesting_nodes variable. Maybe we could define a public NodeContext#nesting_nodes attribute reader?

I implemented a server call that returns database configurations, so that I can map the migration directory to the corresponding connection adapter, in case multiple database adapters are used.

ActiveRecord::Migration implements a few additional methods (e.g. reversible), and it would be nice to have TableDefinition/AlterTable completion in create_table/change_table blocks at some point, but I wanted to first tackle the primary functionality.

Closes #444

@janko janko requested a review from a team as a code owner December 10, 2025 22:53
@janko janko force-pushed the activerecord-migration-completion branch from e0a5c1e to 18acd38 Compare December 11, 2025 20:24
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.

Support completion of migration methods

1 participant