generated_schema_validations 0.5.5 → 0.6.0
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/README.md +12 -0
- data/generated_schema_validations.gemspec +1 -1
- data/lib/generated_schema_validations/template.rb +20 -3
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8d682dd2bd139df00dace4687523703c49ab9f139c8a62f4360b584844ee22af
|
|
4
|
+
data.tar.gz: 46c6c3531d0dd45f4e4c2a92ff98825f961e914916a9970f5d161f53e172250e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 35197994299293c9ce253a9bb65f9c6f3a219250f8275048694ac460837850ad4f5620764641fb95ca1ff6793e5c46c2cc4774742d222927e13a8d1b0f2369b8
|
|
7
|
+
data.tar.gz: 1c9cb3dfd84a6fe456664d7d3e9eb9cb4892d7083155abbebc573872a52c3aca0704b30c7b682006296a688eec048bd425bf69e4994b2f476c96d2bd8b96b222
|
data/README.md
CHANGED
|
@@ -105,6 +105,18 @@ You can watch changes on `schema_validations.rb` to understand the generated val
|
|
|
105
105
|
|
|
106
106
|
## Changelog
|
|
107
107
|
|
|
108
|
+
### 0.6.0
|
|
109
|
+
|
|
110
|
+
* add a relaxed mode for model validations in migrations
|
|
111
|
+
|
|
112
|
+
```ruby
|
|
113
|
+
create_table :new_model do |t|
|
|
114
|
+
t.timestamps null: false
|
|
115
|
+
end
|
|
116
|
+
SchemaValidations.relaxed!
|
|
117
|
+
NewModel.create!
|
|
118
|
+
```
|
|
119
|
+
|
|
108
120
|
### 0.5.5
|
|
109
121
|
|
|
110
122
|
* ignore geography fields
|
|
@@ -9,14 +9,26 @@
|
|
|
9
9
|
module SchemaValidations
|
|
10
10
|
extend ActiveSupport::Concern
|
|
11
11
|
|
|
12
|
+
mattr_accessor :relaxed, default: false
|
|
13
|
+
|
|
14
|
+
def self.relaxed!
|
|
15
|
+
self.relaxed = true
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def self.relaxed?
|
|
19
|
+
relaxed
|
|
20
|
+
end
|
|
21
|
+
|
|
12
22
|
included do
|
|
13
23
|
class_attribute :schema_validations_excluded_columns, default: %i[id created_at updated_at type]
|
|
14
24
|
class_attribute :schema_validations_called, default: false
|
|
15
25
|
|
|
16
26
|
if defined?(Rails::Railtie) && (Rails.env.development? || Rails.env.test?)
|
|
17
27
|
TracePoint.trace(:end) do |t|
|
|
18
|
-
if t.self.respond_to?(:schema_validations_called) &&
|
|
19
|
-
|
|
28
|
+
if t.self.respond_to?(:schema_validations_called) &&
|
|
29
|
+
t.self < ApplicationRecord &&
|
|
30
|
+
!t.self.schema_validations_called &&
|
|
31
|
+
!SchemaValidations.relaxed?
|
|
20
32
|
raise "#{t.self}: schema_validations or skip_schema_validations missing"
|
|
21
33
|
end
|
|
22
34
|
end
|
|
@@ -27,7 +39,12 @@ module SchemaValidations
|
|
|
27
39
|
def schema_validations(exclude: [], schema_table_name: table_name)
|
|
28
40
|
self.schema_validations_called = true
|
|
29
41
|
self.schema_validations_excluded_columns += exclude.map(&:to_sym)
|
|
30
|
-
|
|
42
|
+
|
|
43
|
+
if SchemaValidations.relaxed?
|
|
44
|
+
try("dbv_#{schema_table_name}_validations", enums: defined_enums.keys.map(&:to_sym))
|
|
45
|
+
else
|
|
46
|
+
send("dbv_#{schema_table_name}_validations", enums: defined_enums.keys.map(&:to_sym))
|
|
47
|
+
end
|
|
31
48
|
end
|
|
32
49
|
|
|
33
50
|
def skip_schema_validations
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: generated_schema_validations
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Georg Limbach
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-08-19 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: After each migration it generates a file with some validations. Each
|
|
14
14
|
active record should include this file and can uns generated validations.
|