glib-web 5.0.8 → 5.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/models/concerns/glib/soft_deletable.rb +17 -3
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 66abe13aca7ef703ab65bcbaeded784ff74339b4dcfd3659658bdefc99f0ec30
|
|
4
|
+
data.tar.gz: a8c90ab7a9684a4eeed86c8d6e25d3676281157c856ed07cd582b5ccdebfa622
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ef265df7cd0d8f0e3d951f384b574cf01e6c4039f774e0df286fb0617ce58be80551cb5e1ccbf05996af4b9127aaa8cfdccbac7f146d22b0816acc6690400814
|
|
7
|
+
data.tar.gz: e5ba874af4579d1310671a292404a2cb27b8ff89b609ff2a2c0f0ff3609a301a8566d8e3a86099d4a41c9ca6249a19cd00ce78a4cef30c8642e85efed260f07a
|
|
@@ -20,9 +20,7 @@ module Glib
|
|
|
20
20
|
column_name = :deleted_at
|
|
21
21
|
default_scope { where(column_name => nil) }
|
|
22
22
|
|
|
23
|
-
if Rails.env.development? || Rails.env.test?
|
|
24
|
-
raise ActiveRecord::ConfigurationError, "#{table_name}.#{column_name} need to be indexed" unless connection.index_exists?(table_name, column_name)
|
|
25
|
-
end
|
|
23
|
+
__validate_soft_delete_index!(column_name) if Rails.env.development? || Rails.env.test?
|
|
26
24
|
end
|
|
27
25
|
|
|
28
26
|
# `behaviour` can be either `:soft_destroy` or `:hard_destroy``
|
|
@@ -51,6 +49,22 @@ module Glib
|
|
|
51
49
|
@__glib_soft_deletable_associations ||= []
|
|
52
50
|
end
|
|
53
51
|
|
|
52
|
+
# Dev/test safety net: ensure the soft-delete column is indexed.
|
|
53
|
+
#
|
|
54
|
+
# This must never depend on the database already existing. It runs at class-load
|
|
55
|
+
# time, which also happens during `db:create`, `db:setup`, migrations and cold CI
|
|
56
|
+
# boots — moments when the database or the table may not exist yet. In those cases
|
|
57
|
+
# we skip silently; the check runs again (and can raise) once the schema is present.
|
|
58
|
+
def __validate_soft_delete_index!(column_name)
|
|
59
|
+
return unless table_exists?
|
|
60
|
+
return if connection.index_exists?(table_name, column_name)
|
|
61
|
+
|
|
62
|
+
raise ActiveRecord::ConfigurationError, "#{table_name}.#{column_name} need to be indexed"
|
|
63
|
+
rescue ActiveRecord::NoDatabaseError, ActiveRecord::ConnectionNotEstablished
|
|
64
|
+
# Database not available yet (e.g. during `db:create`/`db:setup` or a cold boot).
|
|
65
|
+
# Defer the check rather than making model definition require a live database.
|
|
66
|
+
end
|
|
67
|
+
|
|
54
68
|
def __validate_soft_deletable_association!(name)
|
|
55
69
|
reflection = reflect_on_association(name)
|
|
56
70
|
unless reflection
|