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,51 +1,54 @@
1
1
  # frozen_string_literal: false
2
2
 
3
- # @!method ActiveRecord::Migration#create_view(name, **options, &block)
4
- # Create a view
5
- #
6
- # @param [#to_s] name (nil) The qualified name of the view
7
- # @option [Boolean] :replace_existing (false) If the view should overwrite an existing one
8
- # @option [#to_s] :sql_definition (nil) The snippet containing the query
9
- # @option [#to_i] :version (nil)
10
- # The alternative way to set sql_definition by referencing to a file containing the snippet
11
- # @option [#to_s] :check (nil) Controls the behavior of automatically updatable views
12
- # Supported values: :local, :cascaded
13
- # @option [#to_s] :comment (nil) The comment describing the view
14
- # @yield [Proc] the block with the view's definition
15
- # @yieldparam The receiver of methods specifying the view
16
- #
17
- # The operation creates the view using its `sql_definition`:
18
- #
19
- # create_view("views.admin_users", sql_definition: <<~SQL)
20
- # SELECT id, name FROM users WHERE admin;
21
- # SQL
22
- #
23
- # For compatibility to the `scenic` gem, we also support
24
- # adding a definition via its version:
25
- #
26
- # create_view "admin_users", version: 1
27
- #
28
- # It is expected, that a `db/views/admin_users_v01.sql`
29
- # to contain the SQL snippet.
30
- #
31
- # You can also set a comment describing the view, and the check option
32
- # (either `:local` or `:cascaded`):
33
- #
34
- # create_view "admin_users" do |v|
35
- # v.sql_definition "SELECT id, name FROM users WHERE admin;"
36
- # v.check :local
37
- # v.comment "Admin users only"
3
+ # @!parse
4
+ # class ActiveRecord::Migration
5
+ # # Create a view
6
+ # #
7
+ # # @param [#to_s] name (nil) The qualified name of the view
8
+ # # @option [Boolean] :replace_existing (false) If the view should overwrite an existing one
9
+ # # @option [#to_s] :sql_definition (nil) The snippet containing the query
10
+ # # @option [#to_i] :version (nil)
11
+ # # The alternative way to set sql_definition by referencing to a file containing the snippet
12
+ # # @option [#to_s] :check (nil) Controls the behavior of automatically updatable views
13
+ # # Supported values: :local, :cascaded
14
+ # # @option [#to_s] :comment (nil) The comment describing the view
15
+ # # @yield [v] the block with the view's definition
16
+ # # @yieldparam Object receiver of methods specifying the view
17
+ # # @return [void]
18
+ # #
19
+ # # The operation creates the view using its `sql_definition`:
20
+ # #
21
+ # # create_view("views.admin_users", sql_definition: <<~SQL)
22
+ # # SELECT id, name FROM users WHERE admin;
23
+ # # SQL
24
+ # #
25
+ # # For compatibility to the `scenic` gem, we also support
26
+ # # adding a definition via its version:
27
+ # #
28
+ # # create_view "admin_users", version: 1
29
+ # #
30
+ # # It is expected, that a `db/views/admin_users_v01.sql`
31
+ # # to contain the SQL snippet.
32
+ # #
33
+ # # You can also set a comment describing the view, and the check option
34
+ # # (either `:local` or `:cascaded`):
35
+ # #
36
+ # # create_view "admin_users" do |v|
37
+ # # v.sql_definition "SELECT id, name FROM users WHERE admin;"
38
+ # # v.check :local
39
+ # # v.comment "Admin users only"
40
+ # # end
41
+ # #
42
+ # # With the `replace_existing: true` option the operation
43
+ # # would use `CREATE OR REPLACE VIEW` command, so it
44
+ # # can be used to "update" (or reload) the existing view.
45
+ # #
46
+ # # create_view "admin_users", version: 1, replace_existing: true
47
+ # #
48
+ # # This option makes an operation irreversible due to uncertainty
49
+ # # of the previous state of the database.
50
+ # def create_view(name, **options, &block); end
38
51
  # end
39
- #
40
- # With the `replace_existing: true` option the operation
41
- # would use `CREATE OR REPLACE VIEW` command, so it
42
- # can be used to "update" (or reload) the existing view.
43
- #
44
- # create_view "admin_users", version: 1, replace_existing: true
45
- #
46
- # This option makes an operation irreversible due to uncertainty
47
- # of the previous state of the database.
48
-
49
52
  module PGTrunk::Operations::Views
50
53
  # @private
51
54
  class CreateView < Base
@@ -1,52 +1,55 @@
1
1
  # frozen_string_literal: false
2
2
 
