127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
# File 'lib/datatransit/rule_dsl.rb', line 127
def do_task task
pks = task.pk tables = task.tables
tables.each do |tbl|
sourceCls = Class.new(DataTransit::Source::SourceBase) do
self.table_name = tbl
end
columns = sourceCls.columns
pk_column = get_pk_column(columns, pks)
if pk_column != nil
pk, pk_type = pk_column.name, pk_column.type
else
pk, pk_type = nil, nil
end
sourceCls.instance_eval( "self.primary_key = \"#{pk}\"") if pk != nil
targetCls = Class.new(DataTransit::Target::TargetBase) do
self.table_name = tbl
end
targetCls.instance_eval( "self.primary_key = \"#{pk}\"") if pk != nil
print "\ntable ", tbl, ":\n"
do_user_ar_proc targetCls, task.pre_work if task.pre_work
do_batch_copy sourceCls, targetCls, task, pk, pk_type=="integer"
do_user_ar_proc targetCls, task.post_work if task.post_work
end
end
|