Replicator¶ ↑
Easy Postgres replication for Rails. Replicates specific columns from one table to another using auto-generated triggers. Just add simple directives in your migrations.
Usage:¶ ↑
ActiveRecord::Migration.extend(Replicator)
class AddReplication < ActiveRecord::Migration
def self.up
replicate :names,
:to => :users,
:fields => [:first_name, :last_name]
replicate :data,
:to => :users,
:fields => [:eye_color, :height]
:key => 'user_id',
:prefix => 'data'
replicate :events,
:to => :users,
:fields => {:start_year => :year},
:key => 'user_id',
:prefix => 'type',
:prefix_map => {'BirthEvent' => 'birth', 'GraduationEvent' => 'grad'}
replicate :locations,
:to => :users,
:fields => [:latitude, :longitude, {[:city, :state, :country] => :location}],
:through => 'events.address_id',
:key => 'user_id',
:prefix => 'events.type',
:prefix_map => {'BirthEvent' => 'birth', 'GraduationEvent' => 'grad'}
end
end
There are a lot of options. The code is mostly self explanatory.
Install:¶ ↑
gem install replicator
License:¶ ↑
Copyright © 2009 Justin Balthrop, Geni.com; Published under The MIT License, see License.txt