pg_trunk 0.1.0 → 0.2.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 +4 -4
- data/.github/workflows/ci.yml +4 -15
- data/CHANGELOG.md +21 -0
- data/README.md +3 -1
- data/lib/pg_trunk/core/operation/attributes.rb +1 -1
- data/lib/pg_trunk/core/railtie/custom_types.rb +5 -6
- data/lib/pg_trunk/operations/check_constraints/add_check_constraint.rb +42 -33
- data/lib/pg_trunk/operations/check_constraints/drop_check_constraint.rb +51 -40
- data/lib/pg_trunk/operations/check_constraints/rename_check_constraint.rb +39 -30
- data/lib/pg_trunk/operations/check_constraints/validate_check_constraint.rb +28 -21
- data/lib/pg_trunk/operations/composite_types/change_composite_type.rb +59 -50
- data/lib/pg_trunk/operations/composite_types/create_composite_type.rb +23 -19
- data/lib/pg_trunk/operations/composite_types/drop_composite_type.rb +48 -43
- data/lib/pg_trunk/operations/composite_types/rename_composite_type.rb +15 -12
- data/lib/pg_trunk/operations/domains/change_domain.rb +53 -47
- data/lib/pg_trunk/operations/domains/create_domain.rb +28 -25
- data/lib/pg_trunk/operations/domains/drop_domain.rb +50 -41
- data/lib/pg_trunk/operations/domains/rename_domain.rb +17 -12
- data/lib/pg_trunk/operations/enums/change_enum.rb +37 -32
- data/lib/pg_trunk/operations/enums/create_enum.rb +23 -20
- data/lib/pg_trunk/operations/enums/drop_enum.rb +50 -39
- data/lib/pg_trunk/operations/enums/rename_enum.rb +17 -12
- data/lib/pg_trunk/operations/foreign_keys/add_foreign_key.rb +58 -49
- data/lib/pg_trunk/operations/foreign_keys/drop_foreign_key.rb +57 -48
- data/lib/pg_trunk/operations/foreign_keys/rename_foreign_key.rb +38 -29
- data/lib/pg_trunk/operations/functions/change_function.rb +53 -47
- data/lib/pg_trunk/operations/functions/create_function.rb +75 -64
- data/lib/pg_trunk/operations/functions/drop_function.rb +78 -65
- data/lib/pg_trunk/operations/functions/rename_function.rb +29 -22
- data/lib/pg_trunk/operations/materialized_views/change_materialized_view.rb +65 -55
- data/lib/pg_trunk/operations/materialized_views/create_materialized_view.rb +82 -71
- data/lib/pg_trunk/operations/materialized_views/drop_materialized_view.rb +59 -46
- data/lib/pg_trunk/operations/materialized_views/refresh_materialized_view.rb +29 -24
- data/lib/pg_trunk/operations/materialized_views/rename_materialized_view.rb +29 -22
- data/lib/pg_trunk/operations/procedures/change_procedure.rb +53 -46
- data/lib/pg_trunk/operations/procedures/create_procedure.rb +63 -52
- data/lib/pg_trunk/operations/procedures/drop_procedure.rb +56 -45
- data/lib/pg_trunk/operations/procedures/rename_procedure.rb +29 -22
- data/lib/pg_trunk/operations/rules/base.rb +77 -0
- data/lib/pg_trunk/operations/rules/create_rule.rb +155 -0
- data/lib/pg_trunk/operations/rules/drop_rule.rb +94 -0
- data/lib/pg_trunk/operations/rules/rename_rule.rb +62 -0
- data/lib/pg_trunk/operations/rules.rb +13 -0
- data/lib/pg_trunk/operations/sequences/base.rb +79 -0
- data/lib/pg_trunk/operations/sequences/change_sequence.rb +142 -0
- data/lib/pg_trunk/operations/sequences/create_sequence.rb +180 -0
- data/lib/pg_trunk/operations/sequences/drop_sequence.rb +82 -0
- data/lib/pg_trunk/operations/sequences/rename_sequence.rb +64 -0
- data/lib/pg_trunk/operations/sequences.rb +14 -0
- data/lib/pg_trunk/operations/statistics/create_statistics.rb +67 -56
- data/lib/pg_trunk/operations/statistics/drop_statistics.rb +64 -53
- data/lib/pg_trunk/operations/statistics/rename_statistics.rb +18 -13
- data/lib/pg_trunk/operations/triggers/change_trigger.rb +23 -18
- data/lib/pg_trunk/operations/triggers/create_trigger.rb +63 -54
- data/lib/pg_trunk/operations/triggers/drop_trigger.rb +55 -46
- data/lib/pg_trunk/operations/triggers/rename_trigger.rb +51 -48
- data/lib/pg_trunk/operations/views/change_view.rb +47 -38
- data/lib/pg_trunk/operations/views/create_view.rb +56 -45
- data/lib/pg_trunk/operations/views/drop_view.rb +59 -46
- data/lib/pg_trunk/operations/views/rename_view.rb +27 -20
- data/lib/pg_trunk/operations.rb +2 -0
- data/lib/pg_trunk/version.rb +1 -1
- data/pg_trunk.gemspec +0 -1
- data/spec/operations/rules/create_rule_spec.rb +119 -0
- data/spec/operations/rules/drop_rule_spec.rb +117 -0
- data/spec/operations/rules/rename_rule_spec.rb +148 -0
- data/spec/operations/sequences/change_sequence_spec.rb +134 -0
- data/spec/operations/sequences/create_sequence_spec.rb +156 -0
- data/spec/operations/sequences/drop_sequence_spec.rb +102 -0
- data/spec/operations/sequences/rename_sequence_spec.rb +100 -0
- metadata +22 -68
@@ -1,49 +1,54 @@
|
|
1
1
|
# frozen_string_literal: false
|
2
2
|
|
3
|
-
# @!
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
# @
|
8
|
-
# @option [
|
9
|
-
# @option [
|
10
|
-
# @
|
11
|
-
# @
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
# `create_composite_type` operation.
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
# d.column "
|
22
|
-
# d.column "
|
23
|
-
# d.
|
24
|
-
#
|
25
|
-
#
|
3
|
+
# @!parse
|
4
|
+
# class ActiveRecord::Migration
|
5
|
+
# # Drop a composite type
|
6
|
+
# #
|
7
|
+
# # @param [#to_s] name (nil) The qualified name of the type
|
8
|
+
# # @option options [Boolean] :if_exists (false) Suppress the error when the type is absent
|
9
|
+
# # @option options [Symbol] :force (:restrict) How to process dependent objects (`:cascade` or `:restrict`)
|
10
|
+
# # @option options [#to_s] :comment (nil) The comment describing the constraint
|
11
|
+
# # @yield [t] the block with the type's definition
|
12
|
+
# # @yieldparam Object receiver of methods specifying the type
|
13
|
+
# # @return [void]
|
14
|
+
# #
|
15
|
+
# # The operation drops a composite_type type identified by its qualified name (it can include a schema).
|
16
|
+
# #
|
17
|
+
# # For inversion use the same options as in the `create_composite_type` operation.
|
18
|
+
# #
|
19
|
+
# # ```ruby
|
20
|
+
# # drop_composite_type "paint.colored_point" do |d|
|
21
|
+
# # d.column "x", "integer"
|
22
|
+
# # d.column "y", "integer"
|
23
|
+
# # d.column "color", "text", collation: "en_US"
|
24
|
+
# # d.comment <<~COMMENT
|
25
|
+
# # 2D point with color
|
26
|
+
# # COMMENT
|
27
|
+
# # end
|
28
|
+
# # ```
|
29
|
+
# #
|
30
|
+
# # Notice, that the composite type creation can use no attributes.
|
31
|
+
# # That's why dropping it is always reversible; though the reversion provides a type without columns:
|
32
|
+
# #
|
33
|
+
# # ```ruby
|
34
|
+
# # drop_composite_type "paint.colored_point"
|
35
|
+
# # ```
|
36
|
+
# #
|
37
|
+
# # With the `force: :cascade` option the operation removes all objects using the type.
|
38
|
+
# #
|
39
|
+
# # ```ruby
|
40
|
+
# # drop_composite_type "paint.colored_point", force: :cascade
|
41
|
+
# # ```
|
42
|
+
# #
|
43
|
+
# # With the `if_exists: true` option the operation won't fail even when the view was absent.
|
44
|
+
# #
|
45
|
+
# # ```ruby
|
46
|
+
# # drop_composite_type "paint.colored_point", if_exists: true
|
47
|
+
# # ```
|
48
|
+
# #
|
49
|
+
# # Both options make a migration irreversible due to uncertainty of the previous state of the database.
|
50
|
+
# def drop_composite_type(name, **options, &block); end
|
26
51
|
# end
|
27
|
-
#
|
28
|
-
# Notice, that the composite type creation can use no attributes.
|
29
|
-
# That's why dropping it is always reversible; though the reversion
|
30
|
-
# would provide a type without columns:
|
31
|
-
#
|
32
|
-
# drop_composite_type "paint.colored_point"
|
33
|
-
#
|
34
|
-
# With the `force: :cascade` option the operation would remove
|
35
|
-
# all objects using the type.
|
36
|
-
#
|
37
|
-
# drop_composite_type "paint.colored_point", force: :cascade
|
38
|
-
#
|
39
|
-
# With the `if_exists: true` option the operation won't fail
|
40
|
-
# even when the view was absent in the database.
|
41
|
-
#
|
42
|
-
# drop_composite_type "paint.colored_point", if_exists: true
|
43
|
-
#
|
44
|
-
# Both options make a migration irreversible due to uncertainty
|
45
|
-
# of the previous state of the database.
|
46
|
-
|
47
52
|
module PGTrunk::Operations::CompositeTypes
|
48
53
|
# @private
|
49
54
|
class DropCompositeType < Base
|
@@ -1,17 +1,20 @@
|
|
1
1
|
# frozen_string_literal: false
|
2
2
|
|
3
|
-
# @!
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
# @
|
8
|
-
#
|
9
|
-
# @
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
|
3
|
+
# @!parse
|
4
|
+
# class ActiveRecord::Migration
|
5
|
+
# # Change the name and/or schema of a composite type
|
6
|
+
# #
|
7
|
+
# # @param [#to_s] name (nil) The qualified name of the type
|
8
|
+
# # @option options [#to_s] :to (nil) The new qualified name for the type
|
9
|
+
# # @return [void]
|
10
|
+
# #
|
11
|
+
# # ```ruby
|
12
|
+
# # rename_composite_type "point", to: "paint.colored_point"
|
13
|
+
# # ```
|
14
|
+
# #
|
15
|
+
# # The operation is always reversible.
|
16
|
+
# def rename_composite_type(name, to:); end
|
17
|
+
# end
|
15
18
|
module PGTrunk::Operations::CompositeTypes
|
16
19
|
# @private
|
17
20
|
class RenameCompositeType < Base
|
@@ -1,53 +1,59 @@
|
|
1
1
|
# frozen_string_literal: false
|
2
2
|
|
3
|
-
# @!
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
# @
|
8
|
-
# @
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
# #
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
# d.
|
21
|
-
#
|
22
|
-
# SQL
|
23
|
-
# d.
|
24
|
-
# d
|
25
|
-
#
|
26
|
-
#
|
27
|
-
#
|
28
|
-
#
|
3
|
+
# @!parse
|
4
|
+
# class ActiveRecord::Migration
|
5
|
+
# # Modify a domain type
|
6
|
+
# #
|
7
|
+
# # @param [#to_s] name (nil) The qualified name of the type
|
8
|
+
# # @yield [d] the block with the type's definition
|
9
|
+
# # @yieldparam Object receiver of methods specifying the type
|
10
|
+
# # @return [void]
|
11
|
+
# #
|
12
|
+
# # The operation can be used to add or remove constraints,
|
13
|
+
# # modify the default_sql value, or the description of the domain type.
|
14
|
+
# # Neither the underlying type nor the collation can be changed.
|
15
|
+
# #
|
16
|
+
# # ```ruby
|
17
|
+
# # change_domain "dict.us_postal_code" do |d|
|
18
|
+
# # d.null true # from: false
|
19
|
+
# # # check is added for inversion
|
20
|
+
# # d.drop_constraint "postal_code_length", check: <<~SQL
|
21
|
+
# # length(VALUE) > 3 AND length(VALUE) < 6
|
22
|
+
# # SQL
|
23
|
+
# # d.add_constraint <<~SQL, name: "postal_code_valid"
|
24
|
+
# # VALUE ~ '^\d{5}$' OR VALUE ~ '^\d{5}-\d{4}$'
|
25
|
+
# # SQL
|
26
|
+
# # d.default_sql "'00000'::text", from: "'0000'::text"
|
27
|
+
# # d.comment <<~COMMENT, from: <<~COMMENT
|
28
|
+
# # Supported currencies
|
29
|
+
# # COMMENT
|
30
|
+
# # Currencies
|
31
|
+
# # COMMENT
|
32
|
+
# # end
|
33
|
+
# # ```
|
34
|
+
# #
|
35
|
+
# # Use blank string (not a `nil` value) to reset either a default_sql,
|
36
|
+
# # or the comment. `nil`-s here will be ignored.
|
37
|
+
# #
|
38
|
+
# # When dropping a constraint you can use a `check` expression.
|
39
|
+
# # In the same manner, use `from` option with `comment` or `default_sql`
|
40
|
+
# # to make the operation invertible.
|
41
|
+
# #
|
42
|
+
# # It is irreversible in case any `drop_constraint` clause
|
43
|
+
# # has `if_exists: true` or `force: :cascade` option -- due to
|
44
|
+
# # uncertainty of the previous state of the database:
|
45
|
+
# #
|
46
|
+
# # ```ruby
|
47
|
+
# # change_domain "dict.us_postal_code", force: :cascade do |d|
|
48
|
+
# # d.drop_constraint "postal_code_valid" # missed `:check` option
|
49
|
+
# # d.drop_constraint "postal_code_length"
|
50
|
+
# # d.drop_constraint "postal_code_format", if_exists: true
|
51
|
+
# # d.default_sql "'0000'::text" # missed `:from` option
|
52
|
+
# # d.comment "New comment" # missed `:from` option
|
53
|
+
# # end
|
54
|
+
# # ```
|
55
|
+
# def change_domain(name, &block); end
|
29
56
|
# end
|
30
|
-
#
|
31
|
-
# Use blank string (not a `nil` value) to reset either a default_sql,
|
32
|
-
# or the comment. `nil`-s here will be ignored.
|
33
|
-
#
|
34
|
-
# When dropping a constraint you can use a `check` expression.
|
35
|
-
# In the same manner, use `from` option with `comment` or `default_sql`
|
36
|
-
# to make the operation invertible.
|
37
|
-
#
|
38
|
-
# It is irreversible in case any `drop_constraint` clause
|
39
|
-
# has `if_exists: true` or `force: :cascade` option -- due to
|
40
|
-
# uncertainty of the previous state of the database:
|
41
|
-
#
|
42
|
-
# # Irreversible change
|
43
|
-
# change_domain "dict.us_postal_code", force: :cascade do |d|
|
44
|
-
# d.drop_constraint "postal_code_valid" # missed `:check` option
|
45
|
-
# d.drop_constraint "postal_code_length"
|
46
|
-
# d.drop_constraint "postal_code_format", if_exists: true
|
47
|
-
# d.default_sql "'0000'::text" # missed `:from` option
|
48
|
-
# d.comment "New comment" # missed `:from` option
|
49
|
-
# end
|
50
|
-
|
51
57
|
module PGTrunk::Operations::Domains
|
52
58
|
# @private
|
53
59
|
class ChangeDomain < Base
|
@@ -1,31 +1,34 @@
|
|
1
1
|
# frozen_string_literal: false
|
2
2
|
|
3
|
-
# @!
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
# @
|
8
|
-
# @option [#to_s] :
|
9
|
-
# @option [
|
10
|
-
# @option [
|
11
|
-
# @option [#to_s] :
|
12
|
-
# @
|
13
|
-
# @
|
14
|
-
#
|
15
|
-
# @
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
# d.
|
20
|
-
# d.
|
21
|
-
# d.
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
3
|
+
# @!parse
|
4
|
+
# class ActiveRecord::Migration
|
5
|
+
# # Create a domain type
|
6
|
+
# #
|
7
|
+
# # @param [#to_s] name (nil) The qualified name of the type
|
8
|
+
# # @option options [#to_s] :as (nil) The base type for the domain (alias: :type)
|
9
|
+
# # @option options [#to_s] :collation (nil) The collation
|
10
|
+
# # @option options [Boolean] :null (true) If a value of this type can be NULL
|
11
|
+
# # @option options [#to_s] :default_sql (nil) The snippet for the default value of the domain
|
12
|
+
# # @option options [#to_s] :comment (nil) The comment describing the constraint
|
13
|
+
# # @yield [d] the block with the type's definition
|
14
|
+
# # @yieldparam Object receiver of methods specifying the type
|
15
|
+
# # @return [void]
|
16
|
+
# #
|
17
|
+
# # ```ruby
|
18
|
+
# # create_domain "dict.us_postal_code", as: "text" do |d|
|
19
|
+
# # d.collation "en_US"
|
20
|
+
# # d.default_sql "'0000'::text"
|
21
|
+
# # d.null false
|
22
|
+
# # d.constraint <<~SQL, name: "code_valid"
|
23
|
+
# # VALUE ~ '^\d{5}$' OR VALUE ~ '^\d{5}-\d{4}$'
|
24
|
+
# # SQL
|
25
|
+
# # d.comment "US postal code"
|
26
|
+
# # end
|
27
|
+
# # ```
|
28
|
+
# #
|
29
|
+
# # It is always reversible.
|
30
|
+
# def create_domain(name, **options, &block); end
|
25
31
|
# end
|
26
|
-
#
|
27
|
-
# It is always reversible.
|
28
|
-
|
29
32
|
module PGTrunk::Operations::Domains
|
30
33
|
# @private
|
31
34
|
class CreateDomain < Base
|
@@ -1,47 +1,56 @@
|
|
1
1
|
# frozen_string_literal: false
|
2
2
|
|
3
|
-
# @!
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
# @
|
8
|
-
# @option [
|
9
|
-
# @option [
|
10
|
-
# @option [#to_s] :
|
11
|
-
# @option [#to_s] :
|
12
|
-
# @option [#to_s] :
|
13
|
-
# @
|
14
|
-
# @
|
15
|
-
#
|
16
|
-
# @
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
26
|
-
#
|
27
|
-
# d.
|
28
|
-
#
|
29
|
-
#
|
3
|
+
# @!parse
|
4
|
+
# class ActiveRecord::Migration
|
5
|
+
# # Drop a domain type by qualified name
|
6
|
+
# #
|
7
|
+
# # @param [#to_s] name (nil) The qualified name of the type
|
8
|
+
# # @option options [Boolean] :if_exists (false) Suppress the error when the type is absent
|
9
|
+
# # @option options [Symbol] :force (:restrict) How to process dependent objects (`:cascade` or `:restrict`)
|
10
|
+
# # @option options [#to_s] :as (nil) The base type for the domain (alias: :type)
|
11
|
+
# # @option options [#to_s] :collation (nil) The collation
|
12
|
+
# # @option options [#to_s] :default_sql (nil) The snippet for the default value of the domain
|
13
|
+
# # @option options [#to_s] :comment (nil) The comment describing the constraint
|
14
|
+
# # @yield [d] the block with the type's definition
|
15
|
+
# # @yieldparam Object receiver of methods specifying the type
|
16
|
+
# # @return [void]
|
17
|
+
# #
|
18
|
+
# # ```ruby
|
19
|
+
# # drop_domain "dict.us_postal_code"
|
20
|
+
# # ```
|
21
|
+
# #
|
22
|
+
# # To make the operation invertible, use the same options
|
23
|
+
# # as in the `create_domain` operation.
|
24
|
+
# #
|
25
|
+
# # ```ruby
|
26
|
+
# # drop_domain "dict.us_postal_code", as: "string" do |d|
|
27
|
+
# # d.constraint <<~SQL, name: "code_valid"
|
28
|
+
# # VALUE ~ '^\d{5}$' OR VALUE ~ '^\d{5}-\d{4}$'
|
29
|
+
# # SQL
|
30
|
+
# # d.comment <<~COMMENT
|
31
|
+
# # US postal code
|
32
|
+
# # COMMENT
|
33
|
+
# # end
|
34
|
+
# # ```
|
35
|
+
# #
|
36
|
+
# # With the `force: :cascade` option the operation would remove
|
37
|
+
# # all the objects that use the type.
|
38
|
+
# #
|
39
|
+
# # ```ruby
|
40
|
+
# # drop_domain "dict.us_postal_code", force: :cascade
|
41
|
+
# # ```
|
42
|
+
# #
|
43
|
+
# # With the `if_exists: true` option the operation won't fail
|
44
|
+
# # even when the view was absent in the database.
|
45
|
+
# #
|
46
|
+
# # ```ruby
|
47
|
+
# # drop_domain "dict.us_postal_code", if_exists: true
|
48
|
+
# # ```
|
49
|
+
# #
|
50
|
+
# # Both options make a migration irreversible due to uncertainty
|
51
|
+
# # of the previous state of the database.
|
52
|
+
# def drop_domain(name, **options, &block); end
|
30
53
|
# end
|
31
|
-
#
|
32
|
-
# With the `force: :cascade` option the operation would remove
|
33
|
-
# all the objects that use the type.
|
34
|
-
#
|
35
|
-
# drop_domain "dict.us_postal_code", force: :cascade
|
36
|
-
#
|
37
|
-
# With the `if_exists: true` option the operation won't fail
|
38
|
-
# even when the view was absent in the database.
|
39
|
-
#
|
40
|
-
# drop_domain "dict.us_postal_code", if_exists: true
|
41
|
-
#
|
42
|
-
# Both options make a migration irreversible due to uncertainty
|
43
|
-
# of the previous state of the database.
|
44
|
-
|
45
54
|
module PGTrunk::Operations::Domains
|
46
55
|
# @private
|
47
56
|
class DropDomain < Base
|
@@ -1,17 +1,22 @@
|
|
1
1
|
# frozen_string_literal: false
|
2
2
|
|
3
|
-
# @!
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
# @
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
|
3
|
+
# @!parse
|
4
|
+
# class ActiveRecord::Migration
|
5
|
+
# # Change the name and/or schema of a domain type
|
6
|
+
# #
|
7
|
+
# # @param [#to_s] :name (nil) The qualified name of the type
|
8
|
+
# # @option options [#to_s] :to (nil) The new qualified name for the type
|
9
|
+
# # @return [void]
|
10
|
+
# #
|
11
|
+
# # A domain type can be both renamed and moved to another schema.
|
12
|
+
# #
|
13
|
+
# # ```ruby
|
14
|
+
# # rename_domain "us_code", to: "dict.us_postal_code"
|
15
|
+
# # ```
|
16
|
+
# #
|
17
|
+
# # The operation is always reversible.
|
18
|
+
# def rename_domain(name, to:); end
|
19
|
+
# end
|
15
20
|
module PGTrunk::Operations::Domains
|
16
21
|
# @private
|
17
22
|
class RenameDomain < Base
|
@@ -1,38 +1,43 @@
|
|
1
1
|
# frozen_string_literal: false
|
2
2
|
|
3
|
-
# @!
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
# @
|
8
|
-
# @
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
# e.
|
18
|
-
# e.
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
3
|
+
# @!parse
|
4
|
+
# class ActiveRecord::Migration
|
5
|
+
# # Modify an enumerated type
|
6
|
+
# #
|
7
|
+
# # @param [#to_s] name (nil) The qualified name of the type
|
8
|
+
# # @yield [e] the block with the type's definition
|
9
|
+
# # @yieldparam Object receiver of methods specifying the type
|
10
|
+
# # @return [void]
|
11
|
+
# #
|
12
|
+
# # The operation can be used to rename or add values to the
|
13
|
+
# # enumerated type. The commend can be changed as well.
|
14
|
+
# #
|
15
|
+
# # ```ruby
|
16
|
+
# # change_enum "currencies" do |e|
|
17
|
+
# # e.add_value "EUR", after: "BTC"
|
18
|
+
# # e.add_value "GBP", before: "usd"
|
19
|
+
# # e.add_value "JPY" # to the end of the list
|
20
|
+
# # e.rename_value "usd", to: "USD"
|
21
|
+
# # e.comment <<~COMMENT, from: <<~COMMENT
|
22
|
+
# # Supported currencies
|
23
|
+
# # COMMENT
|
24
|
+
# # Currencies
|
25
|
+
# # COMMENT
|
26
|
+
# # end
|
27
|
+
# # ```
|
28
|
+
# #
|
29
|
+
# # Please, keep in mind that all values will be added before
|
30
|
+
# # the first rename. That's why you should use old values
|
31
|
+
# # (like the `usd` instead of the `USD` in the example above)
|
32
|
+
# # in `before` and `after` options.
|
33
|
+
# #
|
34
|
+
# # Also notice that PostgreSQL doesn't support value deletion,
|
35
|
+
# # that's why adding any value makes the migration irreversible.
|
36
|
+
# #
|
37
|
+
# # It is also irreversible if you changed the comment, but
|
38
|
+
# # not defined its previous value.
|
39
|
+
# def change_enum(name, &block); end
|
23
40
|
# end
|
24
|
-
#
|
25
|
-
# Please, keep in mind that all values will be added before
|
26
|
-
# the first rename. That's why you should use old values
|
27
|
-
# (like the `usd` instead of the `USD` in the example above)
|
28
|
-
# in `before` and `after` options.
|
29
|
-
#
|
30
|
-
# Also notice that PostgreSQL doesn't support value deletion,
|
31
|
-
# that's why adding any value makes the migration irreversible.
|
32
|
-
#
|
33
|
-
# It is also irreversible if you changed the comment, but
|
34
|
-
# not defined its previous value.
|
35
|
-
|
36
41
|
module PGTrunk::Operations::Enums
|
37
42
|
# @private
|
38
43
|
class ChangeEnum < Base
|
@@ -1,26 +1,29 @@
|
|
1
1
|
# frozen_string_literal: false
|
2
2
|
|
3
|
-
# @!
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
# @
|
8
|
-
# @option [
|
9
|
-
# @
|
10
|
-
# @
|
11
|
-
#
|
12
|
-
# @
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
# e.
|
17
|
-
# e.
|
18
|
-
#
|
19
|
-
#
|
3
|
+
# @!parse
|
4
|
+
# class ActiveRecord::Migration
|
5
|
+
# # Create an enumerated type by qualified name
|
6
|
+
# #
|
7
|
+
# # @param [#to_s] name (nil) The qualified name of the type
|
8
|
+
# # @option options [Array<#to_s>] :values ([]) The list of values
|
9
|
+
# # @option options [#to_s] :comment (nil) The comment describing the constraint
|
10
|
+
# # @yield [e] the block with the type's definition
|
11
|
+
# # @yieldparam Object receiver of methods specifying the type
|
12
|
+
# # @return [void]
|
13
|
+
# #
|
14
|
+
# # ```ruby
|
15
|
+
# # create_enum "finances.currency" do |e|
|
16
|
+
# # e.values "BTC", "EUR", "GBP", "USD"
|
17
|
+
# # e.value "JPY" # the alternative way to add a value to the tail
|
18
|
+
# # e.comment <<~COMMENT
|
19
|
+
# # The list of values for supported currencies.
|
20
|
+
# # COMMENT
|
21
|
+
# # end
|
22
|
+
# # ```
|
23
|
+
# #
|
24
|
+
# # It is always reversible.
|
25
|
+
# def create_enum(name, **options, &block); end
|
20
26
|
# end
|
21
|
-
#
|
22
|
-
# It is always reversible.
|
23
|
-
|
24
27
|
module PGTrunk::Operations::Enums
|
25
28
|
# @private
|
26
29
|
class CreateEnum < Base
|