rein 3.5.0 → 4.0.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
- SHA1:
3
- metadata.gz: db87ecd5f3ef8896a90c53689fa261d1ca6e0724
4
- data.tar.gz: 6c338b26471381194a48a923669651f089a0a81e
2
+ SHA256:
3
+ metadata.gz: 24623f32cadd63604381d8dad8884880eae0bd4b14e9cbe9b374e35f95bf75a1
4
+ data.tar.gz: b6dcaf5464e761520a435e4bc16c6a4476b229dd9bccae99e135931ed169acdd
5
5
  SHA512:
6
- metadata.gz: 0b4f9479e4c12ed154ed845d1074e8884206968f85aa91087885b9e36f4d92493ce859f6958e199b0633ff3c31fdfcccda43354a4b0a42501bd6d472c2913ed9
7
- data.tar.gz: 9a85f0eae72cbbb60cca617ea5d40aa5a2d1e80f0310de72b0fc75688701ff098826da881a81015c795235d9958cfdc4cbee3e4b32a23a4c20e1df4cd9c872bd
6
+ metadata.gz: ff7356d2879f6e6a485d2978fdef2dafe2eb0e3e26e1ea1574dda769b0e1026f474c34f1d141ecb1ae92e2736de7348544df70fdc11445c3c39895e4b7b1aaf1
7
+ data.tar.gz: f0ce01bb2a2033370962318d8a49719763df2b5b1fbc46ffe381ba582a294a58c7dcb610bb766ca8213d70ea4f29ff06e9d479691a65f537a598e4ffff59a1f7
@@ -1,50 +1,56 @@
1
- # Changelog
1
+ ## 4.0.0 (2019-01-28)
2
2
 
3
- ## 3.5.0 / 2018-05-09
3
+ * Add exclusion constraints
4
+ * Add check constraints
4
5
 
5
- * Add support for ActiveRecord 5.2
6
+ ## 3.5.0 (2018-05-09)
6
7
 
7
- ## 3.4.0 / 2018-03-23
8
+ * Add support for ActiveRecord 5.2
8
9
 
9
- * Wrap column and table names in foreign key constraints
10
+ ## 3.4.0 (2018-03-23)
11
+
12
+ * Wrap column and table names in foreign key constraints
10
13
 
11
14
  ## 3.3.0
12
- - Add unique constraint.
15
+
16
+ * Add unique constraint
13
17
 
14
18
  ## 3.2.0
15
- - Add match constraint.
16
- - Fix the rollback of change view migrations.
19
+
20
+ * Add match constraint
21
+ * Fix the rollback of change view migrations
17
22
 
18
23
  ## 3.1.0
19
- - Add length constraint.
24
+
25
+ * Add length constraint
20
26
 
21
27
  ## 3.0.0
22
28
 
23
- - Dropped MySQL support.
24
- - Reversible migrations.
25
- - Add `index` option to `add_foreign_key_constraint`.
29
+ * Dropped MySQL support
30
+ * Reversible migrations
31
+ * Add `index` option to `add_foreign_key_constraint`
26
32
 
27
33
  ## 2.1.0
28
34
 
29
- - Add `if` option to inclusion constraints.
30
- - Add `name` option to constraints.
31
- - Add null constraint.
32
- - Ensure presence constraint enforces not null.
35
+ * Add `if` option to inclusion constraints
36
+ * Add `name` option to constraints
37
+ * Add null constraint
38
+ * Ensure presence constraint enforces not null
33
39
 
34
40
  ## 2.0.0
35
41
 
36
- - Add support for enumerated types.
37
- - Add `if` option to numericality constraints.
38
- - Add `if` option to presence constraints.
39
- - Fix a bug in presence contraints.
42
+ * Add support for enumerated types
43
+ * Add `if` option to numericality constraints
44
+ * Add `if` option to presence constraints
45
+ * Fix a bug in presence contraints
40
46
 
41
47
  ## 1.1.0
42
48
 
43
- - Update README.
44
- - Code cleanups.
45
- - Disable monkey patching in rspec.
49
+ * Update README
50
+ * Code cleanups
51
+ * Disable monkey patching in rspec
46
52
 
47
53
  ## 1.0.0
48
54
 
