Reputation: 6639
OS: Ubuntu 14.04
Rails: 3.2.18
Ruby: 2.15
I inherited a Rails application, and I am having some issues with the migration.
When I try to run the latest migration, I get the following error message:
== CreateBillingComments: migrating ==========================================
-- create_table(:billing_comments, {:id=>false})
rake aborted!
StandardError: An error has occurred, all later migrations canceled:
Mysql2::Error: Table 'billing_comments' already exists:
CREATE TABLE `billing_comments`
The table billing_comments does exist, but the problem is that I cannot find the string billing_comments anywhere in any of the source code files (and that include migration files, views, controller, models, etc.).
The table is not being used, so I would like to erase it, and all references to it in the code. My concern is that if I simply delete the table, I will only have partially solved the problem.
I also looked for CreateBillingComments, to no avail.
Running rake db:schema:dump produced a new schema.rb, with the following in it:
create_table "billing_comments", :force => true do |t|
t.string "ticket_id"
t.text "content"
t.string "user_id"
t.string "slug"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
But this is the only place now where billing_comments appears.
Where could this information coming from?
Upvotes: 2
Views: 57
Reputation: 11235
At some point in your database's history the billing_comments
table was created, by a Rails migration or otherwise. You can simply add a guard to your migration to prevent recreating the table if it already exists:
unless table_exists? :billing_comments
create_table(:billing_comments, {:id=>false})
end
Note that you may still need to remove the id
column if it's already present in your billing_comments
table.
Upvotes: 2