RishiD
RishiD

Reputation: 2168

Convert Ruby ActiveRecord Schema to SQL syntax

I haven't used Ruby much but I am trying to learn. I found a 'schema.db' file that looks like it is generated by Active Record module.

I am trying to figure out how do I convert this file into SQL so I can import it into my database?

Upvotes: 1

Views: 1319

Answers (1)

DanS
DanS

Reputation: 18483

Active Record does generate schema.rb and it represents the current state of the database (useful for getting a quick idea of what attributes each model has).

It is used when deploying new instances of an app, rather than replaying the whole migration history (and is also how the test database is created)

As an example, here's how you can deploy the production database:

RAILS_ENV=production rake db:create db:load

Upvotes: 1

Related Questions