0

I need some help getting my Cloud 9/Rails environment working again for an online course I'm working on through Upskill. I ran into a problem with one section and ended up rolling back to a previous commit. However, since I did that, I've run into some database errors I haven't been able to resolve.

Here is what I get when I try to access my app:

ActiveRecord::PendingMigrationError Migrations are pending. To resolve this issue, run: bin/rails db:migrate RAILS_ENV=development

I've tried the suggested method to resolve it, but it hasn't worked, nor have a dozen other suggestions I've found in other threads with a similar message.

Below is what I see when I run rails db:migrate:status. So I believe maybe it has something to do with the third item there.

Status Migration ID Migration Name

up 20170331144924 Create contacts

up 20170406172755 Devise create users

down 20170410151911 Add devise to users

I am really lost but just hoping to get back to where I was so I can continue with the lessons. Thank you.

  • 3
    Will you detail the "half-a-dozen other suggestions"? We can't help very well if we don't know what you have or haven't tried. – Kevin Brown Apr 10 '17 at 18:39
  • Most of the suggestions have involved deleting the database and recreating it, which I've tried several times but I still get the same error. I have tried several variations of rails db:migrate to no avail. So just not sure what else to try. – carelessdonkey Apr 10 '17 at 19:02
  • If you don't care about the db data, you may just need to `rake db:drop db:create db:migrate`. Or, you may need to delete that file, take a look in the db/migrate folder and post what's in there. It looks like it wants to run that migration. – Mark Swardstrom Apr 10 '17 at 19:02
  • You can also do `rake db:schema:load` and just delete the migrations files. – Eyeslandic Apr 10 '17 at 19:10
  • Thanks, I think I'm getting closer but when I run rake db:migrate I get this message: == 20170410192514 AddDeviseToUsers: migrating ================================= -- change_table(:users) rails aborted! StandardError: An error has occurred, this and all later migrations canceled: SQLite3::SQLException: no such table: users: ALTER TABLE "users" ADD "email" varchar DEFAULT '' NOT NULL – carelessdonkey Apr 10 '17 at 19:26
  • 1
    From that error message, it looks as if you are missing a migration that is supposed to create the users table. Are you sure you aren't missing a migration somewhere, that you either deleted or forgot to write? – Frost Apr 10 '17 at 20:06
  • I am now missing the Devise create users table somehow. I'm not sure how to get it back. I tried running the commands the course instructed when installing Devise but that didn't seem to work. The information I used to install Devise was at this [link]( http://upskillcourses.com/courses/119763/lectures/1746936) – carelessdonkey Apr 10 '17 at 20:43
  • Thanks for the suggestions. I'm just going to go back to a previous branch before I got to Devise and see if I can just start from Square One. – carelessdonkey Apr 10 '17 at 21:01

2 Answers2

1

What worked for me was:

rake db:test:purge
rake db:test:prepare
gmm
  • 943
  • 1
  • 17
  • 30
0

Have you tried running a specific migration which is down like this? Ref

rake db:migrate:up VERSION=20170410151911
Community
  • 1
  • 1
Md. Farhan Memon
  • 6,055
  • 2
  • 11
  • 36