-
Notifications
You must be signed in to change notification settings - Fork 75
/
postgresql_replication.rb
48 lines (42 loc) · 1.29 KB
/
postgresql_replication.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
require 'spec_helper'
require 'yaml'
include RR
shared_examples "PostgreSQLReplication" do
before(:each) do
end
it "create_replication_trigger should also work if language plpgsql does not yet exist" do
session = nil
begin
session = Session.new
session.left.begin_db_transaction
unless session.left.select_all("select lanname from pg_language where lanname = 'plpgsql'").empty?
session.left.execute "DROP EXTENSION plpgsql"
end
params = {
:trigger_name => 'rr_trigger_test',
:table => 'trigger_test',
:keys => ['first_id', 'second_id'],
:log_table => 'rr_pending_changes',
:key_sep => '|',
:exclude_rr_activity => false,
}
session.left.create_replication_trigger params
session.left.insert_record 'trigger_test', {
'first_id' => 1,
'second_id' => 2,
'name' => 'bla'
}
row = session.left.select_one("select * from rr_pending_changes")
row.delete 'id'
row.delete 'change_time'
row.should == {
'change_table' => 'trigger_test',
'change_key' => 'first_id|1|second_id|2',
'change_new_key' => nil,
'change_type' => 'I'
}
ensure
session.left.rollback_db_transaction if session
end
end
end