postgresql-check 0.0.3 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -6
- data/lib/postgresql/check/schema_statements.rb +2 -2
- data/lib/postgresql/check/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f1048872dde6eb9e2fe0bdbce34da53c019ecc62
|
4
|
+
data.tar.gz: 223f215b01978b726f72d21146cb3c5dcca3ccb8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e09208d765f0717700ca88e88da3d3b5ea17c477e511fccd053ecaecd0d0d77e60c30130c4e3e0f8efe8c173e6d8d518f47a1d94ed8c128b6fa44a133dd679e2
|
7
|
+
data.tar.gz: dce6d419be2203db356b60ae728378c868ecd9eaac878a493fef165645ec25360073c6bc2ebf9b01ad2e0f002ef3868fca2d67c0aa33df497db4604db5950ccc
|
data/README.md
CHANGED
@@ -45,7 +45,7 @@ end
|
|
45
45
|
You can add a check constraint in your migration:
|
46
46
|
|
47
47
|
```ruby
|
48
|
-
add_check :products, 'price > 0', :name => '
|
48
|
+
add_check :products, 'price > 0', :name => 'products_price_check'
|
49
49
|
```
|
50
50
|
|
51
51
|
The code above generates following SQL:
|
@@ -54,13 +54,12 @@ The code above generates following SQL:
|
|
54
54
|
ALTER TABLE "products" ADD CONSTRAINT "products_price_check" (price > 0)
|
55
55
|
```
|
56
56
|
|
57
|
-
**NOTE**: `:name` option is mandatory now.
|
58
|
-
to constraint name.
|
57
|
+
**NOTE**: `:name` option is mandatory now.
|
59
58
|
|
60
59
|
To remove constraint use `remove_check` method:
|
61
60
|
|
62
61
|
```ruby
|
63
|
-
remove_check :products, :name => '
|
62
|
+
remove_check :products, :name => 'products_price_check'
|
64
63
|
```
|
65
64
|
|
66
65
|
## Change Table methods
|
@@ -70,7 +69,7 @@ This gem adds extra methods to `create_table` and `change_table`:
|
|
70
69
|
```ruby
|
71
70
|
create_table :products do |t|
|
72
71
|
t.decimal :price, :null => false
|
73
|
-
t.check 'price > 0', :name => '
|
72
|
+
t.check 'price > 0', :name => 'products_price_check'
|
74
73
|
end
|
75
74
|
```
|
76
75
|
|
@@ -78,7 +77,7 @@ Remove a check constraint:
|
|
78
77
|
|
79
78
|
```ruby
|
80
79
|
change_table :products do |t|
|
81
|
-
t.remove_check :name => '
|
80
|
+
t.remove_check :name => 'products_price_check'
|
82
81
|
end
|
83
82
|
```
|
84
83
|
|
@@ -27,7 +27,7 @@ module Postgresql
|
|
27
27
|
name = options.fetch(:name) { raise 'add_check, :name option required' }
|
28
28
|
|
29
29
|
sql = "ALTER TABLE #{quote_table_name(table_name)} " +
|
30
|
-
"ADD CONSTRAINT #{quote_column_name(
|
30
|
+
"ADD CONSTRAINT #{quote_column_name(name)} " +
|
31
31
|
"CHECK (#{condition})"
|
32
32
|
|
33
33
|
execute(sql)
|
@@ -49,7 +49,7 @@ module Postgresql
|
|
49
49
|
name = options.fetch(:name) { raise 'remove_check, :name option required' }
|
50
50
|
|
51
51
|
sql = "ALTER TABLE #{quote_table_name(table_name)} " +
|
52
|
-
"DROP CONSTRAINT #{quote_column_name(
|
52
|
+
"DROP CONSTRAINT #{quote_column_name(name)}"
|
53
53
|
|
54
54
|
execute(sql)
|
55
55
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: postgresql-check
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexei Mikhailov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-03-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -94,9 +94,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
94
94
|
version: '0'
|
95
95
|
requirements: []
|
96
96
|
rubyforge_project:
|
97
|
-
rubygems_version: 2.
|
97
|
+
rubygems_version: 2.4.3
|
98
98
|
signing_key:
|
99
99
|
specification_version: 4
|
100
100
|
summary: Adds helpers to migrations and dumps check constraints to schema.rb
|
101
101
|
test_files: []
|
102
|
-
has_rdoc:
|