# Migrations for initial schema: Where to put initial data?

**URL:** <https://www.ruby-forum.com/t/migrations-for-initial-schema-where-to-put-initial-data/73185>\
**Category:** Rails\
**Created:** [February 25, 2006, 11:26am UTC](https://www.ruby-forum.com/t/migrations-for-initial-schema-where-to-put-initial-data/73185 "2006-02-25T11:26:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [February 25, 2006, 11:26am UTC](https://www.ruby-forum.com/t/migrations-for-initial-schema-where-to-put-initial-data/73185/1 "2006-02-25T11:26:32Z")

</div>

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/UnderstandingMigrations](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.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [February 25, 2006, 11:36am UTC](https://www.ruby-forum.com/t/migrations-for-initial-schema-where-to-put-initial-data/73185/2 "2006-02-25T11:36:06Z")

</div>

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
