0

I'm trying to debug a problem I am having with migrating my db.

I had my application running without issue, and pushed it to heroku, and ran rake db:migrate and got the error

PG::Error: ERROR: relation "places" does not exist
LINE 4: WHERE a.attrelid = '"places"'::regclass
^
: SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull
FROM pg_attribute a LEFT JOIN pg_attrdef d
ON a.attrelid = d.adrelid AND a.attnum = d.adnum
WHERE a.attrelid = '"places"'::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum

I found it very strange that the migrations were fine locally, but not when migrating on the server. I found a few other people had had similar problems, but never found that anybody had a solution. No answers I found on StackOverflow had been accepted. After a few hours of trying different things, I thought I'd try to create a new heroku app from scratch and push my app to it (that worked for somebody else), basically starting fresh.

When I did that, I got the same error, but now on the wineries.

Weird, on the recommendation of Heroku, I tried creating a new db locally, and running my migrations.

Now locally, I get the same error, but on the table admin_users.

I'm pretty sure there is nothing wrong with the actual migration files, as each time I run the migration, I get a different table and therefore in some ways a different migration which is being affected.

I've tried removing a few gems, but still et the same error.

Does rake:db look outside any files other than the migration files? Could this be a relationship issue?

Any other suggestions on how to resolve this?

1 Answer 1

1

Are you accessing/using any models in your migrations to do any data updates? Are you using any models in anything in config/initializers? rake db:migrate loads the rails environment so if you try and access a model that doesn't exist yet it will spit this error out...

1
  • Thanks Philip, I didn't have anything in my initializers but your routes are loaded in the environment as well (it appears) and it turns out that active_admin adds two lines to the routes ActiveAdmin.routes(self) devise_for :admin_users, ActiveAdmin::Devise.config which was causing the problem.
    – pedalpete
    Jan 3, 2013 at 22:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.