49
- - Fix `Mysql2Adapter` for Rails 3.2.
50
- - Add `column` option to `add_primary_key`.
55
+ * Fix `Mysql2Adapter` for Rails 3.2
56
+ * Add `column` option to `add_primary_key`
data/README.md CHANGED
@@ -21,12 +21,14 @@ advantage of reversible Rails migrations.
21
21
  * [Constraint Types](#constraint-types)
22
22
  * [Foreign Key Constraints](#foreign-key-constraints)
23
23
  * [Unique Constraints](#unique-constraints)
24
+ * [Exclusion Constraints](#exclusion-constraints)
24
25
  * [Inclusion Constraints](#inclusion-constraints)
25
26
  * [Length Constraints](#length-constraints)
26
27
  * [Match Constraints](#match-constraints)
27
28
  * [Numericality Constraints](#numericality-constraints)
28
29
  * [Presence Constraints](#presence-constraints)
29
30
  * [Null Constraints](#null-constraints)
31
+ * [Check Constraints](#check-constraints)
30
32
  * [Data Types](#data-types)
31
33
  * [Enumerated Types](#enumerated-types)
32
34
  * [Views](#views)
@@ -159,6 +161,58 @@ a transaction, then you can set the `deferrable` option to `false`:
159
161
  add_unique_constraint :authors, :name, deferrable: false
160
162
  ```
161
163
 
164
+ ### Exclusion Constraints
165
+
166
+ An exclusion constraint is a lot like a unique constraint, but more general.
167
+ Whereas a unique constraint forbids two rows from having all constrained columns be *equal*,
168
+ an exclusion constraint forbids two rows from having all constrained columns be *some relationship*,
169
+ where the relationship is up to you (and can be different for each column).
170
+ For instance you can prevent two ranges from overlapping with the `&&` operator.
171
+ You can read more in
172
+ [the Postgres docs](https://www.postgresql.org/docs/9.0/static/ddl-constraints.html#DDL-CONSTRAINTS-EXCLUSION)
173
+ or [a slideshow by the author, Jeff Davis](https://www.slideshare.net/pgconf/not-just-unique-exclusion-constraints).
174
+
175
+ For example, no two people should own copyright to a book at the same time:
176
+
177
+ ```ruby
178
+ add_exclusion_constraint :book_owners, [[:book_id, '='], [:owned_during, '&&']], using: :gist
179
+ ```
180
+
181
+ By default, the database checks exclusion constraints immediately (i.e. as soon as
182
+ a record is created or updated). If a record with an excluded value exists,
183
+ then the database will raise an error.
184
+
185
+ Sometimes it is necessary to wait until the end of a transaction to do the
186
+ checking (e.g. maybe you want to move the date a copyright changed hands). To do so, you
187
+ need to tell the database to *defer* checking the constraint until the end of
188
+ the current transaction:
189
+
190
+ ```sql
191
+ BEGIN;
192
+ SET CONSTRAINTS book_owners_exclude DEFERRED;
193
+ UPDATE book_owners
194
+ SET owned_during = tsrange(lower(owned_during), '1943-12-22')
195
+ WHERE book_id = 1 AND owner_id = 1;
196
+ UPDATE book_owners
197
+ SET owned_during = tsrange('1943-12-22', upper(owned_during))
198
+ WHERE book_id = 1 AND owner_id = 2;
199
+ COMMIT;
200
+ ```
201
+
202
+ If you *always* want to defer checking a unique constraint, then you can set
203
+ the `deferred` option to `true`:
204
+
205
+ ```ruby
206
+ add_exclusion_constraint :book_owners, [[:book_id, '='], [:owned_during, '&&']], using: :gist, deferred: true
207
+ ```
208
+
209
+ If you really don't want the ability to optionally defer a unique constraint in
210
+ a transaction, then you can set the `deferrable` option to `false`:
211
+
212
+ ```ruby
213
+ add_exclusion_constraint :book_owners, [[:book_id, '='], [:owned_during, '&&']], using: :gist, deferrable: false
214
+ ```
215
+
162
216
  ### Inclusion Constraints
163
217
 
164
218
  An inclusion constraint specifies the possible values that a column value can
@@ -370,6 +424,26 @@ To remove a null constraint:
370
424
  remove_null_constraint :books, :due_date
371
425
  ```
372
426
 
427
+ ### Check Constraints
428
+
429
+ A check constraint lets you enforce any predicate about the current row.
430
+ You can use this if none of the other higher-level constraint types work for you.
431
+
432
+ For example, we can add a constraint to enforce that a book's title
433
+ never starts with an "r":
434
+
435
+ ```ruby
436
+ add_check_constraint :books, "substring(title FROM 1 FOR 1) IS DISTINCT FROM 'r'", name: 'no_r_titles'
437
+ ```
438
+
439
+ Note these types must have a `name` option.
440
+
441
+ To remove a check constraint:
442
+
443
+ ```ruby
444
+ remove_check_constraint :books, "substring(title FROM 1 FOR 1) IS DISTINCT FROM 'r'", name: 'no_r_titles'
445
+ ```
446
+
373
447
  ## Data Types
374
448
 
375
449
  ### Enumerated Types
@@ -1,4 +1,5 @@
1
1
  require 'active_record'
2
+ require 'rein/constraint/check'
2
3
  require 'rein/constraint/foreign_key'
3
4
  require 'rein/constraint/inclusion'
4
5
  require 'rein/constraint/length'
@@ -8,12 +9,14 @@ require 'rein/constraint/numericality'
8
9
  require 'rein/constraint/presence'
9
10
  require 'rein/constraint/primary_key'
10
11
  require 'rein/constraint/unique'
12
+ require 'rein/constraint/exclusion'
11
13
  require 'rein/schema'
12
14
  require 'rein/type/enum'
13
15
  require 'rein/view'
14
16
 
15
17
  module ActiveRecord
16
18
  class Migration # :nodoc:
19
+ include Rein::Constraint::Check
17
20
  include Rein::Constraint::ForeignKey
18
21
  include Rein::Constraint::Inclusion
19
22
  include Rein::Constraint::Length
@@ -23,6 +26,7 @@ module ActiveRecord
23
26
  include Rein::Constraint::Presence
24
27
  include Rein::Constraint::PrimaryKey
25
28
  include Rein::Constraint::Unique
29
+ include Rein::Constraint::Exclusion
26
30
  include Rein::Schema
27
31
  include Rein::Type::Enum
28
32
  include Rein::View
@@ -0,0 +1,40 @@
1
+ require 'active_support/inflector'
2
+ require 'rein/util'
3
+
4
+ module Rein
5
+ module Constraint
6
+ # This module contains methods for defining check constraints.
7
+ module Check
8
+ def add_check_constraint(*args)
9
+ reversible do |dir|
10
+ dir.up { _add_check_constraint(*args) }
11
+ dir.down { _remove_check_constraint(*args) }
12
+ end
13
+ end
14
+
15
+ def remove_check_constraint(*args)
16
+ reversible do |dir|
17
+ dir.up { _remove_check_constraint(*args) }
18
+ dir.down { _add_check_constraint(*args) }
19
+ end
20
+ end
21
+
22
+ private
23
+
24
+ def _add_check_constraint(table_name, predicate, options = {})
25
+ raise 'Generic CHECK constraints must have a name' unless options[:name].present?
26
+ name = Util.wrap_identifier(options[:name])
27
+ sql = "ALTER TABLE #{Util.wrap_identifier(table_name)}"
28
+ sql << " ADD CONSTRAINT #{name}"
29
+ sql << " CHECK (#{predicate})"
30
+ execute(sql)
31
+ end
32
+
33
+ def _remove_check_constraint(table_name, _predicate, options = {})
34
+ raise 'Generic CHECK constraints must have a name' unless options[:name].present?
35
+ name = Util.wrap_identifier(options[:name])
36
+ execute("ALTER TABLE #{Util.wrap_identifier(table_name)} DROP CONSTRAINT #{name}")
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,61 @@
1
+ require 'rein/util'
2
+
3
+ module Rein
4
+ module Constraint
5
+ # This module contains methods for defining exclusion constraints.
6
+ module Exclusion
7
+ include ActiveRecord::ConnectionAdapters::Quoting
8
+
9
+ def add_exclusion_constraint(*args)
10
+ reversible do |dir|
11
+ dir.up { _add_exclusion_constraint_adapter(*args) }
12
+ dir.down { _remove_exclusion_constraint_adapter(*args) }
13
+ end
14
+ end
15
+
16
+ def remove_exclusion_constraint(*args)
17
+ reversible do |dir|
18
+ dir.up { _remove_exclusion_constraint_adapter(*args) }
19
+ dir.down { _add_exclusion_constraint_adapter(*args) }
20
+ end
21
+ end
22
+
23
+ private
24
+
25
+ def _add_exclusion_constraint_adapter(*args)
26
+ if args[1].is_a? Array
27
+ _add_exclusion_constraint(*args)
28
+ else
29
+ _add_exclusion_constraint(args[0], [[args[1], args[2]]], args[3] || {})
30
+ end
31
+ end
32
+
33
+ def _remove_exclusion_constraint_adapter(*args)
34
+ if args[1].is_a? Array
35
+ _remove_exclusion_constraint(*args)
36
+ else
37
+ _remove_exclusion_constraint(args[0], [[args[1], args[2]]], args[3] || {})
38
+ end
39
+ end
40
+
41
+ def _add_exclusion_constraint(table, attributes, options = {})
42
+ name = Util.constraint_name(table, attributes.map { |att| att[0] }.join('_'), 'exclude', options)
43
+ table = Util.wrap_identifier(table)
44
+ attributes = attributes.map do |attribute|
45
+ "#{Util.wrap_identifier(attribute[0])} WITH #{attribute[1]}"
46
+ end
47
+ initially = options[:deferred] ? 'DEFERRED' : 'IMMEDIATE'
48
+ using = options[:using] ? " USING #{options[:using]}" : ''
49
+ sql = "ALTER TABLE #{table} ADD CONSTRAINT #{name} EXCLUDE#{using} (#{attributes.join(', ')})"
50
+ sql << " DEFERRABLE INITIALLY #{initially}" unless options[:deferrable] == false
51
+ execute(sql)
52
+ end
53
+
54
+ def _remove_exclusion_constraint(table, attributes, options = {})
55
+ name = Util.constraint_name(table, attributes.map { |att| att[0] }.join('_'), 'exclude', options)
56
+ table = Util.wrap_identifier(table)
57
+ execute("ALTER TABLE #{table} DROP CONSTRAINT #{name}")
58
+ end
59
+ end
60
+ end
61
+ end
@@ -7,14 +7,14 @@ module Rein
7
7
  module ForeignKey
8
8
  def add_foreign_key_constraint(*args)
9
9
  reversible do |dir|
10
- dir.up do _add_foreign_key_constraint(*args) end
10
+ dir.up { _add_foreign_key_constraint(*args) }
11
11
  dir.down { _remove_foreign_key_constraint(*args) }
12
12
  end
13
13
  end
14
14
 
15
15
  def remove_foreign_key_constraint(*args)
16
16
  reversible do |dir|
17
- dir.up do _remove_foreign_key_constraint(*args) end
17
+ dir.up { _remove_foreign_key_constraint(*args) }
18
18
  dir.down { _add_foreign_key_constraint(*args) }
19
19
  end
20
20
  end
@@ -8,14 +8,14 @@ module Rein
8
8
 
9
9
  def add_inclusion_constraint(*args)
10
10
  reversible do |dir|
11
- dir.up do _add_inclusion_constraint(*args) end
11
+ dir.up { _add_inclusion_constraint(*args) }
12
12
  dir.down { _remove_inclusion_constraint(*args) }
13
13
  end
14
14
  end
15
15
 
16
16
  def remove_inclusion_constraint(*args)
17
17
  reversible do |dir|
18
- dir.up do _remove_inclusion_constraint(*args) end
18
+ dir.up { _remove_inclusion_constraint(*args) }
19
19
  dir.down { _add_inclusion_constraint(*args) }
20
20
  end
21
21
  end
@@ -15,14 +15,14 @@ module Rein
15
15
 
16
16
  def add_length_constraint(*args)
17
17
  reversible do |dir|
18
- dir.up do _add_length_constraint(*args) end
18
+ dir.up { _add_length_constraint(*args) }
19
19
  dir.down { _remove_length_constraint(*args) }
20
20
  end
21
21
  end
22
22
 
23
23
  def remove_length_constraint(*args)
24
24
  reversible do |dir|
25
- dir.up do _remove_length_constraint(*args) end
25
+ dir.up { _remove_length_constraint(*args) }
26
26
  dir.down { _add_length_constraint(*args) }
27
27
  end
28
28
  end
@@ -34,10 +34,10 @@ module Rein
34
34
  table = Util.wrap_identifier(table)
35
35
  attribute = Util.wrap_identifier(attribute)
36
36
  attribute_length = "length(#{attribute})"
37
- conditions = OPERATORS.slice(*options.keys).map { |key, operator|
37
+ conditions = OPERATORS.slice(*options.keys).map do |key, operator|
38
38
  value = options[key]
39
39
  [attribute_length, operator, value].join(' ')
40
- }.join(' AND ')
40
+ end.join(' AND ')
41
41
  conditions = Util.conditions_with_if(conditions, options)
42
42
  execute("ALTER TABLE #{table} ADD CONSTRAINT #{name} CHECK (#{conditions})")
43
43
  end
@@ -13,14 +13,14 @@ module Rein
13
13
 
14
14
  def add_match_constraint(*args)
15
15
  reversible do |dir|
16
- dir.up do _add_match_constraint(*args) end
16
+ dir.up { _add_match_constraint(*args) }
17
17
  dir.down { _remove_match_constraint(*args) }
18
18
  end
19
19
  end
20
20
 
21
21
  def remove_match_constraint(*args)
22
22
  reversible do |dir|
23
- dir.up do _remove_match_constraint(*args) end
23
+ dir.up { _remove_match_constraint(*args) }
24
24
  dir.down { _add_match_constraint(*args) }
25
25
  end
26
26
  end
@@ -31,10 +31,10 @@ module Rein
31
31
  name = Util.constraint_name(table, attribute, 'match', options)
32
32
  table = Util.wrap_identifier(table)
33
33
  attribute = Util.wrap_identifier(attribute)
34
- conditions = OPERATORS.slice(*options.keys).map { |key, operator|
34
+ conditions = OPERATORS.slice(*options.keys).map do |key, operator|
35
35
  value = options[key]
36
36
  [attribute, operator, "'#{value}'"].join(' ')
37
- }.join(' AND ')
37
+ end.join(' AND ')
38
38
  conditions = Util.conditions_with_if(conditions, options)
39
39
  execute("ALTER TABLE #{table} ADD CONSTRAINT #{name} CHECK (#{conditions})")
40
40
  end
@@ -8,14 +8,14 @@ module Rein
8
8
 
9
9
  def add_null_constraint(*args)
10
10
  reversible do |dir|
11
- dir.up do _add_null_constraint(*args) end
11
+ dir.up { _add_null_constraint(*args) }
12
12
  dir.down { _remove_null_constraint(*args) }
13
13
  end
14
14
  end
15
15
 
16
16
  def remove_null_constraint(*args)
17
17
  reversible do |dir|
18
- dir.up do _remove_null_constraint(*args) end
18
+ dir.up { _remove_null_constraint(*args) }
19
19
  dir.down { _add_null_constraint(*args) }
20
20
  end
21
21
  end
@@ -15,14 +15,14 @@ module Rein
15
15
 
16
16
  def add_numericality_constraint(*args)
17
17
  reversible do |dir|
18
- dir.up do _add_numericality_constraint(*args) end
18
+ dir.up { _add_numericality_constraint(*args) }
19
19
  dir.down { _remove_numericality_constraint(*args) }
20
20
  end
21
21
  end
22
22
 
23
23
  def remove_numericality_constraint(*args)
24
24
  reversible do |dir|
25
- dir.up do _remove_numericality_constraint(*args) end
25
+ dir.up { _remove_numericality_constraint(*args) }
26
26
  dir.down { _add_numericality_constraint(*args) }
27
27
  end
28
28
  end
@@ -33,10 +33,10 @@ module Rein
33
33
  name = Util.constraint_name(table, attribute, 'numericality', options)
34
34
  table = Util.wrap_identifier(table)
35
35
  attribute = Util.wrap_identifier(attribute)
36
- conditions = OPERATORS.slice(*options.keys).map { |key, operator|
36
+ conditions = OPERATORS.slice(*options.keys).map do |key, operator|
37
37
  value = options[key]
38
38
  [attribute, operator, value].join(' ')
39
- }.join(' AND ')
39
+ end.join(' AND ')
40
40
  conditions = Util.conditions_with_if(conditions, options)
41
41
  execute("ALTER TABLE #{table} ADD CONSTRAINT #{name} CHECK (#{conditions})")
42
42
  end
@@ -8,14 +8,14 @@ module Rein
8
8
 
9
9
  def add_presence_constraint(*args)
10
10
  reversible do |dir|
11
- dir.up do _add_presence_constraint(*args) end
11
+ dir.up { _add_presence_constraint(*args) }
12
12
  dir.down { _remove_presence_constraint(*args) }
13
13
  end
14
14
  end
15
15
 
16
16
  def remove_presence_constraint(*args)
17
17
  reversible do |dir|
18
- dir.up do _remove_presence_constraint(*args) end
18
+ dir.up { _remove_presence_constraint(*args) }
19
19
  dir.down { _add_presence_constraint(*args) }
20
20
  end
21
21
  end
@@ -4,14 +4,14 @@ module Rein
4
4
  module PrimaryKey
5
5
  def add_primary_key(*args)
6
6
  reversible do |dir|
7
- dir.up do _add_primary_key(*args) end
7
+ dir.up { _add_primary_key(*args) }
8
8
  dir.down { _remove_primary_key(*args) }
9
9
  end
10
10
  end
11
11
 
12
12
  def remove_primary_key(*args)
13
13
  reversible do |dir|
14
- dir.up do _remove_primary_key(*args) end
14
+ dir.up { _remove_primary_key(*args) }
15
15
  dir.down { _add_primary_key(*args) }
16
16
  end
17
17
  end
@@ -8,14 +8,14 @@ module Rein
8
8
 
9
9
  def add_unique_constraint(*args)
10
10
  reversible do |dir|
11
- dir.up do _add_unique_constraint(*args) end
11
+ dir.up { _add_unique_constraint(*args) }
12
12
  dir.down { _remove_unique_constraint(*args) }
13
13
  end
14
14
  end
15
15
 
16
16
  def remove_unique_constraint(*args)
17
17
  reversible do |dir|
18
- dir.up do _remove_unique_constraint(*args) end
18
+ dir.up { _remove_unique_constraint(*args) }
19
19
  dir.down { _add_unique_constraint(*args) }
20
20
  end
21
21
  end
@@ -3,14 +3,14 @@ module Rein
3
3
  module Schema
4
4
  def create_schema(*args)
5
5
  reversible do |dir|
6
- dir.up do _create_schema(*args) end
6
+ dir.up { _create_schema(*args) }
7
7
  dir.down { _drop_schema(*args) }
8
8
  end
9
9
  end
10
10
 
11
11
  def drop_schema(*args)
12
12
  reversible do |dir|
13
- dir.up do _drop_schema(*args) end
13
+ dir.up { _drop_schema(*args) }
14
14
  dir.down { _create_schema(*args) }
15
15
  end
16
16
  end
@@ -8,14 +8,14 @@ module Rein
8
8
 
9
9
  def create_enum_type(*args)
10
10
  reversible do |dir|
11
- dir.up do _create_enum_type(*args) end
11
+ dir.up { _create_enum_type(*args) }
12
12
  dir.down { _drop_enum_type(*args) }
13
13
  end
14
14
  end
15
15
 
16
16
  def drop_enum_type(*args)
17
17
  reversible do |dir|
18
- dir.up do _drop_enum_type(*args) end
18
+ dir.up { _drop_enum_type(*args) }
19
19
  dir.down { _create_enum_type(*args) }
20
20
  end
21
21
  end
@@ -31,7 +31,7 @@ module Rein
31
31
  execute("CREATE TYPE #{enum_name} AS ENUM (#{enum_values})")
32
32
  end
33
33
 
34
- def _drop_enum_type(enum_name)
34
+ def _drop_enum_type(enum_name, *)
35
35
  execute("DROP TYPE #{enum_name}")
36
36
  end
37
37
  end
@@ -1,3 +1,3 @@
1
1
  module Rein
2
- VERSION = '3.5.0'.freeze
2
+ VERSION = '4.0.0'.freeze
3
3
  end
@@ -3,14 +3,14 @@ module Rein
3
3
  module View
4
4
  def create_view(*args)
5
5
  reversible do |dir|
6
- dir.up do _create_view(*args) end
6
+ dir.up { _create_view(*args) }
7
7
  dir.down { _drop_view(*args) }
8
8
  end
9
9
  end
10
10
 
11
11
  def drop_view(*args)
12
12
  reversible do |dir|
13
- dir.up do _drop_view(*args) end
13
+ dir.up { _drop_view(*args) }
14
14
  dir.down { _create_view(*args) }
15
15
  end
16
16
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rein
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.5.0
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Bassett
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-09 00:00:00.000000000 Z
11
+ date: 2019-01-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -56,84 +56,84 @@ dependencies:
56
56
  requirements:
57
57
  - - "~>"
58
58
  - !ruby/object:Gem::Version
59
- version: '2.2'
59
+ version: 2.2.0
60
60
  type: :development
61
61
  prerelease: false
62
62
  version_requirements: !ruby/object:Gem::Requirement
63
63
  requirements:
64
64
  - - "~>"
65
65
  - !ruby/object:Gem::Version
66
- version: '2.2'
66
+ version: 2.2.0
67
67
  - !ruby/object:Gem::Dependency
68
- name: bundler
68
+ name: pg
69
69
  requirement: !ruby/object:Gem::Requirement
70
70
  requirements:
71
71
  - - "~>"
72
72
  - !ruby/object:Gem::Version
73
- version: '1.16'
73
+ version: 0.21.0
74
74
  type: :development
75
75
  prerelease: false
76
76
  version_requirements: !ruby/object:Gem::Requirement
77
77
  requirements:
78
78
  - - "~>"
79
79
  - !ruby/object:Gem::Version
80
- version: '1.16'
80
+ version: 0.21.0
81
81
  - !ruby/object:Gem::Dependency
82
- name: pg
82
+ name: bundler
83
83
  requirement: !ruby/object:Gem::Requirement
84
84
  requirements:
85
85
  - - "~>"
86
86
  - !ruby/object:Gem::Version
87
- version: '0.21'
87
+ version: 2.0.1
88
88
  type: :development
89
89
  prerelease: false
90
90
  version_requirements: !ruby/object:Gem::Requirement
91
91
  requirements:
92
92
  - - "~>"
93
93
  - !ruby/object:Gem::Version
94
- version: '0.21'
94
+ version: 2.0.1
95
95
  - !ruby/object:Gem::Dependency
96
96
  name: rake
97
97
  requirement: !ruby/object:Gem::Requirement
98
98
  requirements:
99
99
  - - "~>"
100
100
  - !ruby/object:Gem::Version
101
- version: '12.3'
101
+ version: 12.3.2
102
102
  type: :development
103
103
  prerelease: false
104
104
  version_requirements: !ruby/object:Gem::Requirement
105
105
  requirements:
106
106
  - - "~>"
107
107
  - !ruby/object:Gem::Version
108
- version: '12.3'
108
+ version: 12.3.2
109
109
  - !ruby/object:Gem::Dependency
110
110
  name: rspec
111
111
  requirement: !ruby/object:Gem::Requirement
112
112
  requirements:
113
113
  - - "~>"
114
114
  - !ruby/object:Gem::Version
115
- version: '3.7'
115
+ version: 3.8.0
116
116
  type: :development
117
117
  prerelease: false
118
118
  version_requirements: !ruby/object:Gem::Requirement
119
119
  requirements:
120
120
  - - "~>"
121
121
  - !ruby/object:Gem::Version
122
- version: '3.7'
122
+ version: 3.8.0
123
123
  - !ruby/object:Gem::Dependency
124
124
  name: rubocop
125
125
  requirement: !ruby/object:Gem::Requirement
126
126
  requirements:
127
127
  - - "~>"
128
128
  - !ruby/object:Gem::Version
129
- version: '0.51'
129
+ version: 0.63.1
130
130
  type: :development
131
131
  prerelease: false
132
132
  version_requirements: !ruby/object:Gem::Requirement
133
133
  requirements:
134
134
  - - "~>"
135
135
  - !ruby/object:Gem::Version
136
- version: '0.51'
136
+ version: 0.63.1
137
137
  description: Rein adds bunch of methods to your ActiveRecord migrations so you can
138
138
  easily tame your database.
139
139
  email: josh.bassett@gmail.com
@@ -145,6 +145,8 @@ files:
145
145
  - LICENSE.md
146
146
  - README.md
147
147
  - lib/rein.rb
148
+ - lib/rein/constraint/check.rb
149
+ - lib/rein/constraint/exclusion.rb
148
150
  - lib/rein/constraint/foreign_key.rb
149
151
  - lib/rein/constraint/inclusion.rb
150
152
  - lib/rein/constraint/length.rb
@@ -178,8 +180,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
178
180
  - !ruby/object:Gem::Version
179
181
  version: '0'
180
182
  requirements: []
181
- rubyforge_project:
182
- rubygems_version: 2.6.13
183
+ rubygems_version: 3.0.0
183
184
  signing_key:
184
185
  specification_version: 4
185
186
  summary: Database constraints made easy for ActiveRecord.