dynamic_migrations 3.6.13 → 3.6.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -0
- data/lib/dynamic_migrations/postgres/generator/foreign_key_constraint.rb +0 -4
- data/lib/dynamic_migrations/postgres/generator/trigger.rb +16 -9
- data/lib/dynamic_migrations/version.rb +1 -1
- data/sig/dynamic_migrations/postgres/generator/trigger.rbs +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b1f731ee879fc2da123605b8cb10c5dee47ff16a065dd043be4ec4424ceba90
|
4
|
+
data.tar.gz: ee8925da339476c44a54440240d4736b443ae671075d6f9791033052ef542da3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 841a16d865fc252e0c7ea85b589d0de86703c1d718ba05fd695852daff12117e6dbbfd7ccb22e7f29659253e8193054dccca635423ccd9ea0dc7875482606cb8
|
7
|
+
data.tar.gz: 16ffa1cffc44cf979247738466a5884db216042f82b945b4936e0f1beca4d04b4544f71b4912e65a1b2e5581d8ffb5c4b2d288a55198eaf6dfdcad04372b10b6
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [3.6.15](https://github.com/craigulliott/dynamic_migrations/compare/v3.6.14...v3.6.15) (2023-09-14)
|
4
|
+
|
5
|
+
|
6
|
+
### Bug Fixes
|
7
|
+
|
8
|
+
* missing colon before foreign schema name in migration generator ([b94ad92](https://github.com/craigulliott/dynamic_migrations/commit/b94ad924c7ead5ad697ea4fb48871ac827ad5c85))
|
9
|
+
|
10
|
+
## [3.6.14](https://github.com/craigulliott/dynamic_migrations/compare/v3.6.13...v3.6.14) (2023-09-14)
|
11
|
+
|
12
|
+
|
13
|
+
### Bug Fixes
|
14
|
+
|
15
|
+
* allowing templates to return nil and skip adding to migrations ([3d90829](https://github.com/craigulliott/dynamic_migrations/commit/3d9082960403899b4243fde60629d9c83ce1e263))
|
16
|
+
|
3
17
|
## [3.6.13](https://github.com/craigulliott/dynamic_migrations/compare/v3.6.12...v3.6.13) (2023-09-14)
|
4
18
|
|
5
19
|
|
@@ -40,10 +40,6 @@ module DynamicMigrations
|
|
40
40
|
RUBY
|
41
41
|
end
|
42
42
|
|
43
|
-
if foreign_key_constraint.table.schema != foreign_key_constraint.foreign_table.schema
|
44
|
-
options[:foreign_schema] = foreign_key_constraint.foreign_table.schema.name.to_s
|
45
|
-
end
|
46
|
-
|
47
43
|
options_syntax = options.map { |k, v| "#{k}: #{v}" }.join(", ")
|
48
44
|
|
49
45
|
add_fragment schema: foreign_key_constraint.table.schema,
|
@@ -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
|