ivanibash
ivanibash

Reputation: 1491

Using Rails with existing database

So I have an existing postgres database which gets populated by a python script. Now I am making a rails api which serves that data to a client. To my amusement all that I had to do is to create model classes and simply define relationships. No migration files, no schema, it just works. So a couple of questions.

Upvotes: 1

Views: 279

Answers (1)

TomD
TomD

Reputation: 791

schema.rb is indeed not required by ActiveRecord.

It is used for:

  • having a quick overview of the state of the database
  • creating thedatabase tables when using db:schema:load task
  • in gems like Apartment, (I think) it is used to create tenant specific schemas

TL:DR; - you don't really need schema.rb file but it's always good to have it as an authoritative source of db information.

More info here: http://edgeguides.rubyonrails.org/active_record_migrations.html#schema-dumping-and-you

Upvotes: 2

Related Questions