gespinha
gespinha

Reputation: 8487

Migration runs but table is not created

I am running the following migration:

class CreateUsers < ActiveRecord::Migration

  def up
    create_table :users do |t|
      t.column "first_name", :string, :limit => 25
      t.string "last_name", :limit => 50
      t.string "email", :default => "", :null => false
      t.string "password", :limit => 40

      # t.datetime "created_at"
      # t.datetime "updated_at"
      t.timestamps
    end
  end

  def down
    drop_table :users
  end

end

But after running rake db:migrate, even though the log shows this:

== 20150705121953 CreateUsers: migrating ======================================
-- create_table(:users)
   -> 0.0013s
== 20150705121953 CreateUsers: migrated (0.0013s) =============================

When I go to the mysql console and run SHOW TABLES; it displays:

mysql> USE my_db;
Database changed
mysql> SHOW TABLES;
    Empty set (0.00 sec)

If I have the migration create the users table, why does the database not show a single table?

Upvotes: 0

Views: 48

Answers (1)

Joe Dayvie
Joe Dayvie

Reputation: 314

This may seem silly but do you have MySQL imported into the rails application? I believe it automatically is setup for SQLite3. I had this issue when I began and have since removed it. It should show this information in the database.yml file.

Joe

Upvotes: 1

Related Questions