dynamic_migrations 3.6.13 → 3.6.14
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a53664f8e85f6f7570b65b756687db445a71c5e48cdc7f52ab4a394570e9be5
|
4
|
+
data.tar.gz: 49cad85aaff8c311714a5e9c47c16708e8f6c3d7b6f276ce94d5b0dc8703eae6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 03230e628a4b6b0719d12ffeecc68ba0395c405ae828232331195a319f2bfc394a00ba80f999ba68660392dede3a76d4656b749c991ba940332901c0a93cb771
|
7
|
+
data.tar.gz: 7b169d5836f5c6a53cfab698c3f8af30c397334bea5efb1087de0f9c33c481218955b90311715a75f96c124c9bd6306887713eddd5a218cbe375bedbd6dd5f31
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [3.6.14](https://github.com/craigulliott/dynamic_migrations/compare/v3.6.13...v3.6.14) (2023-09-14)
|
4
|
+
|
5
|
+
|
6
|
+
### Bug Fixes
|
7
|
+
|
8
|
+
* allowing templates to return nil and skip adding to migrations ([3d90829](https://github.com/craigulliott/dynamic_migrations/commit/3d9082960403899b4243fde60629d9c83ce1e263))
|
9
|
+
|
3
10
|
## [3.6.13](https://github.com/craigulliott/dynamic_migrations/compare/v3.6.12...v3.6.13) (2023-09-14)
|
4
11
|
|
5
12
|
|
@@ -33,13 +33,18 @@ module DynamicMigrations
|
|
33
33
|
|
34
34
|
arguments = template_class.new(trigger, code_comment).fragment_arguments
|
35
35
|
|
36
|
-
#
|
37
|
-
#
|
38
|
-
#
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
36
|
+
# if the template class returns nil, then we skip the creation of this migration
|
37
|
+
# this is common for triggers where the template is respinsible for setting up
|
38
|
+
# multiple triggers (a mix of on update/insert and before/after etc.)
|
39
|
+
unless arguments.nil?
|
40
|
+
# we only provide a dependent function if the function has more than one trigger
|
41
|
+
# or is in a different schema, otherwise it is added to the same migration as this
|
42
|
+
# trigger and we don't need to worry about dependencies
|
43
|
+
if trigger.function && (trigger.function.triggers.count > 1 || trigger.table.schema != trigger.function.schema)
|
44
|
+
add_fragment(dependent_function: trigger.function, **arguments)
|
45
|
+
else
|
46
|
+
add_fragment(**arguments)
|
47
|
+
end
|
43
48
|
end
|
44
49
|
|
45
50
|
# no template, process this as a default trigger (takes all options)
|
@@ -124,8 +129,9 @@ module DynamicMigrations
|
|
124
129
|
end
|
125
130
|
|
126
131
|
def recreate_trigger original_trigger, updated_trigger
|
132
|
+
fragments = []
|
127
133
|
# remove the original trigger
|
128
|
-
|
134
|
+
fragments << remove_trigger(original_trigger, <<~CODE_COMMENT)
|
129
135
|
Removing original trigger because it has changed (it is recreated below)
|
130
136
|
Changes:
|
131
137
|
#{indent original_trigger.differences_descriptions(updated_trigger).join("\n")}
|
@@ -135,9 +141,10 @@ module DynamicMigrations
|
|
135
141
|
recreation_fragment = add_trigger updated_trigger, <<~CODE_COMMENT
|
136
142
|
Recreating this trigger
|
137
143
|
CODE_COMMENT
|
144
|
+
fragments << recreation_fragment unless recreation_fragment.nil?
|
138
145
|
|
139
146
|
# return the new fragments (the main reason to return them here is for the specs)
|
140
|
-
|
147
|
+
fragments
|
141
148
|
end
|
142
149
|
|
143
150
|
# add a comment to a trigger
|
@@ -9,7 +9,7 @@ module DynamicMigrations
|
|
9
9
|
def self.has_template?: (Symbol template_name) -> bool
|
10
10
|
def self.add_template: (Symbol template_name, singleton(TriggerTemplateBase) template_class) -> void
|
11
11
|
|
12
|
-
def add_trigger: (Server::Database::Schema::Table::Trigger trigger, ?String? code_comment) -> Fragment
|
12
|
+
def add_trigger: (Server::Database::Schema::Table::Trigger trigger, ?String? code_comment) -> Fragment?
|
13
13
|
def remove_trigger: (Server::Database::Schema::Table::Trigger trigger, ?String? code_comment) -> Fragment
|
14
14
|
def recreate_trigger: (Server::Database::Schema::Table::Trigger original_trigger, Server::Database::Schema::Table::Trigger updated_trigger) -> Array[Fragment]
|
15
15
|
def set_trigger_comment: (Postgres::Server::Database::Schema::Table::Trigger trigger, ?String? code_comment) -> Fragment
|