The schema.rb is primarily used in the db:test:prepare rake task that bootstraps your :test database when you run rake spec or rake test. You can bootstrap a non test database but I don't recall the command because I don't use it. So if you don't check it in ; and if you clone a project and immediately run the tests it will be unable to prepare the test database. If you db:migrate your dev database it will generate the schema.rb and your tests will be able to proceed.
There are other reasons the schema.rb is useless to check in. Seed data; if your migrations add seed data that data won't be present in a database generated from the schema.rb. (rake db:seed is the new way to handle that problem) Stored procedures; if you've added stored procedures in your migrations, they won't be in a database generated from the schema.rb, also applies to foreign key constraints I believe. The most insidious is that it allows bizarre artifacts into the schema.rb as a result of development unless you are really diligent about resetting your development databases every time you switch checkouts. If you use the schema.rb to initialize production databases beware, but it can also break tests and waste time with useless conflicts. Consider creating a new topic branch, xyz based on abc. In xyz you add a migration that adds table xyz. You need to work on a bug on abc so you checkout abc and commit some migration; if you check the schema.rb carefully you'll notice the table xyz is in the schema.rb for branch abc. If abc and xyz are ever merged or ancestors of those are merged you'll likely end up with conflicts, or worse just the silent little artifacts of garbage slowly polluting your schema.rb. If you doubt what I say take and old project; where there are different developers; a goodly number of migrations; and they have been checking in the schema.rb; >From a clean checkout; reset the development database; rake db:migrate it; I >bet you will end up with a schema.rb that is different than the one checked >in. For extra credit try to find what induced the modifications. On Aug 26, 2010, at 7:48 AM, Pita Salas <r...@salas.com> wrote: > Yeah it's a mystery to me: the question about checking in schema.rb is > heavily debated and the rails code itself STRONGLY advises to check it > in. But I don't know why because what you say makes perfect sense to > me too. > > -- Pito > > -- You received this message because you are subscribed to the Google Groups "Git for human beings" group. To post to this group, send email to git-us...@googlegroups.com. To unsubscribe from this group, send email to git-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/git-users?hl=en.