lib/lhm/entangler.rb in lhm-2.1.0 vs lib/lhm/entangler.rb in lhm-2.2.0
- old
+ new
@@ -12,11 +12,11 @@
attr_reader :connection
# Creates entanglement between two tables. All creates, updates and deletes
# to origin will be repeated on the destination table.
def initialize(migration, connection = nil)
- @common = migration.intersection
+ @intersection = migration.intersection
@origin = migration.origin
@destination = migration.destination
@connection = connection
end
@@ -38,20 +38,20 @@
def create_insert_trigger
strip %Q{
create trigger `#{ trigger(:ins) }`
after insert on `#{ @origin.name }` for each row
- replace into `#{ @destination.name }` (#{ @common.joined }) #{ SqlHelper.annotation }
- values (#{ @common.typed("NEW") })
+ replace into `#{ @destination.name }` (#{ @intersection.destination.joined }) #{ SqlHelper.annotation }
+ values (#{ @intersection.origin.typed('NEW') })
}
end
def create_update_trigger
strip %Q{
create trigger `#{ trigger(:upd) }`
after update on `#{ @origin.name }` for each row
- replace into `#{ @destination.name }` (#{ @common.joined }) #{ SqlHelper.annotation }
- values (#{ @common.typed("NEW") })
+ replace into `#{ @destination.name }` (#{ @intersection.destination.joined }) #{ SqlHelper.annotation }
+ values (#{ @intersection.origin.typed('NEW') })
}
end
def create_delete_trigger
strip %Q{