I wrote a migration with the following:
class CreateTableSomeTable < ActiveRecord::Migration[5.1]
def change
create_table :some_tables do |t|
t.references :user, foreign_key: true
t.references :author, references: :user, foreign_key: true
t.text :summary
end
end
end
It is a basic migration that is creating a database table. However: when I run rails db:migrate
a very odd error message aborts the migration:
Mysql2::Error: Table 'my_database.some_tables' doesn't exist: SHOW FULL FIELDS FROM 'some_tables'
It is as if the error is saying it can't create the table because the table does exist, which doesn't make sense.
Things I have looked at and tried:
- reviewed the database.yml which seems fine. Nothing has changed, and I have recently run other migrations just fine (though no migrations that created database tables)
- ran
bundle
to ensure all gems were installed - deleted the
schema.rb
file, recreated the database with data from another copy, and I ranrake db:schema:dump
to recreate theschema.rb
file. I attempted to run the migration again and still got the same error.
I am using rails 5.1.1
as well as mysql2 0.4.6
Any tips on how I can get the migration to run?