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

New install error: relation "heya_steps" does not exist #145

Closed
acallaghan opened this issue Oct 14, 2021 · 4 comments
Closed

New install error: relation "heya_steps" does not exist #145

acallaghan opened this issue Oct 14, 2021 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@acallaghan
Copy link
Contributor

acallaghan commented Oct 14, 2021

Hey there, I've been integrating Heya with our app, and came across this issue. I have added the gem and run the installation commands and migration. I then setup my first campaign.

However, when I run the campaign scheduling rake task, I get this error:

$ rails heya:scheduler 
rails aborted!
ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR:  relation "heya_steps" does not exist
LINE 1: ...M "public"."heya_campaign_memberships" INNER JOIN "heya_step...
                                                             ^
Caused by:
PG::UndefinedTable: ERROR:  relation "heya_steps" does not exist
LINE 1: ...M "public"."heya_campaign_memberships" INNER JOIN "heya_step...
                                                             ^

Tasks: TOP => heya:scheduler
(See full trace by running task with --trace)

A --trace led me to the lines:

lib/heya/campaigns/scheduler.rb:21:in `run'
lib/tasks/heya_tasks.rake:6:in `block (2 levels) in <main>'

It looks like these files are referring to a table called heya_steps, and referenced in a few places like:

scope :with_steps, -> {
  joins(
    %(INNER JOIN "heya_steps" ON "heya_steps".gid = "heya_campaign_memberships".step_gid)
  )
}

This table isn't in the generator for the installation migration, so not sure where this should come from? Any ideas would be welcome!

I'm using Rails 6.1, Ruby 3.0.1 and postrges 13.3

Thanks in advance,
Andy

@joshuap
Copy link
Member

joshuap commented Oct 19, 2021

@acallaghan hey thanks for the bug report. We use some magic to make the heya_steps table available in heya queries (I try to avoid this type of thing as much as possible but it's part of what makes Heya's Ruby configuration approach work):

https://github.com/honeybadger-io/heya/blob/master/lib/heya/active_record_extension.rb

Can you check to see if that extension is being loaded? You can use bundle open heya if you want to add some debugging output. This library is tested with Rails 6.1 and Ruby 2.6. I'll bump CI to Ruby 3 to see if there are any issues there. It's possible there is a bug in the extension that is not recognizing the query to heya_campaign_memberships or something.

@joshuap joshuap added the bug Something isn't working label Oct 19, 2021
@joshuap joshuap self-assigned this Oct 19, 2021
@acallaghan
Copy link
Contributor Author

Ah, it could be that I'm using the Apartment gem for multi-tenant schemas, I think the two are conflicting - the "public"."heya_campaign_memberships" table in the public schema, but the "heya_steps" table is being defined without a schema. I think this is it anyway.

I might come back to this gem once I've removed Apartment, as I'm pretty sure that's the cause

Thanks anyway

@kimili
Copy link

kimili commented Jul 2, 2024

Hi @joshuap! Just a heads up on this old issue. It looks like if you try to set up campaigns in subdirectories of the app/campaigns folder, you'll hit this issue. Not sure if that's something worth investigating, or at least make a note of in the docs.

@joshuap
Copy link
Member

joshuap commented Jul 22, 2024

Hi @joshuap! Just a heads up on this old issue. It looks like if you try to set up campaigns in subdirectories of the app/campaigns folder, you'll hit this issue. Not sure if that's something worth investigating, or at least make a note of in the docs.

@kimili thanks! I created a new issue to remind myself to investigate this when I have the time. 😁

#264

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants