database_validations 0.3.4 → 0.3.5
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c6d3b1af5cd99bc957bea1d45e2b09da1e10c779dd38b2c1b10b01bcdfd31b74
|
4
|
+
data.tar.gz: 73e67dbfbc0f5419cf1924014879d06ccbc57f08fcc6d815b448c89ce920cbad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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:
|
data/lib/database_validations.rb
CHANGED
@@ -3,8 +3,8 @@ module DatabaseValidations
|
|
3
3
|
module_function
|
4
4
|
|
5
5
|
def raise_if_index_missed!(model, columns)
|
6
|
-
|
7
|
-
|
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
|
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
|
+
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
|