Skip to content

Commit 62b28e1

Browse files
authored
Merge pull request #1 from nepalez/chore/docs
Fix inline docs for methods added to ActiveRecord::Migration
2 parents a955332 + 3393450 commit 62b28e1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1755
-1621
lines changed

Diff for: CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ The noteworthy changes for each PGTrunk version are included here.
44
The format is based on [Keep a Changelog] and this project adheres to [Semantic Versioning].
55
For a complete changelog, see the [commits] for each version via the version links.
66

7+
## [0.1.1] (2022-01-16)
8+
9+
* Fix inline documentation for methods added to ActiveRecord::Migration
10+
711
## [0.1.0] (2022-01-14)
812

913
This is a first public release (nepalez)
@@ -24,6 +28,7 @@ Supported features:
2428
- composite types
2529
- domains types
2630

31+
[0.1.1]: https://github.com/nepalez/pg_trunk/releases/tag/v0.1.1
2732
[0.1.0]: https://github.com/nepalez/pg_trunk/releases/tag/v0.1.0
2833

2934
[Keep a Changelog]: http://keepachangelog.com/

Diff for: lib/pg_trunk/operations/check_constraints/add_check_constraint.rb

+36-33
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,42 @@
11
# frozen_string_literal: false
22

3-
# @!method ActiveRecord::Migration#add_check_constraint(table, expression = nil, **options, &block)
4-
# Add a check constraint to the table
5-
#
6-
# @param [#to_s] table (nil) The qualified name of the table
7-
# @param [#to_s] expression (nil) The SQL expression
8-
# @option [#to_s] :name (nil) The optional name of the constraint
9-
# @option [Boolean] :inherit (true) If the constraint should be inherited by subtables
10-
# @option [#to_s] :comment (nil) The comment describing the constraint
11-
# @yield [Proc] the block with the constraint's definition
12-
# @yieldparam The receiver of methods specifying the constraint
13-
#
14-
# The name of the new constraint can be set explicitly
15-
#
16-
# add_check_constraint :users, "length(phone) > 10",
17-
# name: "phone_is_long_enough",
18-
# inherit: false,
19-
# comment: "Phone is 10+ chars long"
20-
#
21-
# The name can also be skipped (it will be generated by default):
22-
#
23-
# add_check_constraint :users, "length(phone) > 1"
24-
#
25-
# The block syntax can be used for any argument as usual:
26-
#
27-
# add_check_constraint do |c|
28-
# c.table "users"
29-
# c.expression "length(phone) > 10"
30-
# c.name "phone_is_long_enough"
31-
# c.inherit false
32-
# c.comment "Phone is 10+ chars long"
3+
# @!parse
4+
# class ActiveRecord::Migration
5+
# # Add a check constraint to the table
6+
# #
7+
# # @param [#to_s] table (nil) The qualified name of the table
8+
# # @param [#to_s] expression (nil) The SQL expression
9+
# # @option [#to_s] :name (nil) The optional name of the constraint
10+
# # @option [Boolean] :inherit (true) If the constraint should be inherited by subtables
11+
# # @option [#to_s] :comment (nil) The comment describing the constraint
12+
# # @yield [c] the block with the constraint's definition
13+
# # @yieldparam Object receiver of methods specifying the constraint
14+
# # @return [void]
15+
# #
16+
# # The name of the new constraint can be set explicitly
17+
# #
18+
# # add_check_constraint :users, "length(phone) > 10",
19+
# # name: "phone_is_long_enough",
20+
# # inherit: false,
21+
# # comment: "Phone is 10+ chars long"
22+
# #
23+
# # The name can also be skipped (it will be generated by default):
24+
# #
25+
# # add_check_constraint :users, "length(phone) > 1"
26+
# #
27+
# # The block syntax can be used for any argument as usual:
28+
# #
29+
# # add_check_constraint do |c|
30+
# # c.table "users"
31+
# # c.expression "length(phone) > 10"
32+
# # c.name "phone_is_long_enough"
33+
# # c.inherit false
34+
# # c.comment "Phone is 10+ chars long"
35+
# # end
36+
# #
37+
# # The operation is always reversible.
38+
# def add_check_constraint(table, expression = nil, **options, &block); end
3339
# end
34-
#
35-
# The operation is always reversible.
36-
3740
module PGTrunk::Operations::CheckConstraints
3841
# @private
3942
class AddCheckConstraint < Base

Diff for: lib/pg_trunk/operations/check_constraints/drop_check_constraint.rb

+43-40
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,49 @@
11
# frozen_string_literal: false
22

