Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transition migration generator doesn't run because model doesn't exist #546

Open
simmerz opened this issue Sep 6, 2024 · 0 comments
Open

Comments

@simmerz
Copy link

simmerz commented Sep 6, 2024

When running bin/rails g statesman:active_record_transition DirectDebitMandate DirectDebitMandateTransition (yes, I'm making a model to hold a DD mandate using Statesman - very meta), the DirectDebitMandate model file already exists, but the DirectDebitMandateTransition one is due to be created.

However, the in the migration that creates the table (which happens before the model file is created), there is this line which requires the model file to already exist.

My proposal would be to switch the order of the migration and model template lines in the generator file so that the file does exist when the migration is being created.

EDIT: A quick test of this suggests that the class isn't loaded in so the migration still fails to generate.

EDIT 2: Is there a reason why https://github.com/gocardless/statesman/blob/master/lib/statesman/adapters/active_record.rb#L10 doesn't just use ApplicationRecord.connection.respond_to?(:supports_partial_index?) rather than going from the model?

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

No branches or pull requests

1 participant