What you are probably observing is that no migrations are performed in the test environment (db: migrate), but db / schema.rb (db: load) is loaded instead.
You have two options:
- continue to use migration for production and development; for a test environment, add your persistent data to the corresponding yml files in db / fixtures.
- db/fixtures yml ( ) , db/fixtures, , rake db:
, db: load ( db: migrate - , test, db: load db: migrate ..) - drop-in rakefile RAILS_APP/lib/tasks, db: load, "" yml ( ) .
db: seed rake . db/seed/.yml
namespace :db do
desc 'Initialize data from YAML.'
task :load => :environment do
require 'active_record/fixtures'
Dir.glob(RAILS_ROOT + '/db/seeds/*.yml').each do |file|
Fixtures.create_fixtures('db/seeds', File.basename(file, '.*'))
end
end
end
(db: migrate), one, , , .
- , , , , ..