I have a problem with the connection between MySQL and Ruby on rails.
I have a database in MySQL, and I need to migrate it to ActiveRecord in Ruby on rails. To do that, I have to change the database.yml file in my ruby on rails project, like this:
# SQLite version 3.x
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
#
default: &default
adapter: sqlite3
pool: 5
timeout: 5000
development:
adapter: mysql2
database: ********
username: ******
password: ******
host: *******
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
database: db/test.sqlite3
production:
<<: *default
database: db/production.sqlite3
Obviously, the *
characters are information I don´t need to show, but it's properly constructed, and the connection is established as usual.
The problem comes in Ruby on rails console. The migration isn't run properly, and all the IDs are null, regardless of the table I need to migrate. For example, I take this from a table:
All the ID are null, in any table, so I can't, for example, list the last User I introduced in the database, because I would need to do a Order by with the ID. In the Gemfile, I have the gem mysql2
.
What am I doing wrong?