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?
Try rake db:structure:dump
which will recreate the db/structure.sql
from the database.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With