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:
- ruby script/generate migration initial
- modify migration file
- rake migrate
- if more modifications required then
rake migrate VERSION=0
goto step 2 - rake db_schema_dump
- checkin
The next change basically goes through the same steps.
To create a fresh database without going through all the migrations:
- checkout from SVN
- 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/UnderstandingMigrations 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.