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

Cannot add indexes or foreign keys #1025

Open
istrasci opened this issue Jul 26, 2024 · 0 comments
Open

Cannot add indexes or foreign keys #1025

istrasci opened this issue Jul 26, 2024 · 0 comments

Comments

@istrasci
Copy link

I see the options --show-indexes and --show-foreign-keys, but if I run annotate with them, I cannot get it to work. What is annotate looking for to be able to include these in the annotations? Is it looking at the DB migrations? Is it looking at belongs_to associations in the models? Both? Something else?

My migrations contains t.index statements within the create_table calls, as well as add_foreign_key statements as necessary. My models are for legacy tables and don't use the default :id column, so in the belongs_to associations I must use :foreign_key to specify the column. Like:

class MyModel
  belongs_to :other_model, class_name: 'OtherModel',
    primary_key: 'other_model_code',
    foreign_key:  'my_model_code',
    inverse_of: 'my_model'
end

So I'm not sure if I have something set up incorrectly, or if I'm possibly doing something else wrong. I'd appreciate any help.

Commands

$ bundle exec annotate --models --show-indexes --show-foreign-keys

Version

  • annotate version: 3.2.0
  • rails version: 7.0.8.3
  • ruby version: 3.3.1
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