pg_trunk 0.1.0 → 0.1.1

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.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/lib/pg_trunk/operations/check_constraints/add_check_constraint.rb +36 -33
  4. data/lib/pg_trunk/operations/check_constraints/drop_check_constraint.rb +43 -40
  5. data/lib/pg_trunk/operations/check_constraints/rename_check_constraint.rb +33 -30
  6. data/lib/pg_trunk/operations/check_constraints/validate_check_constraint.rb +24 -21
  7. data/lib/pg_trunk/operations/composite_types/change_composite_type.rb +53 -50
  8. data/lib/pg_trunk/operations/composite_types/create_composite_type.rb +22 -19
  9. data/lib/pg_trunk/operations/composite_types/drop_composite_type.rb +46 -43
  10. data/lib/pg_trunk/operations/composite_types/rename_composite_type.rb +15 -12
  11. data/lib/pg_trunk/operations/domains/change_domain.rb +50 -47
  12. data/lib/pg_trunk/operations/domains/create_domain.rb +28 -25
  13. data/lib/pg_trunk/operations/domains/drop_domain.rb +44 -41
  14. data/lib/pg_trunk/operations/domains/rename_domain.rb +15 -12
  15. data/lib/pg_trunk/operations/enums/change_enum.rb +35 -32
  16. data/lib/pg_trunk/operations/enums/create_enum.rb +23 -20
  17. data/lib/pg_trunk/operations/enums/drop_enum.rb +42 -39
  18. data/lib/pg_trunk/operations/enums/rename_enum.rb +15 -12
  19. data/lib/pg_trunk/operations/foreign_keys/add_foreign_key.rb +52 -49
  20. data/lib/pg_trunk/operations/foreign_keys/drop_foreign_key.rb +51 -48
  21. data/lib/pg_trunk/operations/foreign_keys/rename_foreign_key.rb +32 -29
  22. data/lib/pg_trunk/operations/functions/change_function.rb +50 -47
  23. data/lib/pg_trunk/operations/functions/create_function.rb +67 -64
  24. data/lib/pg_trunk/operations/functions/drop_function.rb +68 -65
  25. data/lib/pg_trunk/operations/functions/rename_function.rb +25 -22
  26. data/lib/pg_trunk/operations/materialized_views/change_materialized_view.rb +58 -55
  27. data/lib/pg_trunk/operations/materialized_views/create_materialized_view.rb +74 -71
  28. data/lib/pg_trunk/operations/materialized_views/drop_materialized_view.rb +49 -46
  29. data/lib/pg_trunk/operations/materialized_views/refresh_materialized_view.rb +27 -24
  30. data/lib/pg_trunk/operations/materialized_views/rename_materialized_view.rb +25 -22
  31. data/lib/pg_trunk/operations/procedures/change_procedure.rb +49 -46
  32. data/lib/pg_trunk/operations/procedures/create_procedure.rb +55 -52
  33. data/lib/pg_trunk/operations/procedures/drop_procedure.rb +48 -45
  34. data/lib/pg_trunk/operations/procedures/rename_procedure.rb +25 -22
  35. data/lib/pg_trunk/operations/statistics/create_statistics.rb +59 -56
  36. data/lib/pg_trunk/operations/statistics/drop_statistics.rb +56 -53
  37. data/lib/pg_trunk/operations/statistics/rename_statistics.rb +16 -13
  38. data/lib/pg_trunk/operations/triggers/change_trigger.rb +21 -18
  39. data/lib/pg_trunk/operations/triggers/create_trigger.rb +57 -54
  40. data/lib/pg_trunk/operations/triggers/drop_trigger.rb +49 -46
  41. data/lib/pg_trunk/operations/triggers/rename_trigger.rb +51 -48
  42. data/lib/pg_trunk/operations/views/change_view.rb +41 -38
  43. data/lib/pg_trunk/operations/views/create_view.rb +48 -45
  44. data/lib/pg_trunk/operations/views/drop_view.rb +49 -46
  45. data/lib/pg_trunk/operations/views/rename_view.rb +23 -20
  46. data/lib/pg_trunk/version.rb +1 -1
  47. metadata +2 -2
