0

I made a mistake in my migration file and I deleted and then tried running the migration again and now I'm getting an activerecord::pendingmigrationerror when I load localhost:3000 but when I try to run rails:db migrate again its keeps canceling with this message:

Jerrys-MacBook-Air:nameofapp jerryhoglen$ rails db:migrate --trace

** Invoke db:migrate (first_time)

** Invoke environment (first_time)

** Execute environment

** Invoke db:load_config (first_time)

** Execute db:load_config

** Execute db:migrate == 20161227120926 AddAdminFlagToUsers: migrating ============================== -- add_column(:users, :admin, :boolean, {:default=>false, :null=>false}) rails aborted! StandardError: An error has occurred, this and all later migrations canceled: SQLite3::SQLException: duplicate column name: admin: ALTER TABLE "users" ADD "admin" boolean DEFAULT 'f' NOT NULL"

Cant figure it out! please help

Community
  • 1
  • 1
Jerry Hoglen
  • 111
  • 1
  • 10

1 Answers1

0

You can run rake db:drop then rake db:create && rake db:migrate to set up a new local database or insert the value 20161227120926 into the schema_migrations table.

355E3b
  • 84
  • 3
  • If i insert the value into the schema_migrations table what do i do after that? Im still getting an error thats theres a migration pending – Jerry Hoglen Dec 28 '16 at 00:08
  • Is it the same pending error? If so I would just rebuild your development database. – 355E3b Dec 28 '16 at 11:35
  • Hey thanks for the help, I ended up just rebuilding the database but when i push to heroku im getting an error that the page wont load when logged in as the admin because of undefined method? – Jerry Hoglen Dec 28 '16 at 17:45
  • I'm adding my github and heroku app if someone would take a look and help me out that would be awesome. Im very new to this and feel a little lost! https://github.com/jerryhoglen/bikesiteapp2016 and https://bikesiteapp2016.herokuapp.com/ – Jerry Hoglen Dec 28 '16 at 17:50