Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
Ask Question
I'm using an existing Postgres database for a rails 6 project. When I do some ActiveRecord queries like
User.all()
, I run into the following error
ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: relation "pg_range" does not exist
LINE 3: LEFT JOIN pg_range as r ON oid = rngtypid
After some googling. I found that pg_range
was introduced in PostgreSQL 9.2. My existing database was upgraded from an older version (8.x, if I remembered correctly). Was that the reason I ran into this issue. How can I fix it?
Any PostgreSQL database of version 9.2 or above will always have a pg_catalog.pg_range
table, be it upgraded from an older version or not.
There are two possible explanations for your error:
You are inadvertently working with a PostgreSQL database of version 9.0 or lower.
You somehow managed to corrupt the system catalogs by dropping pg_range
. There are safeguards against that, so that's nothing that can happen by mistake.
–
–
–
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.