heroku addons:add heroku-postgresql:dev
heroku pg:promote NEW_DB_COLORFUL_NAME
Showing posts with label database. Show all posts
Showing posts with label database. Show all posts
Tuesday, August 28, 2012
Upgrade Heroku db to new PostgreSQL Dev addon
Thursday, July 30, 2009
Seed data into development database using Bootstrapper and Factory Girl
There's only so much development an application using unit tests and cucumber before we need to fire up the application on the browser in development mode. Trouble is we've written so many associated models and there did not contain any data in development database.
So comes seeding of data into my development database. I could do one of the following:
Since I'm already using Factory Girl heavily with shoulda and cucumber, it makes sense to use them for my database seeding.
Bootstrapper gives nice convenience methods like
You can specify different environments (test, development, staging, production, etc.) and run seeding modularly within the db/bootstrap.rb file
You can then specify the bootstrapping that you wanna make
So comes seeding of data into my development database. I could do one of the following:
- Manually do SQL insertions of records into database
- Manually create and save objects in "script/console"
- Setup rake task to create records
- Use migration to insert seed data
- Use a SystemSettings model to create objects
- Use plugins like Seed_Fu and object creations
- Use plugins like Seed_Fu and fixtures
- Use Bootstrapper plugin with Factory Girl
Since I'm already using Factory Girl heavily with shoulda and cucumber, it makes sense to use them for my database seeding.
Bootstrapper gives nice convenience methods like
rake db:bootstrap
rake db:bootstrap:reset
You can specify different environments (test, development, staging, production, etc.) and run seeding modularly within the db/bootstrap.rb file
Bootstrapper.for :development do |b|
b.truncate_tables :addresses
b.run :users
Factory(:us_address, :state => "ME")
Factory(:us_address, :state => "IL")
Factory(:us_address, :state => "CA")
end
Bootstrapper.for :production do |b|
end
Bootstrapper.for :test do |b|
end
Bootstrapper.for :staging do |b|
end
Bootstrapper.for :users do |b|
3.times{ Factory(:user) }
Factory(:user, :login => "admin",
:password => "sekret",
:password_confirmation => "sekret")
end
You can then specify the bootstrapping that you wanna make
rake db:bootstrap BOOTSTRAP=usersrake db:bootstrap RAILS_ENV=productionrake db:bootstrap BOOTSTRAP=users RAILS_ENV=production
Subscribe to:
Posts (Atom)