From 1d2715fcc7098c2d2aae395bf099c115c1360a0d Mon Sep 17 00:00:00 2001 From: Nikolay Kononov Date: Thu, 18 Apr 2024 09:42:17 +0300 Subject: [PATCH] add better condition to verify that table exists --- lib/uuidable/active_record.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/uuidable/active_record.rb b/lib/uuidable/active_record.rb index 05718aa..20d0267 100644 --- a/lib/uuidable/active_record.rb +++ b/lib/uuidable/active_record.rb @@ -25,7 +25,7 @@ def uuidable(as_param: true) # rubocop:disable Metrics/AbcSize, Metrics/Cyclomat # 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') && schema_loaded? + if conn_config[:adapter].include?('mysql') && connection.data_source_exists?(table_name) 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