sathishkumar sadhasivam
2009-Nov-11 11:56 UTC
Is it possible to do Reverse Engineering in rails migrations?
Hi All, This is my first post as in joined just now and have some doubts, I need a to discuss about Rails migrations in detail, I have a doubt on doing reverse engineering concept in migrations on existing database. Consider, I have deleted all the migration files from the folder RAILS_ROOT/db/migrate/*. We have all the tables present in Mysql database. Now, I want to create a migration files for all existing tables. Is that possible to create those? If yes, how is it? Even I have deleted the schema.rb file from RAILS_ROOT/db/ folder. Looking for solution to try it out. Thanks in Advance to all the user who is going put their thought process into it, -Sathish Kumar
Frederick Cheung
2009-Nov-11 13:53 UTC
Re: Is it possible to do Reverse Engineering in rails migrations?
On Nov 11, 11:56 am, sathishkumar sadhasivam <srssathishku...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > We have all the tables present in Mysql database. Now, I want to > create a migration files for all existing tables. > > Is that possible to create those? If yes, how is it? > > Even I have deleted the schema.rb file from RAILS_ROOT/db/ folder. >if you want to recreate the schema.rb file, rake db:schema:dump does that. Fred> Looking for solution to try it out. > > Thanks in Advance to all the user who is going put their thought > process into it, > > -Sathish Kumar
Marnen Laibow-Koser
2009-Nov-11 14:17 UTC
Re: Is it possible to do Reverse Engineering in rails migrat
Sathish Kumar wrote: [...]> Consider, I have deleted all the migration files from the folder > RAILS_ROOT/db/migrate/*. > > We have all the tables present in Mysql database. Now, I want to > create a migration files for all existing tables. > > Is that possible to create those? If yes, how is it? > > Even I have deleted the schema.rb file from RAILS_ROOT/db/ folder.Just check out the migrations and schema.rb again from your version control repository, same as you would for any accidentally deleted file. Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/.
Norm Scherer
2009-Nov-11 16:12 UTC
Re: Is it possible to do Reverse Engineering in rails migrations?
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type"> <title></title> </head> <body bgcolor="#ffffff" text="#000000"> sathishkumar sadhasivam wrote: <blockquote cite="mid:2a8021c5-342e-4e7c-9a15-f67aefdf74af-X+tPM7KPro3ZvT1iavJltlYGCWtFR9XvxddQ6fo/n9Y@public.gmane.orgom" type="cite"> <pre wrap="">Hi All, This is my first post as in joined just now and have some doubts, I need a to discuss about Rails migrations in detail, I have a doubt on doing reverse engineering concept in migrations on existing database. Consider, I have deleted all the migration files from the folder RAILS_ROOT/db/migrate/*. We have all the tables present in Mysql database. Now, I want to create a migration files for all existing tables. Is that possible to create those? If yes, how is it? Even I have deleted the schema.rb file from RAILS_ROOT/db/ folder. Looking for solution to try it out. Thanks in Advance to all the user who is going put their thought process into it, -Sathish Kumar </pre> </blockquote> If what you want is a single migration to replace the multiple migrations you had you can do it but maybe not easily. As Marnen said you can recreate the schema.rb from the database using an existing rake task. If you really want a migration you can then bring that file into any editor and change the syntax line by line to the migration syntax. It is not hard but just fairly tedious. If you just want to have the ability to recreate the database, just create the schema.rb (see above) and save it into your configuration management system. You can fetch it and run it any time to recreate the current database configuration.<br> <br> Norm<br> <br> --~--~---------~--~----~------------~-------~--~----~<br> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. <br> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <br> To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <br> For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en<br> -~----------~----~----~----~------~----~------~--~---<br> </body> </html> <br>