Topic: Should we generate models for an existing MySQL database with data?

I've been working through the many examples of how one uses 'generate' model to create the model.rb and the migrate and fixtures file.
It occured to me that maybe I should manually create these as the whenever I start the production application it will already have customer data in it (as I converted their old legacy system)and I won't be creating the database schema.
I'm thinking now that I should take all of the existing migrate files and consolidate them into one? Then I'll manually create all of the model.rb files and fixtures.
Is this how you start up an application with an existing database?
RyanB are you there?
David

Re: Should we generate models for an existing MySQL database with data?

It is not likely your legacy database schema fits into Rails conventions. If it were me, I would recreate the database from scratch along with the Rails app so I can stick to Rails conventions and improve the structure of the database while I'm at it.

Railscasts - Free Ruby on Rails Screencasts

Re: Should we generate models for an existing MySQL database with data?

Ryan,
My existing data is 'squeeky clean' Rails convention(s). Could you re-answer the question based on that premise?
Thank you,
David

Re: Should we generate models for an existing MySQL database with data?

In that case, yes, you could just move the schema over to your Rails app and build a model for each table.

Railscasts - Free Ruby on Rails Screencasts

Re: Should we generate models for an existing MySQL database with data?

Ryan,
Here we go again...do I manually build the models and fixtures or do I run a GENERATE the models?
David

Re: Should we generate models for an existing MySQL database with data?

You can run:

script/generate model Foo

But that will just give you the bair bones structure. Rails expects you to manually fill in the proper data into the models (relationships, methods, business logic, etc.).

Railscasts - Free Ruby on Rails Screencasts

Re: Should we generate models for an existing MySQL database with data?

Ryan,
The point of all this is "should I manually create the model.rb and fixture.rb because I'm NOT going to be running a db:migrate because the fully loaded MySQL database will ALWAYS be delivered to the application.
I won't be using any migrations to deliver my application. Yes, as it evolves certainly I'll be using migrates but NOT precedent to delivery.
David

Re: Should we generate models for an existing MySQL database with data?

Although "script/generate model" generates a migration file, you aren't required to use it. You can just delete it. At least then you don't have to manually create the other files.

Railscasts - Free Ruby on Rails Screencasts