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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/pg_trunk/operations/check_constraints/add_check_constraint.rb +36 -33
- data/lib/pg_trunk/operations/check_constraints/drop_check_constraint.rb +43 -40
- data/lib/pg_trunk/operations/check_constraints/rename_check_constraint.rb +33 -30
- data/lib/pg_trunk/operations/check_constraints/validate_check_constraint.rb +24 -21
- data/lib/pg_trunk/operations/composite_types/change_composite_type.rb +53 -50
- data/lib/pg_trunk/operations/composite_types/create_composite_type.rb +22 -19
- data/lib/pg_trunk/operations/composite_types/drop_composite_type.rb +46 -43
- data/lib/pg_trunk/operations/composite_types/rename_composite_type.rb +15 -12
- data/lib/pg_trunk/operations/domains/change_domain.rb +50 -47
- data/lib/pg_trunk/operations/domains/create_domain.rb +28 -25
- data/lib/pg_trunk/operations/domains/drop_domain.rb +44 -41
- data/lib/pg_trunk/operations/domains/rename_domain.rb +15 -12
- data/lib/pg_trunk/operations/enums/change_enum.rb +35 -32
- data/lib/pg_trunk/operations/enums/create_enum.rb +23 -20
- data/lib/pg_trunk/operations/enums/drop_enum.rb +42 -39
- data/lib/pg_trunk/operations/enums/rename_enum.rb +15 -12
- data/lib/pg_trunk/operations/foreign_keys/add_foreign_key.rb +52 -49
- data/lib/pg_trunk/operations/foreign_keys/drop_foreign_key.rb +51 -48
- data/lib/pg_trunk/operations/foreign_keys/rename_foreign_key.rb +32 -29
- data/lib/pg_trunk/operations/functions/change_function.rb +50 -47
- data/lib/pg_trunk/operations/functions/create_function.rb +67 -64
- data/lib/pg_trunk/operations/functions/drop_function.rb +68 -65
- data/lib/pg_trunk/operations/functions/rename_function.rb +25 -22
- data/lib/pg_trunk/operations/materialized_views/change_materialized_view.rb +58 -55
- data/lib/pg_trunk/operations/materialized_views/create_materialized_view.rb +74 -71
- data/lib/pg_trunk/operations/materialized_views/drop_materialized_view.rb +49 -46
- data/lib/pg_trunk/operations/materialized_views/refresh_materialized_view.rb +27 -24
- data/lib/pg_trunk/operations/materialized_views/rename_materialized_view.rb +25 -22
- data/lib/pg_trunk/operations/procedures/change_procedure.rb +49 -46
- data/lib/pg_trunk/operations/procedures/create_procedure.rb +55 -52
- data/lib/pg_trunk/operations/procedures/drop_procedure.rb +48 -45
- data/lib/pg_trunk/operations/procedures/rename_procedure.rb +25 -22
- data/lib/pg_trunk/operations/statistics/create_statistics.rb +59 -56
- data/lib/pg_trunk/operations/statistics/drop_statistics.rb +56 -53
- data/lib/pg_trunk/operations/statistics/rename_statistics.rb +16 -13
- data/lib/pg_trunk/operations/triggers/change_trigger.rb +21 -18
- data/lib/pg_trunk/operations/triggers/create_trigger.rb +57 -54
- data/lib/pg_trunk/operations/triggers/drop_trigger.rb +49 -46
- data/lib/pg_trunk/operations/triggers/rename_trigger.rb +51 -48
- data/lib/pg_trunk/operations/views/change_view.rb +41 -38
- data/lib/pg_trunk/operations/views/create_view.rb +48 -45
- data/lib/pg_trunk/operations/views/drop_view.rb +49 -46
- data/lib/pg_trunk/operations/views/rename_view.rb +23 -20
- data/lib/pg_trunk/version.rb +1 -1
- metadata +2 -2
@@ -1,55 +1,58 @@
|
|
1
1
|
# frozen_string_literal: false
|
2
2
|
|
3
|
-
# @!
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
# @param [#to_s]
|
8
|
-
# @
|
9
|
-
# @option [#to_s] :
|
10
|
-
# @option [
|
11
|
-
# @option [
|
12
|
-
# @option [
|
13
|
-
# @option [
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
# @
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
26
|
-
#
|
27
|
-
#
|
28
|
-
#
|
29
|
-
#
|
30
|
-
#
|
31
|
-
#
|
32
|
-
#
|
33
|
-
#
|
34
|
-
#
|
35
|
-
#
|
36
|
-
#
|
37
|
-
#
|
38
|
-
#
|
39
|
-
#
|
40
|
-
#
|
3
|
+
# @!parse
|
4
|
+
# class ActiveRecord::Migration
|
5
|
+
# # Create a foreign key constraint
|
6
|
+
# #
|
7
|
+
# # @param [#to_s] table (nil) The qualified name of the table
|
8
|
+
# # @param [#to_s] reference (nil) The qualified name of the reference table
|
9
|
+
# # @option [#to_s] :name (nil) The current name of the foreign key
|
10
|
+
# # @option [#to_s] :to (nil) The new name for the foreign key
|
11
|
+
# # @option [Array<#to_s>] :columns ([]) The list of columns of the table
|
12
|
+
# # @option [#to_s] :column (nil) An alias for :columns for the case of single-column keys
|
13
|
+
# # @option [Array<#to_s>] :primary_key ([]) The list of columns of the reference table
|
14
|
+
# # @option [Symbol] :match (:full) Define how to match rows
|
15
|
+
# # Supported values: :full (default), :partial, :simple
|
16
|
+
# # @option [Symbol] :on_delete (:restrict)
|
17
|
+
# # Define how to handle the deletion of the referred row.
|
18
|
+
# # Supported values: :restrict (default), :cascade, :nullify, :reset
|
19
|
+
# # @option [Symbol] :on_update (:restrict)
|
20
|
+
# # Define how to handle the update of the referred row.
|
21
|
+
# # Supported values: :restrict (default), :cascade, :nullify, :reset
|
22
|
+
# # @yield [k] the block with the key's definition
|
23
|
+
# # @yieldparam Object receiver of methods specifying the foreign key
|
24
|
+
# # @return [void]
|
25
|
+
# #
|
26
|
+
# # The table and reference of the new key must be set explicitly.
|
27
|
+
# # All the rest (including the name) can be generated by default:
|
28
|
+
# #
|
29
|
+
# # # same as `..., column: 'role_id', primary_key: 'id'`
|
30
|
+
# # add_foreign_key :users, :roles
|
31
|
+
# #
|
32
|
+
# # The block syntax can be used for any argument:
|
33
|
+
# #
|
34
|
+
# # add_foreign_key do |k|
|
35
|
+
# # k.table "users"
|
36
|
+
# # k.reference "roles"
|
37
|
+
# # k.column "role_id" # (generated by default from reference and pk)
|
38
|
+
# # k.primary_key "id" # (default)
|
39
|
+
# # k.on_update :cascade # :restrict (default)
|
40
|
+
# # k.on_delete :cascade # :restrict (default)
|
41
|
+
# # k.name "user_roles_fk" # can be generated
|
42
|
+
# # k.comment "Phone is 10+ chars long"
|
43
|
+
# # end
|
44
|
+
# #
|
45
|
+
# # Composite foreign keys are supported as well:
|
46
|
+
# #
|
47
|
+
# # add_foreign_key "users", "roles" do |k|
|
48
|
+
# # k.columns %w[role_name role_id]
|
49
|
+
# # k.primary_key %w[name id] # Requires unique index
|
50
|
+
# # k.match :full # :partial, :simple (default)
|
51
|
+
# # end
|
52
|
+
# #
|
53
|
+
# # The operation is always invertible.
|
54
|
+
# def add_foreign_key(table, reference, **options, &block); end
|
41
55
|
# end
|
42
|
-
#
|
43
|
-
# Composite foreign keys are supported as well:
|
44
|
-
#
|
45
|
-
# add_foreign_key "users", "roles" do |c|
|
46
|
-
# c.columns %w[role_name role_id]
|
47
|
-
# c.primary_key %w[name id] # Requires unique index
|
48
|
-
# c.match :full # :partial, :simple (default)
|
49
|
-
# end
|
50
|
-
#
|
51
|
-
# The operation is always invertible.
|
52
|
-
|
53
56
|
module PGTrunk::Operations::ForeignKeys
|
54
57
|
# @private
|
55
58
|
class AddForeignKey < Base
|
@@ -1,54 +1,57 @@
|
|
1
1
|
# frozen_string_literal: false
|
2
2
|
|
3
|
-
# @!
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
# @param [#to_s]
|
8
|
-
# @
|
9
|
-
# @option [
|
10
|
-
# @option [
|
11
|
-
# @option [
|
12
|
-
# @option [
|
13
|
-
# @option [
|
14
|
-
# @option [
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
# @
|
24
|
-
#
|
25
|
-
#
|
26
|
-
#
|
27
|
-
#
|
28
|
-
#
|
29
|
-
#
|
30
|
-
#
|
31
|
-
#
|
32
|
-
#
|
33
|
-
#
|
34
|
-
#
|
35
|
-
#
|
36
|
-
#
|
37
|
-
#
|
38
|
-
#
|
39
|
-
#
|
3
|
+
# @!parse
|
4
|
+
# class ActiveRecord::Migration
|
5
|
+
# # Drops a foreign key constraint
|
6
|
+
# #
|
7
|
+
# # @param [#to_s] table (nil) The qualified name of the table
|
8
|
+
# # @param [#to_s] reference (nil) The qualified name of the reference table
|
9
|
+
# # @option [#to_s] :name (nil) The current name of the foreign key
|
10
|
+
# # @option [Boolean] :if_exists (false) Suppress the error when the constraint is absent
|
11
|
+
# # @option [#to_s] :to (nil) The new name for the foreign key
|
12
|
+
# # @option [Array<#to_s>] :columns ([]) The list of columns of the table
|
13
|
+
# # @option [#to_s] :column (nil) An alias for :columns for the case of single-column keys
|
14
|
+
# # @option [Array<#to_s>] :primary_key ([]) The list of columns of the reference table
|
15
|
+
# # @option [Symbol] :match (:full) Define how to match rows
|
16
|
+
# # Supported values: :full (default), :partial, :simple
|
17
|
+
# # @option [Symbol] :on_delete (:restrict)
|
18
|
+
# # Define how to handle the deletion of the referred row.
|
19
|
+
# # Supported values: :restrict (default), :cascade, :nullify, :reset
|
20
|
+
# # @option [Symbol] :on_update (:restrict)
|
21
|
+
# # Define how to handle the update of the referred row.
|
22
|
+
# # Supported values: :restrict (default), :cascade, :nullify, :reset
|
23
|
+
# # @yield [k] the block with the key's definition
|
24
|
+
# # @yieldparam Object receiver of methods specifying the foreign key
|
25
|
+
# # @return [void]
|
26
|
+
# #
|
27
|
+
# # The key can be identified by table/name (not invertible):
|
28
|
+
# #
|
29
|
+
# # drop_foreign_key "users", name: "user_roles_fk"
|
30
|
+
# #
|
31
|
+
# # To make it invertible use the same options like
|
32
|
+
# # in the `add_foreign_key` operation.
|
33
|
+
# #
|
34
|
+
# # drop_foreign_key do |k|
|
35
|
+
# # k.table "users"
|
36
|
+
# # k.reference "roles"
|
37
|
+
# # k.column "role_id"
|
38
|
+
# # k.primary_key "id"
|
39
|
+
# # k.on_update :cascade
|
40
|
+
# # k.on_delete :cascade
|
41
|
+
# # k.comment "Phone is 10+ chars long"
|
42
|
+
# # end
|
43
|
+
# #
|
44
|
+
# # Notice that the name can be skipped, in this case we would
|
45
|
+
# # find it in the database.
|
46
|
+
# #
|
47
|
+
# # The operation can be called with `if_exists` option.
|
48
|
+
# #
|
49
|
+
# # drop_foreign_key "users", name: "user_roles_fk", if_exists: true
|
50
|
+
# #
|
51
|
+
# # In this case the operation is always irreversible due to
|
52
|
+
# # uncertainty of the previous state of the database.
|
53
|
+
# def drop_foreign_key(table, reference, **options, &block); end
|
40
54
|
# end
|
41
|
-
#
|
42
|
-
# Notice that the name can be skipped, in this case we would
|
43
|
-
# find it in the database.
|
44
|
-
#
|
45
|
-
# The operation can be called with `if_exists` option.
|
46
|
-
#
|
47
|
-
# drop_foreign_key "users", name: "user_roles_fk", if_exists: true
|
48
|
-
#
|
49
|
-
# In this case the operation is always irreversible due to
|
50
|
-
# uncertainty of the previous state of the database.
|
51
|
-
|
52
55
|
module PGTrunk::Operations::ForeignKeys
|
53
56
|
# @private
|
54
57
|
class DropForeignKey < Base
|
@@ -1,34 +1,37 @@
|
|
1
1
|
# frozen_string_literal: false
|
2
2
|
|
3
|
-
# @!
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
# @param [#to_s]
|
8
|
-
# @
|
9
|
-
# @option [#to_s] :
|
10
|
-
# @option [
|
11
|
-
# @option [
|
12
|
-
# @option [
|
13
|
-
# @
|
14
|
-
# @
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
26
|
-
#
|
27
|
-
#
|
28
|
-
#
|
29
|
-
#
|
30
|
-
#
|
31
|
-
|
3
|
+
# @!parse
|
4
|
+
# class ActiveRecord::Migration
|
5
|
+
# # Rename a foreign key
|
6
|
+
# #
|
7
|
+
# # @param [#to_s] table (nil) The qualified name of the table
|
8
|
+
# # @param [#to_s] reference (nil) The qualified name of the reference table
|
9
|
+
# # @option [#to_s] :name (nil) The current name of the foreign key
|
10
|
+
# # @option [#to_s] :to (nil) The new name for the foreign key
|
11
|
+
# # @option [Array<#to_s>] :columns ([]) The list of columns of the table
|
12
|
+
# # @option [#to_s] :column (nil) An alias for :columns for the case of single-column keys
|
13
|
+
# # @option [Array<#to_s>] :primary_key ([]) The list of columns of the reference table
|
14
|
+
# # @yield [k] the block with the key's definition
|
15
|
+
# # @yieldparam Object receiver of methods specifying the foreign key
|
16
|
+
# # @return [void]
|
17
|
+
# #
|
18
|
+
# # You can rename the foreign key constraint identified by its explicit name:
|
19
|
+
# #
|
20
|
+
# # rename_foreign_key :users,
|
21
|
+
# # name: "user_roles_fk",
|
22
|
+
# # to: "constraints.users_by_roles_fk"
|
23
|
+
# #
|
24
|
+
# # The key can also be found in the database by table/reference/columns/pk
|
25
|
+
# #
|
26
|
+
# # rename_foreign_key :users, :roles, primary_key: "name", to: "user_roles"
|
27
|
+
# #
|
28
|
+
# # If a new name is missed, then the name will be reset to the auto-generated one:
|
29
|
+
# #
|
30
|
+
# # rename_foreign_key :users, "user_roles_fk"
|
31
|
+
# #
|
32
|
+
# # The operation is always reversible.
|
33
|
+
# def rename_foreign_key(table, reference, **options, &block); end
|
34
|
+
# end
|
32
35
|
module PGTrunk::Operations::ForeignKeys
|
33
36
|
#
|
34
37
|
# Definition for the `rename_foreign_key` operation
|
@@ -1,52 +1,55 @@
|
|
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
|
-
# f.
|
22
|
-
# f.
|
23
|
-
# f.
|
24
|
-
# f.
|
25
|
-
# #
|
26
|
-
#
|
27
|
-
#
|
28
|
-
#
|
29
|
-
#
|
30
|
-
#
|
31
|
-
#
|
32
|
-
#
|
33
|
-
#
|
34
|
-
#
|
35
|
-
# SQL
|
36
|
-
# SELECT
|
37
|
-
# SQL
|
38
|
-
#
|
39
|
-
#
|
40
|
-
# f.
|
41
|
-
# f.
|
42
|
-
# f.
|
43
|
-
# #
|
44
|
-
#
|
45
|
-
#
|
46
|
-
#
|
47
|
-
#
|
48
|
-
#
|
49
|
-
|
3
|
+
# @!parse
|
4
|
+
# class ActiveRecord::Migration
|
5
|
+
# # Modify a function
|
6
|
+
# #
|
7
|
+
# # @param [#to_s] name (nil) The qualified name of the function
|
8
|
+
# # @option [Boolean] :if_exists (false) Suppress the error when the function is absent
|
9
|
+
# # @yield [f] the block with the function's definition
|
10
|
+
# # @yieldparam Object receiver of methods specifying the function
|
11
|
+
# # @return [void]
|
12
|
+
# #
|
13
|
+
# # The operation changes the function without dropping it
|
14
|
+
# # (which can be necessary 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_function "math.mult(int, int)" do |f|
|
21
|
+
# # f.volatility :immutable, from: :stable
|
22
|
+
# # f.parallel :safe, from: :restricted
|
23
|
+
# # f.security :invoker
|
24
|
+
# # f.leakproof true
|
25
|
+
# # f.strict true
|
26
|
+
# # f.cost 5.0
|
27
|
+
# # # f.rows 1 (supported for functions returning sets of rows)
|
28
|
+
# # SQL
|
29
|
+
# #
|
30
|
+
# # The example above is not invertible because of uncertainty
|
31
|
+
# # about the previous volatility, parallelism, and cost.
|
32
|
+
# # To define them, use a from options (available in a block syntax only):
|
33
|
+
# #
|
34
|
+
# # change_function "math.mult(a int, b int)" do |f|
|
35
|
+
# # f.body <<~SQL, from: <<~SQL
|
36
|
+
# # SELECT a * b;
|
37
|
+
# # SQL
|
38
|
+
# # SELECT min(a * b, 1);
|
39
|
+
# # SQL
|
40
|
+
# # f.volatility :immutable, from: :volatile
|
41
|
+
# # f.parallel :safe, from: :unsafe
|
42
|
+
# # f.leakproof true
|
43
|
+
# # f.strict true
|
44
|
+
# # f.cost 5.0, from: 100.0
|
45
|
+
# # # f.rows 1, from: 0
|
46
|
+
# # SQL
|
47
|
+
# #
|
48
|
+
# # Like in the other operations, the function can be
|
49
|
+
# # identified by a qualified name (with types of arguments).
|
50
|
+
# # If it has no overloaded implementations, the plain name is supported as well.
|
51
|
+
# def change_function(name, **options, &block); end
|
52
|
+
# end
|
50
53
|
module PGTrunk::Operations::Functions
|
51
54
|
# @private
|
52
55
|
class ChangeFunction < Base
|
@@ -1,70 +1,73 @@
|
|
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
|
-
# SQL
|
41
|
-
#
|
42
|
-
#
|
43
|
-
# f.
|
44
|
-
# f.
|
45
|
-
# f.
|
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 [Boolean] :replace_existing (false) If the function 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 function
|
12
|
+
# # @option [Symbol] :volatility (:volatile) The volatility of the function.
|
13
|
+
# # Supported values: :volatile (default), :stable, :immutable
|
14
|
+
# # @option [Symbol] :parallel (:unsafe) The safety of parallel execution.
|
15
|
+
# # Supported values: :unsafe (default), :restricted, :safe
|
16
|
+
# # @option [Symbol] :security (:invoker) Define the role under which the function is invoked
|
17
|
+
# # Supported values: :invoker (default), :definer
|
18
|
+
# # @option [Boolean] :leakproof (false) If the function is leakproof
|
19
|
+
# # @option [Boolean] :strict (false) If the function is strict
|
20
|
+
# # @option [Float] :cost (nil) The cost estimation for the function
|
21
|
+
# # @option [Integer] :rows (nil) The number of rows returned by a function
|
22
|
+
# # @option [#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
|
+
# # create_function "math.mult(a int, b int) int",
|
30
|
+
# # language: :sql,
|
31
|
+
# # body: "SELECT a * b",
|
32
|
+
# # volatility: :immutable,
|
33
|
+
# # leakproof: true,
|
34
|
+
# # comment: "Multiplies 2 integers"
|
35
|
+
# #
|
36
|
+
# # or using a block:
|
37
|
+
# #
|
38
|
+
# # create_function "math.mult(a int, b int) int" do |f|
|
39
|
+
# # f.language "sql" # (default)
|
40
|
+
# # f.body <<~SQL
|
41
|
+
# # SELECT a * b;
|
42
|
+
# # SQL
|
43
|
+
# # f.volatility :immutable # :stable, :volatile (default)
|
44
|
+
# # f.parallel :safe # :restricted, :unsafe (default)
|
45
|
+
# # f.security :invoker # (default), also :definer
|
46
|
+
# # f.leakproof true
|
47
|
+
# # f.strict true
|
48
|
+
# # f.cost 5.0
|
49
|
+
# # # f.rows 1 (supported for functions returning sets of rows)
|
50
|
+
# # f.comment "Multiplies 2 integers"
|
51
|
+
# # SQL
|
52
|
+
# #
|
53
|
+
# # With a `replace_existing: true` option,
|
54
|
+
# # it will be created using the `CREATE OR REPLACE` clause.
|
55
|
+
# # In this case the migration is irreversible because we
|
56
|
+
# # don't know if and how to restore its previous definition.
|
57
|
+
# #
|
58
|
+
# # create_function "math.mult(a int, b int) int",
|
59
|
+
# # body: "SELECT a * b",
|
60
|
+
# # replace_existing: true
|
61
|
+
# #
|
62
|
+
# # We presume a function without arguments should have
|
63
|
+
# # no arguments and return `void` like
|
64
|
+
# #
|
65
|
+
# # # the same as "do_something() void"
|
66
|
+
# # create_function "do_something" do |f|
|
67
|
+
# # # ...
|
68
|
+
# # end
|
69
|
+
# def create_function(name, **options, &block); end
|
66
70
|
# end
|
67
|
-
|
68
71
|
module PGTrunk::Operations::Functions
|
69
72
|
# @private
|
70
73
|
class CreateFunction < Base
|