@@ -1,27 +1,30 @@
1
1
  # frozen_string_literal: false
2
2
 
3
- # @!method ActiveRecord::Migration#rename_materialized_view(name, **options)
4
- # Change the name and/or schema of a materialized view
5
- #
6
- # @param [#to_s] :name (nil) The qualified name of the view
7
- # @option [#to_s] :to (nil) The new qualified name for the view
8
- # @option [Boolean] :if_exists (false) Suppress the error when the view is absent
9
- #
10
- # A materialized view can be renamed by changing both the name
11
- # and the schema (namespace) it belongs to.
12
- #
13
- # rename_materialized_view "views.admin_users", to: "admins"
14
- #
15
- # With the `if_exists: true` option, the operation won't fail
16
- # even when the view wasn't existed.
17
- #
18
- # rename_materialized_view "admin_users",
19
- # to: "admins",
20
- # if_exists: true
21
- #
22
- # At the same time, the option makes a migration irreversible
23
- # due to uncertainty of the previous state of the database.
24
-
3
+ # @!parse
4
+ # class ActiveRecord::Migration
5
+ # # Change the name and/or schema of a materialized view
6
+ # #
7
+ # # @param [#to_s] :name (nil) The qualified name of the view
8
+ # # @option [#to_s] :to (nil) The new qualified name for the view
9
+ # # @option [Boolean] :if_exists (false) Suppress the error when the view is absent
10
+ # # @return [void]
11
+ # #
12
+ # # A materialized view can be renamed by changing both the name
13
+ # # and the schema (namespace) it belongs to.
14
+ # #
15
+ # # rename_materialized_view "views.admin_users", to: "admins"
16
+ # #
17
+ # # With the `if_exists: true` option, the operation won't fail
18
+ # # even when the view wasn't existed.
19
+ # #
20
+ # # rename_materialized_view "admin_users",
21
+ # # to: "admins",
22
+ # # if_exists: true
23
+ # #
24
+ # # At the same time, the option makes a migration irreversible
25
+ # # due to uncertainty of the previous state of the database.
26
+ # def rename_materialized_view(name, **options); end
27
+ # end
25
28
  module PGTrunk::Operations::MaterializedViews
26
29
  # @private
27
30
  class RenameMaterializedView < Base
@@ -1,51 +1,54 @@
1
1
  # frozen_string_literal: false
2
2
 
