I am writing a RoR app against a legacy Oracle database against which other applications are running. My app will use some existing tables and will add some. My question is how to handle this and still use migrations. I obviously never want to run rake db:migrate against the production db and have it delete any tables that are being used by other apps (though I wouldn''t mind being able to recreate these in dev/ test), so do I, but would like to use migrations to update the production db with the new tables. 1. Create a test and development database that are copies of production as my Version 0 2. Create migrations only for the new tables ? Also, can I use db:schema:dump to get a copy of my production schema to use for dev/test? If so, I''m not clear what the steps are to do this. Appreciate any help - thanks. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Sep 10, 2007, at 2:58 PM, sydneyos wrote:> I am writing a RoR app against a legacy Oracle database against which > other applications are running. My app will use some existing tables > and will add some. My question is how to handle this and still use > migrations. I obviously never want to run rake db:migrate against the > production db and have it delete any tables that are being used by > other apps (though I wouldn''t mind being able to recreate these in > dev/ > test), so do I, but would like to use migrations to update the > production db with the new tables. > > 1. Create a test and development database that are copies of > production as my Version 0 > 2. Create migrations only for the new tables > > ? > > Also, can I use db:schema:dump to get a copy of my production schema > to use for dev/test? If so, I''m not clear what the steps are to do > this. > > Appreciate any help - thanks.This isn''t a full solution, but some tips based on having to reconstruct migrations on a project where the original developers didn''t consistently use migrations (since I''ve not had to deal [yet] with a true legacy db in Rails). put the legacy schema (I don''t know if you can just point your database.yml at production and db:schema:dump) into your migration 1: db/migrate/001_legacy_schema.rb (I think there''s a :force=>false on the create table that might help, too) Put the down migration as: def self.down raise IrreversibleMigration, "Can''t erase Legacy schema" end Manually, create the schema_information table in production and set the version column of the only row to be 1. -Rob Rob Biedenharn http://agileconsultingllc.com Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@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 -~----------~----~----~----~------~----~------~--~---
Thanks Rob - that''s helpful. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
So, if I run rake on production with the version = 1 then only migrations numbered higher will be run, is that the idea? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Sep 10, 2007, at 5:25 PM, sydneyos wrote:> So, if I run rake on production with the version = 1 then only > migrations numbered higher will be run, is that the idea?Right, only the migrations numbered from (select version from schema_information)+1 up to the highest prefix in db/migrate/*.rb will be run. So 001_legacy_schema.rb would exist more as documentation than anything else and the IrreversibleMigration keeps the Migrator from ever going from 1 back to 0 (which is usually an empty schema (with the possible exception of the schema_information table itself that the migration creates and maintains). -Rob Rob Biedenharn http://agileconsultingllc.com Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@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 -~----------~----~----~----~------~----~------~--~---
Thanks --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---