Reputation: 435
I ran rake db:migrate
and I'm getting the following error:
Mysql2::Error: Table 'sdk_wizard_sessions' already exists: CREATE TABLE `sdk_wizard_sessions` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `using_mediation` tinyint(1) DEFAULT 0 NOT NULL, `user_id` int(11) NOT NULL, `selected_networks` text NOT NULL, `selected_games` text NOT NULL, `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL) ENGINE=InnoDB/Users/me/.rvm/gems/ruby-1.9.3-p547@global/gems/activerecord-3.2.15/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:245:in `query'
I've looked on stackoverflow and it seems like no one has a good solution for this. Does anyone know how to fix this?
Upvotes: 0
Views: 236
Reputation: 8826
The table already exists.... Either drop the table
rails g migration DropSdkWizardSession
and enter the following code in the created migration
class DropSdkWizardSession < ActiveRecord::Migration
def change
drop_table :sdk_wizard_sessions
end
end
or you could alter the current table so that it looks like the table you were trying to create (I think the better of the three options)
rails g migration ChangeSdkWizardSession
and add this code to the created migration
class ChangeSdkWizardSession < ActiveRecord::Migration
change_table :sdk_wizard_sessions do |t|
t.remove :description, :name #this will remove columns named :description or :name
t.string :part_number #this will add column of type string, called :part_number
t.index :part_number #this will add an index for column :part_number
t.rename :upccode, :upc_code #this would rename column :upccode, to :upc_code
end
end
or you could create an new table and name it something different (lazy option)
Upvotes: 2