Usage

Create a seed file (eg. /path/to/seeds/20150928000000_initial_seed.rb)

Sequel.seed(:development, :test) do # Applies only to "development" and "test" environments
  def run
    User.create \
      full_name: "Richard Feynman",
      profession: "Theoretical physicist",
      username: "rfeynman",
      password: "271828"
  end
end

Sequel.seed do # Wildcard Seed; applies to every environment
  def run
    [
      ['USD', 'United States dollar'],
      ['BRL', 'Brazilian real']
    ].each do |abbr, name|
      Currency.create abbr: abbr, name: name
    end
  end
end

Set the environment (optional — if omitted, it will fulfil wildcard Seeds only)

Sequel::Seed.setup(:development)

Load the extension

require 'sequel'
require 'sequel/extensions/seed'

Sequel.extension :seed

Apply the seeds/fixtures

DB = Sequel.connect(...)
Sequel::Seeder.apply(DB, "/path/to/seeds")

Limitations

  • JSON and YAML files don't work with associations
  • Only timestamped fixture/seed files by now

What's next?

Work with Model's associations inside JSON & YAML files

Support & Documentation

If you need any help (or have found any bug 🐞), please post it on /issues. Check out the documentation if you need help on how to create seed/fixture files using Ruby, YAML and JSON code and how to apply them over a database instance.