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,51 +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
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
# SQL
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
26
|
-
#
|
27
|
-
#
|
28
|
-
#
|
29
|
-
#
|
30
|
-
#
|
31
|
-
#
|
32
|
-
#
|
33
|
-
#
|
34
|
-
#
|
35
|
-
#
|
36
|
-
# v
|
37
|
-
# v.
|
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
|
-
# @!
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
# @
|
8
|
-
# @option [Boolean] :
|
9
|
-
# @option [
|
10
|
-
# @option [
|
11
|
-
# @option [#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
# @
|
17
|
-
# @
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
26
|
-
#
|
27
|
-
#
|
28
|
-
#
|
29
|
-
#
|
30
|
-
# v.
|
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
|
-
# @!
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
# @
|
8
|
-
# @option [
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
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
|
data/lib/pg_trunk/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2022-01-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|