3
- # @!method ActiveRecord::Migration#change_procedure(name, **options, &block)
4
- # Modify a procedure
5
- #
6
- # @param [#to_s] name (nil) The qualified name of the procedure
7
- # @option [Boolean] :if_exists (false) Suppress the error when the procedure is absent
8
- # @yield [Proc] the block with the procedure's definition
9
- # @yieldparam The receiver of methods specifying the procedure
10
- #
11
- # The operation changes the procedure without dropping it
12
- # (which is useful when there are other objects
13
- # using the function and you don't want to change them all).
14
- #
15
- # You can change any property except for the name
16
- # (use `rename_function` instead) and `language`.
17
- #
18
- # change_procedure "metadata.set_foo(a int)" do |p|
19
- # p.body <<~SQL
20
- # SET foo = a
21
- # SQL
22
- # p.security :invoker
23
- # p.comment "Multiplies 2 integers"
24
- # SQL
25
- #
26
- # The example above is not invertible because of uncertainty
27
- # about the previous state of body and comment.
28
- # To define them, use a from options (available in a block syntax only):
29
- #
30
- # change_procedure "metadata.set_foo(a int)" do |p|
31
- # p.body <<~SQL, from: <<~SQL
32
- # SET foo = a
33
- # SQL
34
- # SET foo = -a
35
- # SQL
36
- # p.comment <<~MSG, from: <<~MSG
37
- # Multiplies 2 integers
38
- # MSG
39
- # Multiplies ints
40
- # MSG
41
- # p.security :invoker
42
- # SQL
43
- #
44
- # Like in the other operations, the procedure can be
45
- # identified by a qualified name (with types of arguments).
46
- # If it has no overloaded implementations,
47
- # the plain name is supported as well.
48
-
3
+ # @!parse
4
+ # class ActiveRecord::Migration
5
+ # # Modify a procedure
6
+ # #
7
+ # # @param [#to_s] name (nil) The qualified name of the procedure
8
+ # # @option [Boolean] :if_exists (false) Suppress the error when the procedure is absent
9
+ # # @yield [p] the block with the procedure's definition
10
+ # # @yieldparam Object receiver of methods specifying the procedure
11
+ # # @return [void]
12
+ # #
13
+ # # The operation changes the procedure without dropping it
14
+ # # (which is useful when there are other objects
15
+ # # using the function and you don't want to change them all).
16
+ # #
17
+ # # You can change any property except for the name
18
+ # # (use `rename_function` instead) and `language`.
19
+ # #
20
+ # # change_procedure "metadata.set_foo(a int)" do |p|
21
+ # # p.body <<~SQL
22
+ # # SET foo = a
23
+ # # SQL
24
+ # # p.security :invoker
25
+ # # p.comment "Multiplies 2 integers"
26
+ # # SQL
27
+ # #
28
+ # # The example above is not invertible because of uncertainty
29
+ # # about the previous state of body and comment.
30
+ # # To define them, use a from options (available in a block syntax only):
31
+ # #
32
+ # # change_procedure "metadata.set_foo(a int)" do |p|
33
+ # # p.body <<~SQL, from: <<~SQL
34
+ # # SET foo = a
35
+ # # SQL
36
+ # # SET foo = -a
37
+ # # SQL
38
+ # # p.comment <<~MSG, from: <<~MSG
39
+ # # Multiplies 2 integers
40
+ # # MSG
41
+ # # Multiplies ints
42
+ # # MSG
43
+ # # p.security :invoker
44
+ # # SQL
45
+ # #
46
+ # # Like in the other operations, the procedure can be
47
+ # # identified by a qualified name (with types of arguments).
48
+ # # If it has no overloaded implementations,
49
+ # # the plain name is supported as well.
50
+ # def change_procedure(name, **options, &block); end
51
+ # end
49
52
  module PGTrunk::Operations::Procedures
50
53
  # @private
51
54
  class ChangeProcedure < Base
@@ -1,58 +1,61 @@
1
1
  # frozen_string_literal: false
2
2
 
