From 46f095bb6fe9d20e0e511f649c83e215d5f0fdff Mon Sep 17 00:00:00 2001 From: Nikolay Kononov Date: Fri, 29 Mar 2024 11:40:29 +0300 Subject: [PATCH] Skip uuidable when uuidable called before schema loaded --- lib/uuidable/active_record.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/uuidable/active_record.rb b/lib/uuidable/active_record.rb index e5685f0..05718aa 100644 --- a/lib/uuidable/active_record.rb +++ b/lib/uuidable/active_record.rb @@ -24,7 +24,8 @@ module ClassMethods def uuidable(as_param: true) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity # Configure all uuid columns for MySQL. Database may not be connected (i.e. on assets precompile), so we must supress errors. conn_config = respond_to?(:connection_db_config) ? connection_db_config.configuration_hash : connection_config - if conn_config[:adapter].include?('mysql') + + if conn_config[:adapter].include?('mysql') && schema_loaded? begin columns.select { |c| c.type == :binary && c.limit == 16 && c.name.include?('uuid') }.each do |column| attribute column.name.to_sym, MySQLBinUUID::Type.new