Search code examples
ruby-on-railsexternaldatabase-schemamysql2

Related to External database connectivity in rails


After linking an external mysql database using database.yml and have also installed mysql2 and activerecord-mysql2-adapter gems.

When I run rails db:schema:dump

The Schema looks like this.

Schema.rb

# This file is auto-generated from the current state of the database. Instead of editing this file, please use the migrations feature of Active Record to incrementally modify your database, and then regenerate this schema definition. Note that this schema.rb definition is the authoritative source for your database schema. If you need to create the application database on another system, you should be using db:schema:load, not running all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations you'll amass, the slower it'll run and the greater likelihood for issues).
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 0) do

  # Could not dump table "employees" because of following NoMethodError 
  #   undefined method `sql_type' for "int(11)":String

end

And also I'm running into this problem when I run rails db:schema:dump:

/home/admin/.rvm/gems/ruby-2.4.2/gems/activerecord-mysql2-adapter-0.0.3/lib/active_record/connection_adapters/mysql2_adapter.rb:606: warning: constant ::Fixnum is deprecated

database.yml

development: &default
adapter: mysql2
encoding: utf8
pool: 5
host: localhost
username: Ruby
password: *****
port: 3306
socket: /var/lib/mysql/mysql.sock
database: rubyappdb

Solution

  • The problem was with the activerecord-mysql2-adapter gem. Commenting it out in the Gemfile and running bundle install solved the problem. I hope it wont cause any problems in the future.