3
- # @!method ActiveRecord::Migration#create_procedure(name, **options, &block)
4
- # Create a procedure
5
- #
6
- # @param [#to_s] name (nil)
7
- # The qualified name of the procedure with arguments and returned value type
8
- # @option [Boolean] :replace_existing (false) If the procedure should overwrite an existing one
9
- # @option [#to_s] :language ("sql") The language (like "sql" or "plpgsql")
10
- # @option [#to_s] :body (nil) The body of the procedure
11
- # @option [Symbol] :security (:invoker) Define the role under which the procedure is invoked
12
- # Supported values: :invoker (default), :definer
13
- # @option [#to_s] :comment The description of the procedure
14
- # @yield [Proc] the block with the procedure's definition
15
- # @yieldparam The receiver of methods specifying the procedure
16
- #
17
- # The syntax of the operation is the same as for `create_function`,
18
- # but with only `security` option available. Notice, that
19
- # procedures cannot return values so you're expected not to
20
- # define a returned value as well.
21
- #
22
- # The procedure can be created either using inline syntax
23
- #
24
- # create_procedure "metadata.set_foo(a int)",
25
- # language: :sql,
26
- # body: "SET foo = a",
27
- # comment: "Sets foo value"
28
- #
29
- # or using a block:
30
- #
31
- # create_procedure "metadata.set_foo(a int)" do |p|
32
- # p.language "sql" # (default)
33
- # p.body <<~SQL
34
- # SET foo = a
35
- # SQL
36
- # p.security :invoker # (default), also :definer
37
- # p.comment "Multiplies 2 integers"
38
- # SQL
39
- #
40
- # With a `replace_existing: true` option,
41
- # it will be created using the `CREATE OR REPLACE` clause.
42
- # In this case the migration is irreversible because we
43
- # don't know if and how to restore its previous definition.
44
- #
45
- # create_procedure "set_foo(a int)",
46
- # body: "SET foo = a",
47
- # replace_existing: true
48
- #
49
- # A procedure without arguments is supported as well
50
- #
51
- # # the same as "do_something()"
52
- # create_procedure "do_something" do |p|
53
- # # ...
3
+ # @!parse
4
+ # class ActiveRecord::Migration
5
+ # # Create a procedure
6
+ # #
7
+ # # @param [#to_s] name (nil)
8
+ # # The qualified name of the procedure with arguments and returned value type
9
+ # # @option [Boolean] :replace_existing (false) If the procedure should overwrite an existing one
10
+ # # @option [#to_s] :language ("sql") The language (like "sql" or "plpgsql")
11
+ # # @option [#to_s] :body (nil) The body of the procedure
12
+ # # @option [Symbol] :security (:invoker) Define the role under which the procedure is invoked
13
+ # # Supported values: :invoker (default), :definer
14
+ # # @option [#to_s] :comment The description of the procedure
15
+ # # @yield [p] the block with the procedure's definition
16
+ # # @yieldparam Object receiver of methods specifying the procedure
17
+ # # @return [void]
18
+ # #
19
+ # # The syntax of the operation is the same as for `create_function`,
20
+ # # but with only `security` option available. Notice, that
21
+ # # procedures cannot return values so you're expected not to
22
+ # # define a returned value as well.
23
+ # #
24
+ # # The procedure can be created either using inline syntax
25
+ # #
26
+ # # create_procedure "metadata.set_foo(a int)",
27
+ # # language: :sql,
28
+ # # body: "SET foo = a",
29
+ # # comment: "Sets foo value"
30
+ # #
31
+ # # or using a block:
32
+ # #
33
+ # # create_procedure "metadata.set_foo(a int)" do |p|
34
+ # # p.language "sql" # (default)
35
+ # # p.body <<~SQL
36
+ # # SET foo = a
37
+ # # SQL
38
+ # # p.security :invoker # (default), also :definer
39
+ # # p.comment "Multiplies 2 integers"
40
+ # # SQL
41
+ # #
42
+ # # With a `replace_existing: true` option,
43
+ # # it will be created using the `CREATE OR REPLACE` clause.
44
+ # # In this case the migration is irreversible because we
45
+ # # don't know if and how to restore its previous definition.
46
+ # #
47
+ # # create_procedure "set_foo(a int)",
48
+ # # body: "SET foo = a",
49
+ # # replace_existing: true
50
+ # #
51
+ # # A procedure without arguments is supported as well
52
+ # #
53
+ # # # the same as "do_something()"
54
+ # # create_procedure "do_something" do |p|
55
+ # # # ...
56
+ # # end
57
+ # def create_procedure(name, **options, &block); end
54
58
  # end
55
-
56
59
  module PGTrunk::Operations::Procedures
57
60
  # @private
58
61
  class CreateProcedure < Base
@@ -1,50 +1,53 @@
1
1
  # frozen_string_literal: false
2
2
 
