pg_trunk 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- 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,70 +1,81 @@
|
|
1
1
|
# frozen_string_literal: false
|
2
2
|
|
3
|
-
# @!
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
# @option [
|
10
|
-
# @option [#to_s] :
|
11
|
-
# @option [
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
# @option [Boolean] :
|
19
|
-
# @option [
|
20
|
-
# @option [
|
21
|
-
# @option [
|
22
|
-
# @
|
23
|
-
# @
|
24
|
-
#
|
25
|
-
#
|
26
|
-
#
|
27
|
-
#
|
28
|
-
#
|
29
|
-
#
|
30
|
-
#
|
31
|
-
#
|
32
|
-
#
|
33
|
-
#
|
34
|
-
#
|
35
|
-
#
|
36
|
-
#
|
37
|
-
#
|
38
|
-
#
|
39
|
-
#
|
40
|
-
#
|
41
|
-
#
|
42
|
-
# f.
|
43
|
-
# f.
|
44
|
-
#
|
45
|
-
#
|
46
|
-
# f.
|
47
|
-
# #
|
48
|
-
# f.
|
49
|
-
#
|
50
|
-
#
|
51
|
-
#
|
52
|
-
#
|
53
|
-
#
|
54
|
-
#
|
55
|
-
#
|
56
|
-
#
|
57
|
-
#
|
58
|
-
#
|
59
|
-
#
|
60
|
-
#
|
61
|
-
#
|
62
|
-
#
|
63
|
-
#
|
64
|
-
#
|
65
|
-
# #
|
3
|
+
# @!parse
|
4
|
+
# class ActiveRecord::Migration
|
5
|
+
# # Create a function
|
6
|
+
# #
|
7
|
+
# # @param [#to_s] name (nil)
|
8
|
+
# # The qualified name of the function with arguments and returned value type
|
9
|
+
# # @option options [Boolean] :replace_existing (false) If the function should overwrite an existing one
|
10
|
+
# # @option options [#to_s] :language ("sql") The language (like "sql" or "plpgsql")
|
11
|
+
# # @option options [#to_s] :body (nil) The body of the function
|
12
|
+
# # @option options [Symbol] :volatility (:volatile) The volatility of the function.
|
13
|
+
# # Supported values: :volatile (default), :stable, :immutable
|
14
|
+
# # @option options [Symbol] :parallel (:unsafe) The safety of parallel execution.
|
15
|
+
# # Supported values: :unsafe (default), :restricted, :safe
|
16
|
+
# # @option options [Symbol] :security (:invoker) Define the role under which the function is invoked
|
17
|
+
# # Supported values: :invoker (default), :definer
|
18
|
+
# # @option options [Boolean] :leakproof (false) If the function is leakproof
|
19
|
+
# # @option options [Boolean] :strict (false) If the function is strict
|
20
|
+
# # @option options [Float] :cost (nil) The cost estimation for the function
|
21
|
+
# # @option options [Integer] :rows (nil) The number of rows returned by a function
|
22
|
+
# # @option options [#to_s] :comment The description of the function
|
23
|
+
# # @yield [f] the block with the function's definition
|
24
|
+
# # @yieldparam Object receiver of methods specifying the function
|
25
|
+
# # @return [void]
|
26
|
+
# #
|
27
|
+
# # The function can be created either using inline syntax
|
28
|
+
# #
|
29
|
+
# # ```ruby
|
30
|
+
# # create_function "math.mult(a int, b int) int",
|
31
|
+
# # language: :sql,
|
32
|
+
# # body: "SELECT a * b",
|
33
|
+
# # volatility: :immutable,
|
34
|
+
# # leakproof: true,
|
35
|
+
# # comment: "Multiplies 2 integers"
|
36
|
+
# # ```
|
37
|
+
# #
|
38
|
+
# # or using a block:
|
39
|
+
# #
|
40
|
+
# # ```ruby
|
41
|
+
# # create_function "math.mult(a int, b int) int" do |f|
|
42
|
+
# # f.language "sql" # (default)
|
43
|
+
# # f.body <<~SQL
|
44
|
+
# # SELECT a * b;
|
45
|
+
# # SQL
|
46
|
+
# # f.volatility :immutable # :stable, :volatile (default)
|
47
|
+
# # f.parallel :safe # :restricted, :unsafe (default)
|
48
|
+
# # f.security :invoker # (default), also :definer
|
49
|
+
# # f.leakproof true
|
50
|
+
# # f.strict true
|
51
|
+
# # f.cost 5.0
|
52
|
+
# # # f.rows 1 (supported for functions returning sets of rows)
|
53
|
+
# # f.comment "Multiplies 2 integers"
|
54
|
+
# # SQL
|
55
|
+
# # ```
|
56
|
+
# #
|
57
|
+
# # With a `replace_existing: true` option,
|
58
|
+
# # it will be created using the `CREATE OR REPLACE` clause.
|
59
|
+
# # In this case the migration is irreversible because we
|
60
|
+
# # don't know if and how to restore its previous definition.
|
61
|
+
# #
|
62
|
+
# # ```ruby
|
63
|
+
# # create_function "math.mult(a int, b int) int",
|
64
|
+
# # body: "SELECT a * b",
|
65
|
+
# # replace_existing: true
|
66
|
+
# # ```
|
67
|
+
# #
|
68
|
+
# # We presume a function without arguments should have
|
69
|
+
# # no arguments and return `void` like
|
70
|
+
# #
|
71
|
+
# # ```ruby
|
72
|
+
# # # the same as "do_something() void"
|
73
|
+
# # create_function "do_something" do |f|
|
74
|
+
# # # ...
|
75
|
+
# # end
|
76
|
+
# # ```
|
77
|
+
# def create_function(name, **options, &block); end
|
66
78
|
# end
|
67
|
-
|
68
79
|
module PGTrunk::Operations::Functions
|
69
80
|
# @private
|
70
81
|
class CreateFunction < Base
|
@@ -1,71 +1,84 @@
|
|
1
1
|
# frozen_string_literal: false
|
2
2
|
|
3
|
-
# @!
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
# @option [
|
10
|
-
#
|
11
|
-
#
|
12
|
-
# @option [#to_s] :
|
13
|
-
# @option [
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
# @option [Boolean] :
|
21
|
-
# @option [
|
22
|
-
# @option [
|
23
|
-
# @option [
|
24
|
-
# @
|
25
|
-
# @
|
26
|
-
#
|
27
|
-
#
|
28
|
-
#
|
29
|
-
#
|
30
|
-
#
|
31
|
-
#
|
32
|
-
#
|
33
|
-
#
|
34
|
-
#
|
35
|
-
#
|
36
|
-
#
|
37
|
-
#
|
38
|
-
#
|
39
|
-
#
|
40
|
-
#
|
41
|
-
#
|
42
|
-
#
|
43
|
-
#
|
44
|
-
#
|
45
|
-
#
|
46
|
-
#
|
47
|
-
#
|
48
|
-
#
|
49
|
-
# f.
|
50
|
-
# f.
|
51
|
-
#
|
52
|
-
# #
|
53
|
-
# f.
|
3
|
+
# @!parse
|
4
|
+
# class ActiveRecord::Migration
|
5
|
+
# # Drop a function
|
6
|
+
# #
|
7
|
+
# # @param [#to_s] name (nil)
|
8
|
+
# # The qualified name of the function with arguments and returned value type
|
9
|
+
# # @option options [Boolean] :if_exists (false) Suppress the error when the function is absent
|
10
|
+
# # @option options [Symbol] :force (:restrict) How to process dependent objects
|
11
|
+
# # Supported values: :restrict (default), :cascade
|
12
|
+
# # @option options [#to_s] :language ("sql") The language (like "sql" or "plpgsql")
|
13
|
+
# # @option options [#to_s] :body (nil) The body of the function
|
14
|
+
# # @option options [Symbol] :volatility (:volatile) The volatility of the function.
|
15
|
+
# # Supported values: :volatile (default), :stable, :immutable
|
16
|
+
# # @option options [Symbol] :parallel (:unsafe) The safety of parallel execution.
|
17
|
+
# # Supported values: :unsafe (default), :restricted, :safe
|
18
|
+
# # @option options [Symbol] :security (:invoker) Define the role under which the function is invoked
|
19
|
+
# # Supported values: :invoker (default), :definer
|
20
|
+
# # @option options [Boolean] :leakproof (false) If the function is leakproof
|
21
|
+
# # @option options [Boolean] :strict (false) If the function is strict
|
22
|
+
# # @option options [Float] :cost (nil) The cost estimation for the function
|
23
|
+
# # @option options [Integer] :rows (nil) The number of rows returned by a function
|
24
|
+
# # @option options [#to_s] :comment The description of the function
|
25
|
+
# # @yield [f] the block with the function's definition
|
26
|
+
# # @yieldparam Object receiver of methods specifying the function
|
27
|
+
# # @return [void]
|
28
|
+
# #
|
29
|
+
# # A function can be dropped by a plain name:
|
30
|
+
# #
|
31
|
+
# # ```ruby
|
32
|
+
# # drop_function "multiply"
|
33
|
+
# # ```
|
34
|
+
# #
|
35
|
+
# # If several overloaded functions have the name,
|
36
|
+
# # then you must specify the signature having
|
37
|
+
# # types of attributes at least:
|
38
|
+
# #
|
39
|
+
# # ```ruby
|
40
|
+
# # drop_function "multiply(int, int)"
|
41
|
+
# # ```
|
42
|
+
# #
|
43
|
+
# # In both cases above the operation is irreversible. To make it
|
44
|
+
# # inverted you have to provide a full signature along with
|
45
|
+
# # the body definition. The other options are supported as well:
|
46
|
+
# #
|
47
|
+
# # ```ruby
|
48
|
+
# # drop_function "math.mult(a int, b int) int" do |f|
|
49
|
+
# # f.language "sql" # (default)
|
50
|
+
# # f.body <<~SQL
|
51
|
+
# # SELECT a * b;
|
52
|
+
# # SQL
|
53
|
+
# # f.volatility :immutable # :stable, :volatile (default)
|
54
|
+
# # f.parallel :safe # :restricted, :unsafe (default)
|
55
|
+
# # f.security :invoker # (default), also :definer
|
56
|
+
# # f.leakproof true
|
57
|
+
# # f.strict true
|
58
|
+
# # f.cost 5.0
|
59
|
+
# # # f.rows 1 (supported for functions returning sets of rows)
|
60
|
+
# # f.comment "Multiplies 2 integers"
|
61
|
+
# # end
|
62
|
+
# # ```
|
63
|
+
# #
|
64
|
+
# # The operation can be called with `if_exists` option. In this case
|
65
|
+
# # it would do nothing when no function existed.
|
66
|
+
# #
|
67
|
+
# # ```ruby
|
68
|
+
# # drop_function "math.multiply(integer, integer)", if_exists: true
|
69
|
+
# # ```
|
70
|
+
# #
|
71
|
+
# # Another operation-specific option `force: :cascade` enables
|
72
|
+
# # to drop silently any object depending on the function.
|
73
|
+
# #
|
74
|
+
# # ```ruby
|
75
|
+
# # drop_function "math.multiply(integer, integer)", force: :cascade
|
76
|
+
# # ```
|
77
|
+
# #
|
78
|
+
# # Both options make the operation irreversible because of
|
79
|
+
# # uncertainty about the previous state of the database.
|
80
|
+
# def drop_function(name, **options, &block); end
|
54
81
|
# end
|
55
|
-
#
|
56
|
-
# The operation can be called with `if_exists` option. In this case
|
57
|
-
# it would do nothing when no function existed.
|
58
|
-
#
|
59
|
-
# drop_function "math.multiply(integer, integer)", if_exists: true
|
60
|
-
#
|
61
|
-
# Another operation-specific option `force: :cascade` enables
|
62
|
-
# to drop silently any object depending on the function.
|
63
|
-
#
|
64
|
-
# drop_function "math.multiply(integer, integer)", force: :cascade
|
65
|
-
#
|
66
|
-
# Both options make the operation irreversible because of
|
67
|
-
# uncertainty about the previous state of the database.
|
68
|
-
|
69
82
|
module PGTrunk::Operations::Functions
|
70
83
|
# @private
|
71
84
|
class DropFunction < Base
|
@@ -1,27 +1,34 @@
|
|
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
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
24
|
-
|
3
|
+
# @!parse
|
4
|
+
# class ActiveRecord::Migration
|
5
|
+
# # Change the name and/or schema of a function
|
6
|
+
# #
|
7
|
+
# # @param [#to_s] :name (nil) The qualified name of the function
|
8
|
+
# # @option options [#to_s] :to (nil) The new qualified name for the function
|
9
|
+
# # @return [void]
|
10
|
+
# #
|
11
|
+
# # A function can be renamed by changing both the name
|
12
|
+
# # and the schema (namespace) it belongs to.
|
13
|
+
# #
|
14
|
+
# # If there are no overloaded functions, then you can use a plain name:
|
15
|
+
# #
|
16
|
+
# # ```ruby
|
17
|
+
# # rename_function "math.multiply", to: "public.product"
|
18
|
+
# # ```
|
19
|
+
# #
|
20
|
+
# # otherwise the types of attributes must be explicitly specified.
|
21
|
+
# #
|
22
|
+
# # ```ruby
|
23
|
+
# # rename_function "math.multiply(int, int)", to: "public.product"
|
24
|
+
# # ```
|
25
|
+
# #
|
26
|
+
# # Any specification of attributes or returned values in `to:` option
|
27
|
+
# # is ignored because they cannot be changed anyway.
|
28
|
+
# #
|
29
|
+
# # The operation is always reversible.
|
30
|
+
# def rename_function(name, to:); end
|
31
|
+
# end
|
25
32
|
module PGTrunk::Operations::Functions
|
26
33
|
# @private
|
27
34
|
class RenameFunction < Base
|
@@ -1,61 +1,71 @@
|
|
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
|
-
# v.
|
20
|
-
# v.column "
|
3
|
+
# @!parse
|
4
|
+
# class ActiveRecord::Migration
|
5
|
+
# # Modify a materialized view
|
6
|
+
# #
|
7
|
+
# # @param [#to_s] name (nil) The qualified name of the view
|
8
|
+
# # @option options [Boolean] :if_exists (false) Suppress the error when the view is absent
|
9
|
+
# # @yield [v] the block with the view's definition
|
10
|
+
# # @yieldparam Object receiver of methods specifying the view
|
11
|
+
# # @return [void]
|
12
|
+
# #
|
13
|
+
# # The operation enables to alter a view without recreating
|
14
|
+
# # its from scratch. You can rename columns, change their
|
15
|
+
# # storage settings (how the column is TOAST-ed), or customize their statistics.
|
16
|
+
# #
|
17
|
+
# # ```ruby
|
18
|
+
# # change_materialized_view "admin_users" do |v|
|
19
|
+
# # v.rename_column "name", to: "full_name"
|
20
|
+
# # v.column "name", storage: "extended", from_storage: "expanded"
|
21
|
+
# # v.column "admin", n_distinct: 2
|
22
|
+
# # v.column "role", statistics: 100
|
23
|
+
# # end
|
24
|
+
# # ```
|
25
|
+
# #
|
26
|
+
# # Notice that renaming will be done AFTER all changes even
|
27
|
+
# # though the order of declarations can be different.
|
28
|
+
# #
|
29
|
+
# # As in the snippet above, to make the change invertible,
|
30
|
+
# # you have to define a previous storage via `from_storage` option.
|
31
|
+
# # The inversion would always reset statistics (set it to 0).
|
32
|
+
# #
|
33
|
+
# # In addition to changing columns, the operation enables
|
34
|
+
# # to set a default clustering by given index:
|
35
|
+
# #
|
36
|
+
# # ```ruby
|
37
|
+
# # change_materialized_view "admin_users" do |v|
|
38
|
+
# # v.cluster_on "admin_users_by_names_idx"
|
39
|
+
# # end
|
40
|
+
# # ```
|
41
|
+
# #
|
42
|
+
# # The clustering is invertible, but its inversion does nothing,
|
43
|
+
# # keeping the clustering unchanged.
|
44
|
+
# #
|
45
|
+
# # The comment can also be changed:
|
46
|
+
# #
|
47
|
+
# # ```ruby
|
48
|
+
# # change_materialized_view "admin_users" do |v|
|
49
|
+
# # v.comment "Admin users", from: "Admin users only"
|
50
|
+
# # end
|
51
|
+
# # ```
|
52
|
+
# #
|
53
|
+
# # Notice, that without `from` option the operation is still
|
54
|
+
# # invertible, but its inversion would delete the comment.
|
55
|
+
# # It can also be reset to the blank string explicitly:
|
56
|
+
# #
|
57
|
+
# # ```ruby
|
58
|
+
# # change_materialized_view "admin_users" do |v|
|
59
|
+
# # v.comment "", from: "Admin users only"
|
60
|
+
# # end
|
61
|
+
# # ```
|
62
|
+
# #
|
63
|
+
# # With the `if_exists: true` option, the operation won't fail
|
64
|
+
# # even when the view wasn't existed. At the same time,
|
65
|
+
# # this option makes a migration irreversible due to uncertainty
|
66
|
+
# # of the previous state of the database.
|
67
|
+
# def change_materialized_view(name, **options, &block); end
|
21
68
|
# end
|
22
|
-
#
|
23
|
-
# Notice that renaming will be done AFTER all changes even
|
24
|
-
# though the order of declarations can be different.
|
25
|
-
#
|
26
|
-
# As in the snippet above, to make the change invertible,
|
27
|
-
# you have to define a previous storage via `from_storage` option.
|
28
|
-
# The inversion would always reset statistics (set it to 0).
|
29
|
-
#
|
30
|
-
# In addition to changing columns, the operation enables
|
31
|
-
# to set a default clustering by given index:
|
32
|
-
#
|
33
|
-
# change_materialized_view "admin_users" do |v|
|
34
|
-
# v.cluster_on "admin_users_by_names_idx"
|
35
|
-
# end
|
36
|
-
#
|
37
|
-
# The clustering is invertible, but its inversion does nothing,
|
38
|
-
# keeping the clustering unchanged.
|
39
|
-
#
|
40
|
-
# The comment can also be changed:
|
41
|
-
#
|
42
|
-
# change_materialized_view "admin_users" do |v|
|
43
|
-
# v.comment "Admin users", from: "Admin users only"
|
44
|
-
# end
|
45
|
-
#
|
46
|
-
# Notice, that without `from` option the operation is still
|
47
|
-
# invertible, but its inversion would delete the comment.
|
48
|
-
# It can also be reset to the blank string explicitly:
|
49
|
-
#
|
50
|
-
# change_materialized_view "admin_users" do |v|
|
51
|
-
# v.comment "", from: "Admin users only"
|
52
|
-
# end
|
53
|
-
#
|
54
|
-
# With the `if_exists: true` option, the operation won't fail
|
55
|
-
# even when the view wasn't existed. At the same time,
|
56
|
-
# this option makes a migration irreversible due to uncertainty
|
57
|
-
# of the previous state of the database.
|
58
|
-
|
59
69
|
module PGTrunk::Operations::MaterializedViews
|
60
70
|
# @private
|
61
71
|
class ChangeMaterializedView < Base
|