Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Need help creating structure.sql for my Rails app

Tags:

I'm trying to manually create/update the db/structure.sql file for test purposes. I have "config.active_record.schema_format = :sql" set in application.rb. I am wondering if there is a command equivalent to "ActiveRecord::SchemaDumper.dump" that will create or update structure.sql. I've tried structure_dump, but the output is nil:

> ActiveRecord::Base.connection.structure_dump => nil 

I also tried passing a file to that method:

> File.open( File.join(Rails.root, 'db/structure.sql')) { |f| ActiveRecord::Base.connection.structure_dump() }  => nil  

So far, the only way I've been able to generate or update db/structure.sql is by running rake db:migrate. Any alternatives? Or am I missing something when trying to run ActiveRecord::Base.connection.structure_dump?

like image 367
MothOnMars Avatar asked Mar 01 '13 00:03

MothOnMars


1 Answers

Try rake db:structure:dump which will recreate the db/structure.sql from the database.

like image 82
jvnill Avatar answered Nov 15 '22 12:11

jvnill