3
- # @!method ActiveRecord::Migration#drop_procedure(name, **options, &block)
4
- # Drop a procedure
5
- #
6
- # @param [#to_s] name (nil)
7
- # The qualified name of the procedure with arguments and returned value type
8
- # @option [Boolean] :if_exists (false) Suppress the error when the procedure is absent
9
- # @option [#to_s] :language ("sql") The language (like "sql" or "plpgsql")
10
- # @option [#to_s] :body (nil) The body of the procedure
11
- # @option [Symbol] :security (:invoker) Define the role under which the procedure is invoked
12
- # Supported values: :invoker (default), :definer
13
- # @option [#to_s] :comment The description of the procedure
14
- # @yield [Proc] the block with the procedure's definition
15
- # @yieldparam The receiver of methods specifying the procedure
16
- #
17
- # A procedure can be dropped by a plain name:
18
- #
19
- # drop_procedure "set_foo"
20
- #
21
- # If several overloaded procedures have the name,
22
- # then you must specify the signature having
23
- # types of attributes at least:
24
- #
25
- # drop_procedure "set_foo(int)"
26
- #
27
- # In both cases above the operation is irreversible. To make it
28
- # inverted you have to provide a full signature along with
29
- # the body definition. The other options are supported as well:
30
- #
31
- # drop_procedure "metadata.set_foo(a int)" do |p|
32
- # p.language "sql" # (default)
33
- # p.body <<~SQL
34
- # SET foo = a
35
- # SQL
36
- # p.security :invoker # (default), also :definer
37
- # p.comment "Multiplies 2 integers"
38
- # SQL
39
- #
40
- # The operation can be called with `if_exists` option. In this case
41
- # it would do nothing when no procedure existed.
42
- #
43
- # drop_procedure "metadata.set_foo(a int)", if_exists: true
44
- #
45
- # Notice, that this option make the operation irreversible because of
46
- # uncertainty about the previous state of the database.
47
-
3
+ # @!parse
4
+ # class ActiveRecord::Migration
5
+ # # Drop a procedure
6
+ # #
7
+ # # @param [#to_s] name (nil)
8
+ # # The qualified name of the procedure with arguments and returned value type
9
+ # # @option [Boolean] :if_exists (false) Suppress the error when the procedure is absent
10
+ # # @option [#to_s] :language ("sql") The language (like "sql" or "plpgsql")
11
+ # # @option [#to_s] :body (nil) The body of the procedure
12
+ # # @option [Symbol] :security (:invoker) Define the role under which the procedure is invoked
13
+ # # Supported values: :invoker (default), :definer
14
+ # # @option [#to_s] :comment The description of the procedure
15
+ # # @yield [p] the block with the procedure's definition
16
+ # # @yieldparam Object receiver of methods specifying the procedure
17
+ # # @return [void]
18
+ # #
19
+ # # A procedure can be dropped by a plain name:
20
+ # #
21
+ # # drop_procedure "set_foo"
22
+ # #
23
+ # # If several overloaded procedures have the name,
24
+ # # then you must specify the signature having
25
+ # # types of attributes at least:
26
+ # #
27
+ # # drop_procedure "set_foo(int)"
28
+ # #
29
+ # # In both cases above the operation is irreversible. To make it
30
+ # # inverted you have to provide a full signature along with
31
+ # # the body definition. The other options are supported as well:
32
+ # #
33
+ # # drop_procedure "metadata.set_foo(a int)" do |p|
34
+ # # p.language "sql" # (default)
35
+ # # p.body <<~SQL
36
+ # # SET foo = a
37
+ # # SQL
38
+ # # p.security :invoker # (default), also :definer
39
+ # # p.comment "Multiplies 2 integers"
40
+ # # SQL
41
+ # #
42
+ # # The operation can be called with `if_exists` option. In this case
43
+ # # it would do nothing when no procedure existed.
44
+ # #
45
+ # # drop_procedure "metadata.set_foo(a int)", if_exists: true
46
+ # #
47
+ # # Notice, that this option make the operation irreversible because of
48
+ # # uncertainty about the previous state of the database.
49
+ # def drop_procedure(name, **options, &block); end
50
+ # end
48
51
  module PGTrunk::Operations::Procedures
