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

Additional index annotation to other table with same name but with prefix #967

Open
choosen opened this issue Aug 16, 2022 · 1 comment
Open

Comments

@choosen
Copy link

choosen commented Aug 16, 2022

Annotate is adding us additional indexes to other table with same name but with prefix.

Cause:
#405 provided code to remove table_name_prefix on index annotate, as some people have problem with public. prefix @ postgres.
Fixing prefix this way maybe can be valid but is not universal.

We use table_name_prefix for domain module table prefixes like this:

module AccessControlSystems
  class BaseModel < ApplicationRecord
    self.abstract_class = true

    def self.table_name_prefix
      'access_control_systems_'
    end
  end
end
(...)
#
# Indexes
#
#  index_locations_on_contact_user_id  (contact_user_id) # <<<< it should not be here 
#
module AccessControlSystems
  class Location < BaseModel
  end
end

and we have common location table without table prefix:

(...)
#
# Indexes
#
#  index_locations_on_contact_user_id  (contact_user_id)
#
# Foreign Keys
# (...)  Foreign keys are fine
class Location < ApplicationRecord
end

We can also define table_name_prefix in AccessControlSystems::Location and the issue will be there

Commands

We annotate on migrate:

rake db:migrate

Version

  • annotate version 4.2.0 (4.1.X)
  • rails version 5.2.6
  • ruby version 2.6.9
@filipegiusti
Copy link

I have the exact same issue.

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

2 participants