database_validations 0.3.4 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5be0a1cf5c74a0aa6744a86a14aa6a81707dc767dac4009706d882a6bbd43f86
4
- data.tar.gz: 1e278b7a7399acc9305465129c68f7e8970d4dc283d5586a8531cb8fd0103369
3
+ metadata.gz: c6d3b1af5cd99bc957bea1d45e2b09da1e10c779dd38b2c1b10b01bcdfd31b74
4
+ data.tar.gz: 73e67dbfbc0f5419cf1924014879d06ccbc57f08fcc6d815b448c89ce920cbad
5
5
  SHA512:
6
- metadata.gz: 5080c42455f88a031b2cbefd620637c3312b576d7ba1af781c1d179b362d93194cd3f892693a07cfbc666c6bf98911ab0f302a6b1ef8bacd9d1b6ea88159717c
7
- data.tar.gz: 7f83a786582d700407fe95a092a3675e9444b7a25265379befd16972462d528c7f9784ea992480124c8d889dc3e9492520f44c9b0ca07fad08451e9766aafc02
6
+ metadata.gz: 78aaad9c51875b7cd10ef7239ad46b51339b144c32cd07bbcd577bd3b76353582bc64aca374d5f21e444d051dca6f3bfeb060b83f3c94442facd443dfc56113d
7
+ data.tar.gz: 54c9fd499505ce6ce6e05db0619c800668cf7a1c6246e3ed02d569be35195e7fbb22e3d691c8fd59e05c1953bb194e793e238d99e7967ccd74a7acab7326cfad
data/README.md CHANGED
@@ -31,7 +31,8 @@ Supported databases: `postgresql`, `mysql` and `sqlite`.
31
31
 
32
32
  Advantages:
33
33
  - Provides true uniqueness on the database level because it handles race conditions cases properly.
34
- - Check the existence of correct unique index at the boot time.
34
+ - Check the existence of correct unique index at the boot time. Use `ENV['SKIP_DB_UNIQUENESS_VALIDATOR_INDEX_CHECK'] = 'true'`
35
+ if you want to skip it in some cases.
35
36
  - It's faster. See [Benchmark](https://github.com/toptal/database_validations#benchmark-code) section for details.
36
37
 
37
38
  Disadvantages:
@@ -1,6 +1,7 @@
1
1
  require 'active_record'
2
2
 
3
3
  require 'database_validations/version'
4
+ require 'database_validations/railtie' if defined?(Rails)
4
5
  require 'database_validations/uniqueness_validator'
5
6
  require 'database_validations/errors'
6
7
  require 'database_validations/helpers'
@@ -3,8 +3,8 @@ module DatabaseValidations
3
3
  module_function
4
4
 
5
5
  def raise_if_index_missed!(model, columns)
6
- connection = model.connection rescue return
7
- index = connection.indexes(model.table_name)
6
+ index = model.connection
7
+ .indexes(model.table_name)
8
8
  .select(&:unique)
9
9
  .find { |index| index.columns.map(&:to_s).sort == columns }
10
10
 
@@ -0,0 +1,15 @@
1
+ require 'active_record/railtie'
2
+
3
+ module StrongMigrations
4
+ class Railtie < Rails::Railtie
5
+ rake_tasks do
6
+ load 'tasks/database_validations.rake'
7
+
8
+ Rake.application.in_namespace(:db) do |namespace|
9
+ namespace.tasks.each do |task|
10
+ task.enhance %w[database_validations:skip_db_uniqueness_validator_index_check]
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -1,3 +1,3 @@
1
1
  module DatabaseValidations
2
- VERSION = "0.3.4"
2
+ VERSION = "0.3.5"
3
3
  end
@@ -0,0 +1,5 @@
1
+ namespace :database_validations do
2
+ task :skip_db_uniqueness_validator_index_check do
3
+ ENV['SKIP_DB_UNIQUENESS_VALIDATOR_INDEX_CHECK'] = 'true'
4
+ end
5
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: database_validations
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evgeniy Demin
@@ -151,8 +151,10 @@ files:
151
151
  - lib/database_validations/adapters/sqlite_adapter.rb
152
152
  - lib/database_validations/errors.rb
153
153
  - lib/database_validations/helpers.rb
154
+ - lib/database_validations/railtie.rb
154
155
  - lib/database_validations/uniqueness_validator.rb
155
156
  - lib/database_validations/version.rb
157
+ - lib/tasks/database_validations.rake
156
158
  homepage: https://github.com/toptal/database_validations
157
159
  licenses:
158
160
  - MIT