I've created a table in a SQL Server database using a migration,
successfully.
I've tried to change the name of a column in the table and got the
error message above when running 'rake db:migrate'.
Previously I have developed using MySQL and Sqlite and migrations have
worked successfully. This is an error I have not seen before.
Has anybody seen this and worked around it?
Hassan,
Thanks for the reply.
No, I didn't edit an existing migration - I created a new one for the
rename.
I understand what you are saying about dropping the table (not the
entire db surely :-0). While that would work, I wouldn't get to
understand what the problem is!!
Yes, I agree that the second migration seems to be trying to re-create
the schema table.
The database is a legacy SQL Server db with over 100 tables already in
existence.
I've noticed that db/schema.rb contains no information re the table
that was built, hence rake trying to re-create the schema_migrations
table.
The first migration created a searches table:
class CreateSearches < ActiveRecord::Migration
def self.up
create_table :searches do |t|
t.date :start
t.date :end
t.integer :team_id
t.integer :match_id
t.integer :innings_id
t.integer :over_id
t.integer :ball_id
t.integer :match_session_id
t.integer :bowler_id
t.integer :delivery_type_id
t.integer :extra_type_id
t.integer :appeal_id
t.integer :shot_type_id
t.integer :runs_id
t.integer :batter_id
t.integer :umpire_id
t.integer :validity_id
t.integer :decison_id
t.integer :height_id
t.integer :extra_runs_id
t.timestamps
end
end
def self.down
drop_table :searches
end
end
and the second migration tried to rename one of the columns:
class RenameTeamId < ActiveRecord::Migration
def self.up
rename_column :searches, :team_id, :home_team_id
end
def self.down
rename_column :searches, :home_team_id, :team_id
end
end
Dropping the whole DB is really not an option.
Martin
The database is a legacy SQL Server db with over 100 tables already in
existence.
I've noticed that db/schema.rb contains no information re the table
that was built, hence rake trying to re-create the schema_migrations
table.
The first migration created a searches table:
And that was created with no errors? I assume you've looked in the
SQL Server error log(s)?
and the second migration tried to rename one of the columns:
So what does schema_migrations contain at this point?
Dropping the whole DB is really not an option.
Got it. But if I were you, I'd create a new temporary rails projects, just
using sqlite3,. and try running your migrations there as a test. If they
work there, then there's something peculiar to your original config.