I am getting an error while migrating a database. The error is:
PG::UndefinedColumn: ERROR: column roles.deleted_at does not exist
LINE 1: SELECT "roles".* FROM "roles" WHERE ("roles"."deleted_at" I...
^
: SELECT "roles".* FROM "roles" WHERE ("roles"."deleted_at" IS NULL)
Here is my part of schema.rb:
create_table "roles", :force => true do |t|
t.string "name"
t.string "title"
t.integer "resource_id"
t.string "resource_type"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.datetime "deleted_at"
end
I tried to make:
rails generate migration AddDeletedAtToRoles deleted_at
But it did not help.
Sometimes what I do in order to get rid of these inconsistent database states is, if it's a simple fix, go into the actual database and fix manually whatever seems to be the problem in order to get migrations going again.
In your case it seems like you are missing the deleted_at
column in the roles table. So what you could do is create the column yourself. In order to do that in Postgres you would need to do something like:
psql your_database_name
once you are in there Alter your roles
table and add the column you are missing using the following command.ALTER TABLE roles ADD COLUMN deleted_at date;
Hope that helps.