3-
# @!method ActiveRecord::Migration#drop_check_constraint(table, expression = nil, **options, &block)
4-
# Remove a check constraint from the table
5-
#
6-
# @param [#to_s] table (nil) The qualified name of the table
7-
# @param [#to_s] expression (nil) The SQL expression
8-
# @option [Boolean] :if_exists (false) Suppress the error when the constraint is absent
9-
# @option [#to_s] :name (nil) The optional name of the constraint
10-
# @option [Boolean] :inherit (true) If the constraint should be inherited by subtables
11-
# @option [#to_s] :comment (nil) The comment describing the constraint
12-
# @yield [Proc] the block with the constraint's definition
13-
# @yieldparam The receiver of methods specifying the constraint
14-
#
15-
# Definition for the `drop_check_constraint` operation
16-
#
17-
# The constraint can be identified by the table and explicit name
18-
#
19-
# drop_check_constraint :users, name: "phone_is_long_enough"
20-
#
21-
# Alternatively the name can be got from the expression.
22-
# Be careful! the expression must have exactly the same form
23-
# as stored in the database:
24-
#
25-
# drop_check_constraint :users, "length((phone::text) > 10)"
26-
#
27-
# To made operation reversible the expression must be provided:
28-
#
29-
# drop_check_constraint "users" do |c|
30-
# c.expression "length((phone::text) > 10)"
31-
# c.inherit false
32-
# c.comment "The phone is 10+ chars long"
3+
# @!parse
4+
# class ActiveRecord::Migration
5+
# # Remove a check constraint from the table
6+
# #
7+
# # @param [#to_s] table (nil) The qualified name of the table
8+
# # @param [#to_s] expression (nil) The SQL expression
9+
# # @option [Boolean] :if_exists (false) Suppress the error when the constraint is absent
10+
# # @option [#to_s] :name (nil) The optional name of the constraint
11+
# # @option [Boolean] :inherit (true) If the constraint should be inherited by subtables
12+
# # @option [#to_s] :comment (nil) The comment describing the constraint
13+
# # @yield [c] the block with the constraint's definition
14+
# # @yieldparam Object receiver of methods specifying the constraint
15+
# # @return [void]
16+
# #
17+
# # Definition for the `drop_check_constraint` operation
18+
# #
19+
# # The constraint can be identified by the table and explicit name
20+
# #
21+
# # drop_check_constraint :users, name: "phone_is_long_enough"
22+
# #
23+
# # Alternatively the name can be got from the expression.
24+
# # Be careful! the expression must have exactly the same form
25+
# # as stored in the database:
26+
# #
27+
# # drop_check_constraint :users, "length((phone::text) > 10)"
28+
# #
29+
# # To made operation reversible the expression must be provided:
30+
# #
31+
# # drop_check_constraint "users" do |c|
32+
# # c.expression "length((phone::text) > 10)"
33+
# # c.inherit false
34+
# # c.comment "The phone is 10+ chars long"
35+
# # end
36+
# #
37+
# # The operation can be called with `if_exists` option.
38+
# #
39+
# # drop_check_constraint :users,
40+
# # name: "phone_is_long_enough",
41+
# # if_exists: true
42+
# #
43+
# # In this case the operation is always irreversible due to
44+
# # uncertainty of the previous state of the database.
45+
# def drop_check_constraint(table, expression = nil, **options, &block); end
3346
# end
34-
#
35-
# The operation can be called with `if_exists` option.
36-
#
37-
# drop_check_constraint :users,
38-
# name: "phone_is_long_enough",
39-
# if_exists: true
40-
#
41-
# In this case the operation is always irreversible due to
42-
# uncertainty of the previous state of the database.
43-
4447
module PGTrunk::Operations::CheckConstraints
4548
# @private
4649
class DropCheckConstraint < Base

Diff for: lib/pg_trunk/operations/check_constraints/rename_check_constraint.rb

+33-30
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,38 @@
11
# frozen_string_literal: false
22

