I have an application that''s been under constant heavy development for several months. I''m now rewriting it to somewhat different specs, and I decided it would be easiest and cleanest to start with a new blank application, and copy only the parts I need from the old one. Almost all of the changes will be in the controller code and HTML. The models and database will stay substantially the same. The database is up to 25 migrations, and I''d like to "flatten" them for this new version. As far as I could tell, the migrate task gets its next number by adding one to the number of the highest-numbered file in the migrations folder. So I made a migration file in the new project, "025_inherited_db.rb", and put everything from the schema.rb in the old project into it. I ran rake db:migrate, and as expected, it didn''t do anything. So generated a new migration, added a table, ran the migration again, and the new table appeared as expected. Then I migrated back to the initial version, and it correctly dropped the new table and set schema_info to the correct value. So it looks to me like this works. Am I missing something that will bite me later? Thanks, --Al Evans -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Elad Meidar - Creopolis.com
2006-Dec-23 18:50 UTC
Re: Migrations question: force initial version?
Hi Al, As you already found, the base level of your database structure is found in schema.rb. but db:migrate will not help you in this case, although you created a new member since it compares the migration number (aka schema version) to the number found in the schema_info table (version column) in your working db. try copying the schema.rb file into your new project and issue the db:schema:load command. hope this helps. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---