Pito Salas wrote:
> This maybe too vague a question, but I wonder if there's some wisdom out
> there for me to tap...
> 
> Sometimes when I get ready to commit, git says that db/schema.rb has
> changed. This is weird, and I think it's because I did a rake
> db:migrate.
> 
> So my question is, what's the best practice relating to putting bits of
> the database (schema.rb and the databases themselves) into sourc
> control. And what's the best practice relating to running a rake
> db:migrate after a git checkout of a new branch?

Beyond the issues with db/schema.rb, I think it's also good practice to 
not version control config/database.yml. You may be doing this already.

The reason for this is that database configurations for other member of 
the team may be different, and you may not want to expose the production 
database configuration to then entire team.

I do the following:

1. Rename a basic config/database.yml file to 
config/example_database.yml.
2. Add config/example_database.yml to Git
3. Ignore config/database.yml in .gitignore
4. Commit these changes
5. Copy config/example_database.yml to config/database.yml

When other team members clone the repository they will also need to copy 
the example_database.yml file and configure it for their own system. 
This allow more freedom to other developers on the team to setup their 
system the way they see fit.

For example: I may prefer to use the MySQL root user with no password 
set on my development database, while other may prefer (or need) their 
development database protected by using a different user with their own 
password. Or, maybe I might prefer using SQLite in development while 
others on the team prefer developing using MySQL.

Keeping this configuration out of the versioning system makes these 
kinds of preference easier to manage. This technique also helps in cases 
where not all team member are allowed to know the production database's 
password.
-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to