Read more

Don't use migrations to seed default data

Henning Koch
November 25, 2010Software engineer at makandra GmbH

It's OK to add data in a migration if your test suite cleans the database before it starts.

For instance, in RSpec:

config.before(:suite) do
  DatabaseCleaner.clean_with(:deletion)
end

Don't insert table rows in a Rails database migration. This will break tests that expect that database to be empty and cause you all sorts of pain.

Illustration online protection

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
Read more Show archive.org snapshot

If you need a place for default application data, use db/seed.rb Show archive.org snapshot or put a script into lib/scripts. It won't run automatically, so add a chore story to Pivotal Tracker as a reminder.

Posted by Henning Koch to makandra dev (2010-11-25 14:33)