3
- # @!method ActiveRecord::Migration#drop_view(name, **options, &block)
4
- # Drop a view
5
- #
6
- # @param [#to_s] name (nil) The qualified name of the view
7
- # @option [Boolean] :replace_existing (false) If the view should overwrite an existing one
8
- # @option [Boolean] :if_exists (false) Suppress the error when the view is absent
9
- # @option [Symbol] :force (:restrict) How to process dependent objects (`:cascade` or `:restrict`)
10
- # @option [#to_s] :sql_definition (nil) The snippet containing the query
11
- # @option [#to_i] :revert_to_version (nil)
12
- # The alternative way to set sql_definition by referencing to a file containing the snippet
13
- # @option [#to_s] :check (nil) Controls the behavior of automatically updatable views
14
- # Supported values: :local, :cascaded
15
- # @option [#to_s] :comment (nil) The comment describing the view
16
- # @yield [Proc] the block with the view's definition
17
- # @yieldparam The receiver of methods specifying the view
18
- #
19
- # The operation drops the existing view identified by its
20
- # qualified name (it can include a schema).
21
- #
22
- # drop_view "views.admin_users"
23
- #
24
- # To make the operation invertible, use the same options
25
- # as in the `create_view` operation.
26
- #
27
- # drop_view "views.admin_users" do |v|
28
- # v.sql_definition "SELECT name, email FROM users WHERE admin;"
29
- # v.check :local
30
- # v.comment "Admin users only"
3
+ # @!parse
4
+ # class ActiveRecord::Migration
5
+ # # Drop a view
6
+ # #
7
+ # # @param [#to_s] name (nil) The qualified name of the view
8
+ # # @option [Boolean] :replace_existing (false) If the view should overwrite an existing one
9
+ # # @option [Boolean] :if_exists (false) Suppress the error when the view is absent
10
+ # # @option [Symbol] :force (:restrict) How to process dependent objects (`:cascade` or `:restrict`)
11
+ # # @option [#to_s] :sql_definition (nil) The snippet containing the query
12
+ # # @option [#to_i] :revert_to_version (nil)
13
+ # # The alternative way to set sql_definition by referencing to a file containing the snippet
14
+ # # @option [#to_s] :check (nil) Controls the behavior of automatically updatable views
15
+ # # Supported values: :local, :cascaded
16
+ # # @option [#to_s] :comment (nil) The comment describing the view
17
+ # # @yield [v] the block with the view's definition
18
+ # # @yieldparam Object receiver of methods specifying the view
19
+ # # @return [void]
20
+ # #
21
+ # # The operation drops the existing view identified by its
22
+ # # qualified name (it can include a schema).
23
+ # #
24
+ # # drop_view "views.admin_users"
25
+ # #
26
+ # # To make the operation invertible, use the same options
27
+ # # as in the `create_view` operation.
28
+ # #
29
+ # # drop_view "views.admin_users" do |v|
30
+ # # v.sql_definition "SELECT name, email FROM users WHERE admin;"
31
+ # # v.check :local
32
+ # # v.comment "Admin users only"
33
+ # # end
34
+ # #
35
+ # # You can also use a version-base SQL definition like:
36
+ # #
37
+ # # drop_view "views.admin_users", revert_to_version: 1
38
+ # #
39
+ # # With the `force: :cascade` option the operation would remove
40
+ # # all the objects which depend on the view.
41
+ # #
42
+ # # drop_view "views.admin_users", force: :cascade
43
+ # #
44
+ # # With the `if_exists: true` option the operation won't fail
45
+ # # even when the view was absent in the database.
46
+ # #
47
+ # # drop_view "views.admin_users", if_exists: true
48
+ # #
49
+ # # Both options make an operation irreversible due to uncertainty
50
+ # # of the previous state of the database.
51
+ # def drop_view(name, **options, &block); end
31
52
  # end
32
- #
33
- # You can also use a version-base SQL definition like:
34
- #
35
- # drop_view "views.admin_users", revert_to_version: 1
36
- #
37
- # With the `force: :cascade` option the operation would remove
38
- # all the objects which depend on the view.
39
- #
40
- # drop_view "views.admin_users", force: :cascade
41
- #
42
- # With the `if_exists: true` option the operation won't fail
43
- # even when the view was absent in the database.
44
- #
45
- # drop_view "views.admin_users", if_exists: true
46
- #
47
- # Both options make an operation irreversible due to uncertainty
48
- # of the previous state of the database.
49
-
50
53
  module PGTrunk::Operations::Views
51
54
  # @private
52
55
  class DropView < Base
@@ -1,25 +1,28 @@
1
1
  # frozen_string_literal: false
2
2
 
3
- # @!method ActiveRecord::Migration#rename_view(name, **options)
4
- # Change the name and/or schema of a 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 view can be renamed by changing both the name
11
- # and the schema (namespace) it belongs to.
12
- #
13
- # rename_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_view "views.admin_users", to: "admins", if_exists: true
19
- #
20
- # At the same time, the option makes a view irreversible
21
- # due to uncertainty of the previous state of the database.
22
-
3
+ # @!parse
4
+ # class ActiveRecord::Migration
5
+ # # Change the name and/or schema of a 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 view can be renamed by changing both the name
13
+ # # and the schema (namespace) it belongs to.
14
+ # #
15
+ # # rename_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_view "views.admin_users", to: "admins", if_exists: true
21
+ # #
22
+ # # At the same time, the option makes a view irreversible
23
+ # # due to uncertainty of the previous state of the database.
24
+ # def rename_view(name, **options); end
25
+ # end
23
26
  module PGTrunk::Operations::Views
24
27
  # @private
25
28
  class RenameView < Base
@@ -2,5 +2,5 @@
2
2
 
3
3
  module PGTrunk
4
4
  # @private
5
- VERSION = "0.1.0"
5
+ VERSION = "0.1.1"
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pg_trunk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kozin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-14 00:00:00.000000000 Z
11
+ date: 2022-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord