How to create schema in sql

vince picture vince · Aug 12, 2011 · Viewed 15k times · Source

As per http://edgeguides.rubyonrails.org/configuring.html and this post I have this in application.rb

config.active_record.schema_format = :sql

However, it's still creating db/schema.rb (even after I delete it) and more importantly it's not creating the schema in sql when I run "rake db:migrate". Anyone know what I'm doing wrong? I'm on Rails 3.1 pre.

Answer

Maurício Linhares picture Maurício Linhares · Aug 14, 2011

Well, this could be a rails bug, but you can always generate your db structure with this:

rake db:structure:dump

This is going to generate an "#{Rails.env}.sql" file for you with your database structure in SQL.