Hi, I'm trying to get my head around using migrations to define my initial schema. When using migrations, I want to: - Avoid creating a new migration for every small change. Limit it to one migration per checkin. - When creating a new (fresh) schema, I do not want to go through the overhead of all the migrations. These are the steps I came up with, to create the initial schema: 1. ruby script/generate migration initial 2. modify migration file 3. rake migrate 4. if more modifications required then rake migrate VERSION=0 goto step 2 5. rake db_schema_dump 6. checkin The next change basically goes through the same steps. To create a fresh database without going through all the migrations: 1. checkout from SVN 2. rake db_schema_import Now here come the questions: a. Any comments on the procedure described above? b. Where do I define the initial data? E.g. the statusses in a status table. In http://wiki.rubyonrails.org/rails/pages/Understand... it is suggested to put these in a migration script. But these lines are NOT carried over to schema.rb. So if I create a fresh database using the procedure described above, it would not contain this initial data. Thanks, Mike.
on 2006-02-25 11:26
on 2006-02-25 11:36
Mike, This is really a matter of preference, but unlike the Migrations screencast I prefer to start out with a migration script that defines the initial structure. So instead of using a db/schema.rb file I choose to just start with a migration. That way you can get your schema and lookup data all in there. Also, the initial install is simplified (as if it could be much more simple) in that all you have to do is: 1. create the database 2. rake migrate As far as getting to that first initial schema, I do exacly like you've stated in the top portion, migrating and then rolling back repeatedly until I'm comfortable. Again, it's just preference. Michael