49
52
  # @private
50
53
  class DropProcedure < Base
@@ -1,27 +1,30 @@
1
1
  # frozen_string_literal: false
2
2
 
3
- # @!method ActiveRecord::Migration#rename_procedure(name, to:)
4
- # Change the name and/or schema of a procedure
5
- #
6
- # @param [#to_s] :name (nil) The qualified name of the procedure
7
- # @option [#to_s] :to (nil) The new qualified name for the procedure
8
- #
9
- # A procedure can be renamed by changing both the name
10
- # and the schema (namespace) it belongs to.
11
- #
12
- # If there are no overloaded procedures, then you can use a plain name:
13
- #
14
- # rename_procedure "math.set_foo", to: "public.foo_setup"
15
- #
16
- # otherwise the types of attributes must be explicitly specified.
17
- #
18
- # rename_procedure "math.set_foo(int)", to: "public.foo_setup"
19
- #
20
- # Any specification of attributes in `to:` option
21
- # is ignored because they cannot be changed anyway.
22
- #
23
- # The operation is always reversible.
24
-
3
+ # @!parse
4
+ # class ActiveRecord::Migration
5
+ # # Change the name and/or schema of a procedure
6
+ # #
7
+ # # @param [#to_s] :name (nil) The qualified name of the procedure
8
+ # # @option [#to_s] :to (nil) The new qualified name for the procedure
9
+ # # @return [void]
10
+ # #
11
+ # # A procedure can be renamed by changing both the name
12
+ # # and the schema (namespace) it belongs to.
13
+ # #
14
+ # # If there are no overloaded procedures, then you can use a plain name:
15
+ # #
16
+ # # rename_procedure "math.set_foo", to: "public.foo_setup"
17
+ # #
18
+ # # otherwise the types of attributes must be explicitly specified.
19
+ # #
20
+ # # rename_procedure "math.set_foo(int)", to: "public.foo_setup"
21
+ # #
22
+ # # Any specification of attributes in `to:` option
23
+ # # is ignored because they cannot be changed anyway.
24
+ # #
25
+ # # The operation is always reversible.
26
+ # def rename_procedure(name, to:); end
27
+ # end
25
28
  module PGTrunk::Operations::Procedures
26
29
  # @private
27
30
  class RenameProcedure < Base
@@ -1,61 +1,64 @@
1
1
  # frozen_string_literal: false
2
2
 
