LearningRoR
LearningRoR

Reputation: 27192

Rake db:migrate aborted! Ghost development database using MySQL2?

OK, I just re-installed MySQL Servers 5.5(32bit to 64bit) on my Windows 7 64-bit machine. I then took the steps to use mysql2 for rails:

gem 'mysql2', '0.2.6'
gem 'rails', '3.0.7'

Step 1:

rake db:drop
Couldn't drop store_development : #<Mysql2::Error: Unknown database 'store_development'>

Strange because in the MySQL Workbench I only see the test database up.

Step 2:

$ rake db:migrate
rake aborted!
Unknown database 'store_development'

No idea why I get this error so I try to reset the database now.

Step 3:

rake db:reset
(in C:/store)
Couldn't drop store_development : #<Mysql2::Error: Unknown database 'store_development'>
store_test already exists
-- create_table("business_online_stores", {:force=>true})
   -> 0.1110s
-- create_table("business_retail_stores", {:force=>true})
   -> 0.0740s
-- create_table("businesses", {:force=>true})
   -> 0.0900s
-- create_table("products", {:force=>true})
   -> 0.0810s
-- create_table("user_prices", {:force=>true})
   -> 0.0720s
-- create_table("users", {:force=>true})
   -> 0.1810s
-- initialize_schema_migrations_table()
   -> 0.2800s
-- assume_migrated_upto_version(0, "db/migrate")
   -> 0.0320s
You have 6 pending migrations:
  20110909175650 DeviseCreateUsers
  20110929161120 CreateUserPrices
  20111004023516 CreateProducts
  20111007023521 CreateBusinesses
  20111009215120 CreateBusinessRetailStores
  20111009215419 CreateBusinessOnlineStores
Run "rake db:migrate" to update your database then try again.

Yes, the Test database does already exist but where is this Ghost development database at? How does it reset the migrations, yet tell me to migrate them again. Ok, ill do as it says now:

Step 4:

$ rake db:migrate
(in C:/store)
==  DeviseCreateUsers: migrating ==============================================
-- create_table(:users)
rake aborted!
An error has occurred, all later migrations canceled:

Mysql2::Error: Table 'users' already exists: CREATE TABLE `users`

Step 5:

$ rake db:migrate
rake aborted!
Unknown database 'store_development'

Impossible, I went inside of my MySQL Workbench and dropped the test and development databases by right-clicking them and going through the necessary steps so nothing exist even when I refresh it, yet I get this error about a database that doesn't exist.

How do I fix this problem?

Note: 0.2.7 Gives me the same issues.

Note: These are my first 2 migration files just encase anyone wanted to see them: https://gist.github.com/1341682

Upvotes: 0

Views: 1272

Answers (2)

LearningRoR
LearningRoR

Reputation: 27192

The only way to solve this that I know of was to recreate my whole application.

Upvotes: 0

Perry Horwich
Perry Horwich

Reputation: 2846

Just a thought, but does Users already have entries in the email column? I wonder if an existing duplicate entry would prevent the addition of the validation :unique=>true

And just to check, did you want to do?:

add_column :users, :email, :string

instead of add_index?

Upvotes: 1

Related Questions