From f14168d29e6b1bea0700b9c17d9c8af1fcf0bfe1 Mon Sep 17 00:00:00 2001 From: Daniel Pierce Date: Thu, 29 Jun 2023 11:45:04 -0400 Subject: [PATCH 1/2] Load all work classes at startup --- lib/extensions/allinson_flex_extensions.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/extensions/allinson_flex_extensions.rb b/lib/extensions/allinson_flex_extensions.rb index fefde7f3a..6f0bf3c92 100644 --- a/lib/extensions/allinson_flex_extensions.rb +++ b/lib/extensions/allinson_flex_extensions.rb @@ -29,3 +29,9 @@ # profile texts AllinsonFlex::ProfileText.include Extensions::AllinsonFlex::IncludeProfileText + +# Create transient new objects for all registered work types. Attempts to work around failures to +# define methods for some properties when loading works (e.g. missing ocr_state) +Hyrax.config.registered_curation_concern_types.each do |klass| + klass.constantize.new +end \ No newline at end of file From dbb1ef6d18d67c882c34417e2c1f629fe08b1241 Mon Sep 17 00:00:00 2001 From: Daniel Pierce Date: Thu, 29 Jun 2023 12:04:42 -0400 Subject: [PATCH 2/2] Do not load classes when db is not ready. --- lib/extensions/allinson_flex_extensions.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/extensions/allinson_flex_extensions.rb b/lib/extensions/allinson_flex_extensions.rb index 6f0bf3c92..66a0cfec8 100644 --- a/lib/extensions/allinson_flex_extensions.rb +++ b/lib/extensions/allinson_flex_extensions.rb @@ -32,6 +32,8 @@ # Create transient new objects for all registered work types. Attempts to work around failures to # define methods for some properties when loading works (e.g. missing ocr_state) -Hyrax.config.registered_curation_concern_types.each do |klass| - klass.constantize.new -end \ No newline at end of file +unless ActiveRecord::Base.connection.migration_context.needs_migration? + Hyrax.config.registered_curation_concern_types.each do |klass| + klass.constantize.new + end +end