3
- # @!method ActiveRecord::Migration#create_statistics(name, **options, &block)
4
- # Create a custom statistics
5
- #
6
- # @param [#to_s] name (nil) The qualified name of the statistics
7
- # @option [Boolean] :if_not_exists (false)
8
- # Suppress the error when the statistics is already exist
9
- # @option [#to_s] table (nil)
10
- # The qualified name of the table whose statistics will be collected
11
- # @option [Array<Symbol>] kinds ([:dependencies, :mcv, :ndistinct])
12
- # The kinds of statistics to be collected (all by default).
13
- # Supported values in the array: :dependencies, :mcv, :ndistinct
14
- # @option [#to_s] :comment The description of the statistics
15
- # @yield [Proc] the block with the statistics' definition
16
- # @yieldparam The receiver of methods specifying the statistics
17
- #
18
- # The statistics can be created with explicit name:
19
- #
20
- # create_statistics "users_stats" do |s|
21
- # s.table "users"
22
- # s.columns "family", "name"
23
- # s.kinds :dependencies, :mcv, :ndistinct
24
- # s.comment "Statistics for users' names and families"
25
- # SQL
26
- #
27
- # The name can be generated as well:
28
- #
29
- # create_statistics do |s|
30
- # s.table "users"
31
- # s.columns "family", "name"
32
- # s.kinds :dependencies, :mcv, :ndistinct
33
- # s.comment "Statistics for users' names and families"
34
- # SQL
35
- #
36
- # Since v14 PostgreSQL have supported expressions in addition to columns:
37
- #
38
- # create_statistics "users_stats" do |s|
39
- # s.table "users"
40
- # s.columns "family"
41
- # s.expression "length(name)"
42
- # s.kinds :dependencies, :mcv, :ndistinct
43
- # s.comment "Statistics for users' name lengths and families"
44
- # SQL
45
- #
46
- # as well as statistics for the sole expression (kinds must be blank)
47
- # by columns of some table.
48
- #
49
- # create_statistics "users_stats" do |s|
50
- # s.table "users"
51
- # s.expression "length(name || ' ' || family)"
52
- # s.comment "Statistics for full name lengths"
53
- # SQL
54
- #
55
- # Use `if_not_exists: true` to suppress error in case the statistics
56
- # has already been created. This option, though, makes the migration
57
- # irreversible due to uncertainty of the previous state of the database.
58
-
3
+ # @!parse
4
+ # class ActiveRecord::Migration
5
+ # # Create a custom statistics
6
+ # #
7
+ # # @param [#to_s] name (nil) The qualified name of the statistics
8
+ # # @option [Boolean] :if_not_exists (false)
9
+ # # Suppress the error when the statistics is already exist
10
+ # # @option [#to_s] table (nil)
11
+ # # The qualified name of the table whose statistics will be collected
12
+ # # @option [Array<Symbol>] kinds ([:dependencies, :mcv, :ndistinct])
13
+ # # The kinds of statistics to be collected (all by default).
14
+ # # Supported values in the array: :dependencies, :mcv, :ndistinct
15
+ # # @option [#to_s] :comment The description of the statistics
16
+ # # @yield [s] the block with the statistics' definition
17
+ # # @yieldparam Object receiver of methods specifying the statistics
18
+ # # @return [void]
19
+ # #
20
+ # # The statistics can be created with explicit name:
21
+ # #
22
+ # # create_statistics "users_stats" do |s|
23
+ # # s.table "users"
24
+ # # s.columns "family", "name"
25
+ # # s.kinds :dependencies, :mcv, :ndistinct
26
+ # # s.comment "Statistics for users' names and families"
27
+ # # SQL
28
+ # #
29
+ # # The name can be generated as well:
30
+ # #
31
+ # # create_statistics do |s|
32
+ # # s.table "users"
33
+ # # s.columns "family", "name"
34
+ # # s.kinds :dependencies, :mcv, :ndistinct
35
+ # # s.comment "Statistics for users' names and families"
36
+ # # SQL
37
+ # #
38
+ # # Since v14 PostgreSQL have supported expressions in addition to columns:
39
+ # #
40
+ # # create_statistics "users_stats" do |s|
41
+ # # s.table "users"
42
+ # # s.columns "family"
43
+ # # s.expression "length(name)"
44
+ # # s.kinds :dependencies, :mcv, :ndistinct
45
+ # # s.comment "Statistics for users' name lengths and families"
46
+ # # SQL
47
+ # #
48
+ # # as well as statistics for the sole expression (kinds must be blank)
49
+ # # by columns of some table.
50
+ # #
51
+ # # create_statistics "users_stats" do |s|
52
+ # # s.table "users"
53
+ # # s.expression "length(name || ' ' || family)"
54
+ # # s.comment "Statistics for full name lengths"
55
+ # # SQL
56
+ # #
57
+ # # Use `if_not_exists: true` to suppress error in case the statistics
58
+ # # has already been created. This option, though, makes the migration
59
+ # # irreversible due to uncertainty of the previous state of the database.
60
+ # def create_statistics(name, **options, &block); end
61
+ # end
59
62
  module PGTrunk::Operations::Statistics
60
63
  # SQL snippet to fetch statistics in v10-13
61
64
  SQL_V10 = <<~SQL.freeze