Skip to content

remi/portugal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Portugal

Use ActiveRecord migrations, but not in Rails.

Installation

Add this line to your application's Gemfile:

gem 'portugal'

And then execute:

$ bundle install

Usage

In your Rakefile:

require 'portugal/tasks'
Portugal.configure do |config|
  config.migrations_path = File.expand_path("../config/migrations", __FILE__)
end

# This task is called before Portugal executes its tasks.
# It should require ActiveRecord somehow and establish the database connection
#
# Change it so it works for your application
task :environment do
  require 'bundler'
  Bundler.require
  ActiveRecord::Base.establish_connection({})
end

Then, in your shell:

$ bundle exec rake -T | grep 'db:'
rake db:migrate        # Migrate the database
rake db:new_migration  # Create a new migration file (specify name w/ NAME=do_something)
rake db:rollback       # Rolls the database back to the previous version (specify steps w/ STEP=n).

Yay!

Inspiration

Gob: Portugal? Well, gonna live it up in ol’ South America, aren’t we, Michael?

About

ActiveRecord migrations without Rails

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages