0

I'm working on a project with two other remote coders. I'm setting up most of the models/DBs. We're going to be working off of github, so I'll post my basic backend infrastructure, then they'll add their stuff from there.

My initial thought was I would just put my databas.yml in the .gitignore file and let them set up their own databases. But I'm a bit confused as to how they would get their databases up to speed with my models. I generated my models one at a time, so I have like 7 migration files, one for each model. As I make changes, I'll probably have even more.

Is there a simple way to get their databases in sync with mine in terms of tables/fields, or are they just going to have to run rake db:migrate for every single migration file starting from the beginning? Maybe I should just put all of the code in a "master migrate" file and send that to them? I'm looking for a solution that doesn't bring in too much third party material and essentially stays within the rails/postgres/github paradigm.

user1427661
  • 11,158
  • 28
  • 90
  • 132
  • Running `rake db:migrate` I've will run ALL pending migrations, so there is no need to create a "master migration" solely for convenience. – Wizard of Ogz Jun 08 '13 at 17:03

2 Answers2

2

Add your database.yml file to .gitignore. Do a "Save as" of your database.yml as database.yml.example with the username and password removed.

Now on to strategy. Ideally your migrations only modify the schema, and are necessary only if you have the application going already. You should maintain db/seeds.rb to bring in any seed data your friends need to run the app. When they set up, they should be able to type "rake db:create db:schema:load db:seed" and be up and running. From then on, db:migrate and db:seed will keep them up to date.

davidfurber
  • 5,274
  • 1
  • 20
  • 11
1

I don't see any way of keeping things consistent other than using git. Just make sure you all push and pull often from the repository.

The database.yml file really has nothing to do with your schema, it's just ensuring a connection to your DB.

If you want to merge migrations, you can do so by visiting the answer here. But this is really more for just making sure that you don't get too many migration files after a long period of time, and doesn't really have anything to do with keeping files consistent.

Community
  • 1
  • 1
varatis
  • 14,494
  • 23
  • 71
  • 114