Skip to content

A platform for community discussion. Free, open, simple.

DEV: Add an `after_copy_data` hook to CopyStep (#34491)

Selase Krakanic3c62165fb9d
diff --git a/migrations/lib/importer/copy_step.rb b/migrations/lib/importer/copy_step.rb
index 8e118542023..356d9889e3f 100644
--- a/migrations/lib/importer/copy_step.rb
+++ b/migrations/lib/importer/copy_step.rb
@@ -66,10 +66,24 @@ module Migrations::Importer
def execute
super
+
+ before(total_rows: total_count)
with_progressbar(total_count) { copy_data }
+ after(total_rows: total_count)
+
nil
end
+ protected
+
+ def before(total_rows:)
+ # Override in step implementation if needed
+ end
+
+ def after(total_rows:)
+ # Override in step implementation if needed
+ end
+
private
def copy_data
@@ -165,8 +179,11 @@ module Migrations::Importer
end
def total_count
- query, parameters = self.class.total_rows_query
- @intermediate_db.count(query, *parameters)
+ @total_count ||=
+ begin
+ query, parameters = self.class.total_rows_query
+ @intermediate_db.count(query, *parameters)
+ end
end
end
end