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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5132d3be501617c0096cedc576b6d9167643b90c7fcca7023fb21117e78ecc42
4
- data.tar.gz: '095f22b4ff3e06758bf03a1c271cf27d3c504370bafc41c5f47710ac9ba626c3'
3
+ metadata.gz: 8d682dd2bd139df00dace4687523703c49ab9f139c8a62f4360b584844ee22af
4
+ data.tar.gz: 46c6c3531d0dd45f4e4c2a92ff98825f961e914916a9970f5d161f53e172250e
5
5
  SHA512:
6
- metadata.gz: a227d2c716e5b9c05cd6349305b1dbaed35f567bfc72ee35d0ba0490e112016a4e4392f0e84792ab733b86b17e61385b271408cdd2af4808465ebc2b4110c40a
7
- data.tar.gz: 4f329cd8c928056756df0dba6048e94c34b0de3a310dd8abc9d2f91cda1b11351837af4b1f3cb158c5e0ba459211736a50e7e77e4c9925b17fff8cf4a14a974d
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
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'generated_schema_validations'
5
- spec.version = '0.5.5'
5
+ spec.version = '0.6.0'
6
6
  spec.authors = ['Georg Limbach']
7
7
  spec.email = ['georg.limbach@lichtbit.com']
8
8
 
@@ -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) && t.self < ApplicationRecord &&
19
- !t.self.schema_validations_called
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
- send("dbv_#{schema_table_name}_validations", enums: defined_enums.keys.map(&:to_sym))
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.5.5
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-04-15 00:00:00.000000000 Z
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.