Martin Hawkins
2009-Jan-08 16:03 UTC
There is already an object named ''schema_migrations'' in the database
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? thnx Martin --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hassan Schroeder
2009-Jan-08 16:18 UTC
Re: There is already an object named ''schema_migrations'' in the database
On Thu, Jan 8, 2009 at 8:03 AM, Martin Hawkins <martin.hawkins-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > 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''.It sounds like you edited an existing migration -- if so, don''t :-) Create a new migration to change the column, or drop the entire DB and start from scratch. HTH, -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Martin Hawkins
2009-Jan-08 16:36 UTC
Re: There is already an object named ''schema_migrations'' in the database
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!! Martin On Jan 8, 4:18 pm, "Hassan Schroeder" <hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Thu, Jan 8, 2009 at 8:03 AM, Martin Hawkins <martin.hawk...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > 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''. > > It sounds like you edited an existing migration -- if so, don''t :-) > > Create a new migration to change the column, or drop the entire DB > and start from scratch. > > HTH, > -- > Hassan Schroeder ------------------------ hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hassan Schroeder
2009-Jan-08 16:41 UTC
Re: There is already an object named ''schema_migrations'' in the database
On Thu, Jan 8, 2009 at 8:36 AM, Martin Hawkins <martin.hawkins-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> No, I didn''t edit an existing migration - I created a new one for the > rename.It sounds like your second migration is trying to create the schema table which already exists. Maybe you could post your migrations, or at least the failing one?> I understand what you are saying about dropping the table (not the > entire db surely :-0).Yes, the whole DB -- if you''re wanting to fix a bad migration and run it all from the beginning. That''s not a bad thing early in a project. -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Martin Hawkins
2009-Jan-08 17:07 UTC
Re: There is already an object named ''schema_migrations'' in the database
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 On Jan 8, 4:41 pm, "Hassan Schroeder" <hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Thu, Jan 8, 2009 at 8:36 AM, Martin Hawkins <martin.hawk...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > No, I didn''t edit an existing migration - I created a new one for the > > rename. > > It sounds like your second migration is trying to create the schema table > which already exists. > > Maybe you could post your migrations, or at least the failing one? > > > I understand what you are saying about dropping the table (not the > > entire db surely :-0). > > Yes, the whole DB -- if you''re wanting to fix a bad migration and run > it all from the beginning. That''s not a bad thing early in a project. > > -- > Hassan Schroeder ------------------------ hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hassan Schroeder
2009-Jan-08 18:21 UTC
Re: There is already an object named ''schema_migrations'' in the database
On Thu, Jan 8, 2009 at 9:07 AM, Martin Hawkins <martin.hawkins-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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. Caveat: I know zero about MS SQL Server so... -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---