Rails 5 adding admin flag to users but deleted migration and

272 views Asked by At

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

1

There are 1 answers

4
355E3b On

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.