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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/neon_postgres/inter_database_copy/matter_copier.rb', line 22
def copy
from_dataset.each do |row|
to_connection[:matter_templates].insert_conflict(
target: :id,
update: {
category: Sequel[:excluded][:category],
name: Sequel[:excluded][:name],
description: Sequel[:excluded][:description]
}
).insert({
id: row.fetch(:matter_template_id),
name: row.fetch(:matter_templates_name),
category: row.fetch(:category),
description: row.fetch(:matter_templates_description)
})
to_connection[:people].insert_conflict(
target: :id,
update: {
name: Sequel[:excluded][:name],
email: Sequel[:excluded][:email],
sub: Sequel[:excluded][:sub]
}
).insert({
id: row.fetch(:people_id),
name: Faker::Name.name,
email: Faker::Internet.email,
sub: Faker::Internet.uuid
})
to_connection[:matters].insert_conflict(
target: :name,
update: {
matter_template_id: Sequel[:excluded][:matter_template_id],
primary_contact_id: Sequel[:excluded][:primary_contact_id],
description: Sequel[:excluded][:description]
}
).insert({
name: "#{row.fetch(:matter_templates_name)} Matter",
matter_template_id: row.fetch(:matter_template_id),
description: JSON.generate({
body: Faker::Lorem.paragraphs(number: 3)
}),
primary_contact_id: row.fetch(:primary_contact_id)
})
end
end
|