3-
# @!method ActiveRecord::Migration#rename_check_constraint(table, expression = nil, **options, &block)
4-
# Rename a check constraint
5-
#
6-
# @param [#to_s] table (nil) The qualified name of the table
7-
# @param [#to_s] expression (nil) The SQL expression
8-
# @option [#to_s] :name (nil) The current name of the constraint
9-
# @option [#to_s] :to (nil) The new name for the constraint
10-
# @yield [Proc] the block with the constraint's definition
11-
# @yieldparam The receiver of methods specifying the constraint
12-
#
13-
# A constraint can be identified by the table and explicit name
14-
#
15-
# rename_check_constraint :users,
16-
# name: "phone_is_long_enough",
17-
# to: "phones.long_enough"
18-
#
19-
# Alternatively the name can be got from the expression.
20-
# Be careful! the expression must have exactly the same form
21-
# as stored in the database:
22-
#
23-
# rename_check_constraint :users, "length((phone::text) > 10)",
24-
# to: "long_enough"
25-
#
26-
# The name can be reset to auto-generated when
27-
# the `:to` option is missed or blank:
28-
#
29-
# rename_check_constraint :users, "phone_is_long_enough"
30-
#
31-
# The operation is always reversible.
32-
3+
# @!parse
4+
# class ActiveRecord::Migration
5+
# # Rename a check constraint
6+
# #
7+
# # @param [#to_s] table (nil) The qualified name of the table
8+
# # @param [#to_s] expression (nil) The SQL expression
9+
# # @option [#to_s] :name (nil) The current name of the constraint
10+
# # @option [#to_s] :to (nil) The new name for the constraint
11+
# # @yield [c] the block with the constraint's definition
12+
# # @yieldparam Object receiver of methods specifying the constraint
13+
# # @return [void]
14+
# #
15+
# # A constraint can be identified by the table and explicit name
16+
# #
17+
# # rename_check_constraint :users,
18+
# # name: "phone_is_long_enough",
19+
# # to: "phones.long_enough"
20+
# #
21+
# # Alternatively the name can be got from the expression.
22+
# # Be careful! the expression must have exactly the same form
23+
# # as stored in the database:
24+
# #
25+
# # rename_check_constraint :users, "length((phone::text) > 10)",
26+
# # to: "long_enough"
27+
# #
28+
# # The name can be reset to auto-generated when
29+
# # the `:to` option is missed or blank:
30+
# #
31+
# # rename_check_constraint :users, "phone_is_long_enough"
32+
# #
33+
# # The operation is always reversible.
34+
# def rename_check_constraint(table, expression = nil, **options, &block); end
35+
# end
3336
module PGTrunk::Operations::CheckConstraints
3437
# @private
3538
class RenameCheckConstraint < Base

Diff for: lib/pg_trunk/operations/check_constraints/validate_check_constraint.rb

+24-21
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,29 @@
11
# frozen_string_literal: false
22

3-
# @!method ActiveRecord::Migration#validate_check_constraint(table, expression = nil, **options, &block)
4-
# Validate an invalid check constraint
5-
#
6-
# @param [#to_s] table (nil) The qualified name of the table
7-
# @param [#to_s] expression (nil) The SQL expression
8-
# @option [#to_s] :name (nil) The optional name of the constraint
9-
# @yield [Proc] the block with the constraint's definition
10-
# @yieldparam The receiver of methods specifying the constraint
11-
#
12-
# The invalid constraint can be identified by table and explicit name:
13-
#
14-
# validate_check_constraint :users, name: "phone_is_long_enough"
15-
#
16-
# Alternatively it can be specified by expression. In this case
17-
# you must ensure the expression has the same form as it is stored
18-
# in the database (after parsing the source).
19-
#
20-
# validate_check_constraint :users, "length((phone::text) > 10)"
21-
#
22-
# Notice that it is invertible but the inverted operation does nothing.
23-
3+
# @!parse
4+
# class ActiveRecord::Migration
5+
# # Validate an invalid check constraint
6+
# #
7+
# # @param [#to_s] table (nil) The qualified name of the table
8+
# # @param [#to_s] expression (nil) The SQL expression
9+
# # @option [#to_s] :name (nil) The optional name of the constraint
10+
# # @yield [c] the block with the constraint's definition
11+
# # @yieldparam Object receiver of methods specifying the constraint
12+
# # @return [void]
13+
# #
14+
# # The invalid constraint can be identified by table and explicit name:
15+
# #
16+
# # validate_check_constraint :users, name: "phone_is_long_enough"
17+
# #
18+
# # Alternatively it can be specified by expression. In this case
19+
# # you must ensure the expression has the same form as it is stored
20+
# # in the database (after parsing the source).
21+
# #
22+
# # validate_check_constraint :users, "length((phone::text) > 10)"
23+
# #
24+
# # Notice that it is invertible but the inverted operation does nothing.
25+
# def validate_check_constraint(table, expression = nil, **options, &block); end
26+
# end
2427
module PGTrunk::Operations::CheckConstraints
2528
# @private
2629
class ValidateCheckConstraint < Base

0 commit comments

Comments
 (0)