`relation "action_text_rich_texts" does not exist` in CircleCI

Published 8th January 2020 at 05:50pm (Last Updated 14th April 2020 at 06:38pm)

Another short post about obscure errors. Ran into this weirdness yesterday/this morning:

rake aborted!
ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR:  relation "action_text_rich_texts" does not exist
LINE 8:  WHERE a.attrelid = '"action_text_rich_texts"'::regclass


Just came out of nowhere.


Everything I found online seemed to suggest that I simply needed to run the relevant migration or install ActionText again...


rails action_text:install


And that's perfectly reasonable when the error occurs in the dev environment. Sadly, this didn't work when I ran it here...


CircleCI: UndefinedTable


It's worth noting that at this point I already had a working CircleCI config and had already successfully run tests even after I'd added an ActionText::RichText column to an earlier table.


I tried experimenting with the rake tasks I'd already added in .circleci/config.yml but the error still wouldn't budge.


I was almost at my wit's end when I found the post below:


require 'factory_girl_rails' - https://discuss.circleci.com/t/pg-undefinedtable-error-relation-users-does-not-exist/4250


The post is a little old so when Nesokas refers to "factorygirl", they're actually referring to the factory_bot_rails gem (Thoughtbot changed the name - it was a whole thing). Following those instructions fixed the error message.


So in short, if you see that error, add

gem 'rspec-rails', '~> 4.0.0.beta2'

to your Gemfile, run the following in the terminal:

bundle

Add the this to spec/rails_helper.rb:

require 'factory_bot_rails'


And then push it to your branch


git add -A
git commit -m "Fix CircleCI error"
git push origin HEAD

The error should clear up in no time!



Anyway, props to Nesokas for working this out as it's a bizarre error to get and the solution is far from obvious. I would link to their social media but I can't really find them anywhere else so... ¯\_(ツ)_/¯

Post a comment

Posted by Anonymous on 27th July 2020 at 16:51:56

In my case I had run


rails action_text:install


Which had generated a fixture in test/fixtures/action_text. Once I deleted that everything worked again.

Posted by Jess on 24th August 2020 at 01:04:57

Hmm...I wonder if ActionText expects you to use MiniTest and is just prone to error when you use anything else. Stuff like that makes me glad I ditched it in the end.

Thanks for the comment! =]