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: 9ecc60f6bad6a321991985b6e7cfd024486ec79caa1b49b143caf3c844d28275
4
- data.tar.gz: b16c5bb261de851a877d4b6e6067b2767badf82f895ce25e0816286d11ef83e8
3
+ metadata.gz: 2a53664f8e85f6f7570b65b756687db445a71c5e48cdc7f52ab4a394570e9be5
4
+ data.tar.gz: 49cad85aaff8c311714a5e9c47c16708e8f6c3d7b6f276ce94d5b0dc8703eae6
5
5
  SHA512:
6
- metadata.gz: 182c7cbc69b0ba406147e7e0d972887ec44d8171e00eb75b92a531702cd4abfaf18ab9c7e319ac7771f25696968582b56cf18fe275652f71f2426d1a1b6e363a
7
- data.tar.gz: b0f0de5ca2c65380c25c80fe23c53942a576e4f4c9e7e3984d56dbf67d9afac6e2b16153f1d70012b7f0fb1dfd50b1b13e2cdebcf1c0333ea2cd86f90ded33df
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
- # we only provide a dependent function if the function has more than one trigger
37
- # or is in a different schema, otherwise it is added to the same migration as this
38
- # trigger and we don't need to worry about dependencies
39
- if trigger.function && (trigger.function.triggers.count > 1 || trigger.table.schema != trigger.function.schema)
40
- add_fragment(dependent_function: trigger.function, **arguments)
41
- else
42
- add_fragment(**arguments)
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
- removal_fragment = remove_trigger original_trigger, <<~CODE_COMMENT
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
- [removal_fragment, recreation_fragment]
147
+ fragments
141
148
  end
142
149
 
143
150
  # add a comment to a trigger
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DynamicMigrations
4
- VERSION = "3.6.13"
4
+ VERSION = "3.6.14"
5
5
  end
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynamic_migrations
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.6.13
4
+ version: 3.6.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Craig Ulliott