postgresql - Rails schema.rb does not include new custom Postgres function -
i have created new custom postgres function via usual migration.
class createbestbowlingfigurefunction < activerecord::migration def change execute "create or replace function ......" end end
after migration, new function not available in schema.rb.
as per official doc, use command db:schema:load
create schema before running tests.
so, best practice create custom functions before running tests?
schema.rb
does not handle (see section 6.2 of rails 3.2.x guides , section 7.2 of rails 4 guides) views or custom functions. have view in our application , schema not work it.
we use structure.sql
instead sets our view and, sense same apply here custom functions. use structure.sql instead of schema.rb:
this set in config/application.rb config.active_record.schema_format setting, may either :sql or :ruby.
you can use combination of schema.rb
(for regular tables & index) , structure.sql
(for custom functions). setup combo test environments:
bundle exec rake db:schema:load bundle exec rake db:structure:load
in setup, note structure.sql has maintained manually while schema.rb maintained rails you.
Comments
Post a Comment