37

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.

Community
  • 1
  • 1
vince
  • 2,374
  • 4
  • 23
  • 39

1 Answers1

51

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.

Maurício Linhares
  • 39,901
  • 14
  • 121
  • 158
  • 11
    that works but we wanted the .sql file to be updated (like schema.rb) every time we db:migrate. at least that's what i thought it's supposed to do according to the documentation. else there's no point in doing "config.active_record.schema_format = :sql" since we can "db:structure:dump" manually anytime no? – vince Aug 14 '11 at 04:04
  • Yes, you'd expect that switching to :sql wouldn't break all the rake support infrastructure for tests - and it seems like a patch to do that was committed several years ago: https://github.com/rails/rails/issues/715 but that's not the behavior I'm seeing in Rails 3.2 - It's seeming like the extensive reworking of rake tasks outlined here: http://pivotallabs.com/using-mysql-foreign-keys-procedures-and-triggers-with-rails/ is still necessary . . . but maybe I'm missing something? – Steve May 01 '14 at 19:32