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

relation "pg_stat_statements_info" already exists #835

Open
scarroll32 opened this issue Dec 11, 2021 · 2 comments
Open

relation "pg_stat_statements_info" already exists #835

scarroll32 opened this issue Dec 11, 2021 · 2 comments

Comments

@scarroll32
Copy link
Contributor

scarroll32 commented Dec 11, 2021

Recently something wierd has been happening with this gem for me.

After I run a migration, I see this in the schema.rb

  create_view "pg_stat_statements_info", sql_definition: <<-SQL
      SELECT pg_stat_statements_info.dealloc,
      pg_stat_statements_info.stats_reset
     FROM pg_stat_statements_info() pg_stat_statements_info(dealloc, stats_reset);
  SQL

If I then run rake parallel:setup, I get an error:

Caused by:
PG::DuplicateTable: ERROR:  relation "pg_stat_statements_info" already exists
/Users/sean/immersive/immersive/db/schema.rb:926:in `block in <main>'
/Users/sean/immersive/immersive/db/schema.rb:13:in `<main>'

If I comment out the statement in schema.rb it works fine, but the comments are overwritten after each new migration.

@grosser
Copy link
Owner

grosser commented Dec 12, 2021

not sure what comments you are talking about

sounds like it runs the migration against the same db twice maybe ?
try with an older/newer version of a gem to verify that it's not a regression or already fixed

@scarroll32
Copy link
Contributor Author

scarroll32 commented Dec 28, 2021

Updated to 3.7.3 but it is still happening. No-one else is reporting it so it must be something specific to my own setup.

❯ be rake parallel:setup
rake aborted!
ActiveRecord::StatementInvalid: PG::DuplicateTable: ERROR:  relation "pg_stat_statements_info" already exists
/Users/sean/immersive/immersive/db/schema.rb:926:in `block in <main>'
/Users/sean/immersive/immersive/db/schema.rb:13:in `<main>'

Workaround is to comment out the creation of the pg_stat_statements_info view in schema.rb.

  add_foreign_key "testimonials", "users"
  add_foreign_key "thanks", "corrections"
  add_foreign_key "thanks", "users"

  #create_view "pg_stat_statements_info", sql_definition: <<-SQL
  #    SELECT pg_stat_statements_info.dealloc,
  #    pg_stat_statements_info.stats_reset
  #   FROM pg_stat_statements_info() pg_stat_statements_info(dealloc, stats_reset);
  #SQL

I am using the Scenic gem, I wonder if there is some conflict there.

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