dynamic_migrations 3.6.10 → 3.6.12

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 93b2822411008957140dcf9902d9e769cfaf10ea99e9ac424f5c57effdaff8f4
4
- data.tar.gz: 38e53d341c2f9fd15231f1eea9c670ed1f724d7ce4a6618b587645faafec7356
3
+ metadata.gz: 79b80c950a523a7f70c930e8c86774fa64009ae689f5164de3320dc8d55e4238
4
+ data.tar.gz: 649f3e0f23d676e97b8cf3c8389875ae2127701eb405c7c8947bf19de076b7f2
5
5
  SHA512:
6
- metadata.gz: 1f383da41e391a24896b2ae6264710c891f9ab6a46382f70953cf424ccffcee1644e42123ccbe6cb29391d494bb9058c12c93c81a7cba9f20f20755e8eb43d10
7
- data.tar.gz: b77823cc86a9f235be6ad33d6eb48b382c671ab8a60465435f060de14ad981acdc29767645af87e2128c817d9a0cdd24bc7aca1a9352a6be44289ac2d13688d5
6
+ metadata.gz: 94c1280b7c62a39f8337d1093731625b22049eab02b642f17a9c8d1e7f067ef90cabb1dcabda980acde0eb38639ddbd1d30c9b740d85535d0250295e032b2983
7
+ data.tar.gz: '0478e668cf87739da754981dd2be1acd6a21cdfb3ef41609043c12915a455a04ccf99f31e46b3d0a5630002a59ba6b085f65381a86ed1e4d17eeaa796e70b418'
data/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Changelog
2
2
 
3
+ ## [3.6.12](https://github.com/craigulliott/dynamic_migrations/compare/v3.6.11...v3.6.12) (2023-09-13)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * removing unused argument for create_function migrator ([bdb2ad5](https://github.com/craigulliott/dynamic_migrations/commit/bdb2ad58ff0c5aa3520eb38ab0d16b823014ce6e))
9
+
10
+ ## [3.6.11](https://github.com/craigulliott/dynamic_migrations/compare/v3.6.10...v3.6.11) (2023-09-13)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * injecting dependent_function into templated triggers ([9e770a3](https://github.com/craigulliott/dynamic_migrations/commit/9e770a352b176c7b10471e9185ac01feca538c0c))
16
+ * writing enums to the migration files as arrays of strings for more compatibility with special characters ([1910e0f](https://github.com/craigulliott/dynamic_migrations/commit/1910e0f709e5bd560696c2e2b3bd729c7a61e319))
17
+
3
18
  ## [3.6.10](https://github.com/craigulliott/dynamic_migrations/compare/v3.6.9...v3.6.10) (2023-09-13)
4
19
 
5
20
 
@@ -9,7 +9,7 @@ module DynamicMigrations
9
9
  end
10
10
 
11
11
  # create a postgres function
12
- def create_function table_name, function_name, comment: nil, &block
12
+ def create_function function_name, comment: nil, &block
13
13
  unless block
14
14
  raise MissingFunctionBlockError, "create_function requires a block"
15
15
  end
@@ -30,7 +30,7 @@ module DynamicMigrations
30
30
  end
31
31
 
32
32
  # update a postgres function
33
- def update_function table_name, function_name, comment: nil, &block
33
+ def update_function function_name, comment: nil, &block
34
34
  unless block
35
35
  raise MissingFunctionBlockError, "create_function requires a block"
36
36
  end
@@ -21,7 +21,7 @@ module DynamicMigrations
21
21
  code_comment: code_comment,
22
22
  migration: <<~RUBY
23
23
  create_enum :#{enum.name}, [
24
- :#{enum.values.join(",\n :")}
24
+ "#{enum.values.join("\",\n \"")}"
25
25
  ]
26
26
  RUBY
27
27
  end
@@ -40,7 +40,7 @@ module DynamicMigrations
40
40
  code_comment: code_comment,
41
41
  migration: <<~RUBY
42
42
  add_enum_values :#{updated_enum.name}, [
43
- :#{added_values.join(",\n :")}
43
+ "#{added_values.join("\",\n \"")}"
44
44
  ]
45
45
  RUBY
46
46
  end
@@ -32,7 +32,15 @@ module DynamicMigrations
32
32
  end
33
33
 
34
34
  arguments = template_class.new(trigger, code_comment).fragment_arguments
35
- add_fragment(**arguments)
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)
43
+ end
36
44
 
37
45
  # no template, process this as a default trigger (takes all options)
38
46
  else
@@ -50,7 +50,7 @@ module DynamicMigrations
50
50
  process_schema schema_name, differences[:configuration][:schemas][schema_name], differences[:database][:schemas][schema_name]
51
51
  end
52
52
 
53
- # return the migrations organized by schema
53
+ # return the migrations (they are sorted via a dependency algorithm)
54
54
  @generator.migrations
55
55
  end
56
56
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DynamicMigrations
4
- VERSION = "3.6.10"
4
+ VERSION = "3.6.12"
5
5
  end
@@ -5,8 +5,8 @@ module DynamicMigrations
5
5
  module ActiveRecord
6
6
  module Migrators
7
7
  module Function
8
- def create_function: (Symbol table_name, Symbol function_name, ?comment: String?) -> void
9
- def update_function: (Symbol table_name, Symbol function_name, ?comment: String?) -> void
8
+ def create_function: (Symbol function_name, ?comment: String?) -> void
9
+ def update_function: (Symbol function_name, ?comment: String?) -> void
10
10
  def drop_function: (Symbol function_name) -> void
11
11
  def set_function_comment: (Symbol function_name, String comment) -> void
12
12
  def remove_function_comment: (Symbol function_name) -> void
@@ -12,7 +12,7 @@ module DynamicMigrations
12
12
  def initialize: (untyped validation, untyped code_comment) -> void
13
13
 
14
14
  # abstract method (should actually be added to child classes)
15
- def fragment_arguments: -> {schema: Postgres::Server::Database::Schema, table: Postgres::Server::Database::Schema::Table, migration_method: :add_validation, object: Postgres::Server::Database::Schema::Table::Validation, code_comment: String?, migration: String}
15
+ def fragment_arguments: -> {schema: Postgres::Server::Database::Schema, table: Postgres::Server::Database::Schema::Table, migration_method: Symbol, object: untyped, code_comment: String?, migration: String, dependent_function: Postgres::Server::Database::Schema::Function?}
16
16
 
17
17
  private
18
18
  def assert_not_deferred!: -> nil
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.10
4
+ version: 3.6.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Craig Ulliott