Loading structure.sql file in Rails + Spork

76 Views Asked by At

We have the schemaless option selected in our application.rb config.active_record.schema_format = :sql

Before each spork run we are reloading the schema in the database. However, this does not work. As you can see the code is loading the schema.rb file. But it should load the db/structure.sql file into the database.

ActiveRecord::Schema.verbose = false
def reload_database
  silence_stream(STDOUT) do
    load("#{Rails.root}/db/schema.rb")
  end
end

The problem is that the schema.rb is outdated. Most of the attributes of the models are no longer in the schema file. That's why the spork database does not have all attributes. This raises method not found issues in some of the tests. Example:

AdwordsCampaign::visible#test_0003_sets the default state to visible of new campaigns: NoMethodError: undefined method `visible' for #<AdwordsCampaign:0x007fef94c66d18>

What I am looking for is a a way to make the load command load the SQL schema instead.

0

There are 0 best solutions below