dynamic_migrations 3.5.0 → 3.5.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (20) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +14 -0
  3. data/lib/dynamic_migrations/postgres/generator/column.rb +1 -1
  4. data/lib/dynamic_migrations/postgres/generator/foreign_key_constraint.rb +1 -1
  5. data/lib/dynamic_migrations/postgres/generator/index.rb +1 -1
  6. data/lib/dynamic_migrations/postgres/generator/table.rb +1 -1
  7. data/lib/dynamic_migrations/postgres/generator/trigger.rb +1 -1
  8. data/lib/dynamic_migrations/postgres/generator/unique_constraint.rb +1 -1
  9. data/lib/dynamic_migrations/postgres/generator/validation.rb +1 -1
  10. data/lib/dynamic_migrations/postgres/server/database/differences/to_migrations/schemas/tables/columns.rb +2 -2
  11. data/lib/dynamic_migrations/postgres/server/database/differences/to_migrations/schemas/tables/foreign_key_constraints.rb +2 -2
  12. data/lib/dynamic_migrations/postgres/server/database/differences/to_migrations/schemas/tables/indexes.rb +2 -2
  13. data/lib/dynamic_migrations/postgres/server/database/differences/to_migrations/schemas/tables/triggers.rb +2 -2
  14. data/lib/dynamic_migrations/postgres/server/database/differences/to_migrations/schemas/tables/unique_constraints.rb +2 -2
  15. data/lib/dynamic_migrations/postgres/server/database/differences/to_migrations/schemas/tables/validations.rb +2 -2
  16. data/lib/dynamic_migrations/postgres/server/database/differences.rb +1 -1
  17. data/lib/dynamic_migrations/postgres/server/database/loaded_schemas.rb +7 -3
  18. data/lib/dynamic_migrations/postgres/server/database/schema/table/trigger.rb +2 -1
  19. data/lib/dynamic_migrations/version.rb +1 -1
  20. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c2370c3373cb04ce64f20e48f15adf1f68cbacf17de79ca420f39f67c13536aa
4
- data.tar.gz: 0d8d19007406180972f5a6304c01c0277079920bb8190705f2a246ef0975167a
3
+ metadata.gz: d618a9b98ed9b0f378f6e4342c57e6df554df34c600572a6aa55db61dbb32fad
4
+ data.tar.gz: a90d7e5fa28aa0f4dbc2d42a7545ed6207bc800baba766dd23c9bc0e73cfd0c6
5
5
  SHA512:
6
- metadata.gz: de27b281b3e4494cfa5b3cc3835da3e71816c4a3b3e75bc92d96e2b69ae7e6169d9b32ebadc53c0f5e25d44378e81f46b26cc9db8cfb9c7bf97d009e4fc3eb3d
7
- data.tar.gz: 79e609f4d4ce4272a8f82e4d11771faa05c9c380228e2587a96abb751fd9647d55f65f91e730ec0487ddc349cc6922f2e079782bcd355c17335a8f8d4c68caa7
6
+ metadata.gz: 33c0b803f4a4a01aff67b258ade285c2acf0420c0c611b918cf24405f5081497050bdcb726532b01fe4d832a086d15a4b37dc5a03c445772e7b6e863edd795c6
7
+ data.tar.gz: 7a00457cdb78107f62c43bd74647513817c1fbb0e4dbbc92bdc458aefc02030980fd074d03f2ada4399dd442f4152098024a492839fe98ccba2ad16ad4508356
data/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [3.5.2](https://github.com/craigulliott/dynamic_migrations/compare/v3.5.1...v3.5.2) (2023-09-11)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * accepting nil or false for existence check when calculating differences (because if the schema doesn't exist we wont have table objects to test against) ([c4112cc](https://github.com/craigulliott/dynamic_migrations/commit/c4112cccb5a887b78e15182cdb8bcfdbd80fd0c0))
9
+
10
+ ## [3.5.1](https://github.com/craigulliott/dynamic_migrations/compare/v3.5.0...v3.5.1) (2023-09-11)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * missing primary key should be represented by nil when building differences, and added some more descriptive error messages ([491c1c2](https://github.com/craigulliott/dynamic_migrations/commit/491c1c2d7c2128f3f4ad3f2a21b0b52c67029185))
16
+
3
17
  ## [3.5.0](https://github.com/craigulliott/dynamic_migrations/compare/v3.4.1...v3.5.0) (2023-09-11)
4
18
 
5
19
 
@@ -92,7 +92,7 @@ module DynamicMigrations
92
92
  description = column.description
93
93
 
94
94
  if description.nil?
95
- raise MissingDescriptionError
95
+ raise MissingDescriptionError, "Missing required description for column `#{column.name}` in table `#{column.table.schema.name}.#{column.table.name}`"
96
96
  end
97
97
 
98
98
  add_fragment schema: column.table.schema,
@@ -73,7 +73,7 @@ module DynamicMigrations
73
73
  description = foreign_key_constraint.description
74
74
 
75
75
  if description.nil?
76
- raise MissingDescriptionError
76
+ raise MissingDescriptionError, "Missing required description for foreign_key_constraint `#{foreign_key_constraint.name}` in table `#{foreign_key_constraint.table.schema.name}.#{foreign_key_constraint.table.name}`"
77
77
  end
78
78
 
79
79
  add_fragment schema: foreign_key_constraint.table.schema,
@@ -89,7 +89,7 @@ module DynamicMigrations
89
89
  description = index.description
90
90
 
91
91
  if description.nil?
92
- raise MissingDescriptionError
92
+ raise MissingDescriptionError, "Missing required description for index `#{index.name}` in table `#{index.table.schema.name}.#{index.table.name}`"
93
93
  end
94
94
 
95
95
  add_fragment schema: index.table.schema,
@@ -44,7 +44,7 @@ module DynamicMigrations
44
44
  description = table.description
45
45
 
46
46
  if description.nil?
47
- raise MissingDescriptionError
47
+ raise MissingDescriptionError, "Missing required description for table `#{table.schema.name}.#{table.name}`"
48
48
  end
49
49
 
50
50
  add_fragment schema: table.schema,
@@ -93,7 +93,7 @@ module DynamicMigrations
93
93
  description = trigger.description
94
94
 
95
95
  if description.nil?
96
- raise MissingDescriptionError
96
+ raise MissingDescriptionError, "Missing required description for trigger `#{trigger.name}` on table `#{trigger.table.schema.name}.#{trigger.table.name}`"
97
97
  end
98
98
 
99
99
  add_fragment schema: trigger.table.schema,
@@ -67,7 +67,7 @@ module DynamicMigrations
67
67
  description = unique_constraint.description
68
68
 
69
69
  if description.nil?
70
- raise MissingDescriptionError
70
+ raise MissingDescriptionError, "Missing required description for unique_constraint `#{unique_constraint.name}` in table `#{unique_constraint.table.schema.name}.#{unique_constraint.table.name}`"
71
71
  end
72
72
 
73
73
  add_fragment schema: unique_constraint.table.schema,
@@ -75,7 +75,7 @@ module DynamicMigrations
75
75
  description = validation.description
76
76
 
77
77
  if description.nil?
78
- raise MissingDescriptionError
78
+ raise MissingDescriptionError, "Missing required description for validation `#{validation.name}` in table `#{validation.table.schema.name}.#{validation.table.name}`"
79
79
  end
80
80
 
81
81
  add_fragment schema: validation.table.schema,
@@ -20,14 +20,14 @@ module DynamicMigrations
20
20
  def process_column schema_name, table_name, column_name, configuration_column, database_column
21
21
  # If the column exists in the configuration but not in the database
22
22
  # then we have to create it.
23
- if configuration_column[:exists] == true && database_column[:exists] == false
23
+ if configuration_column[:exists] == true && !database_column[:exists]
24
24
  # a migration to create the column
25
25
  column = @database.configured_schema(schema_name).table(table_name).column(column_name)
26
26
  @generator.add_column column
27
27
 
28
28
  # If the schema exists in the database but not in the configuration
29
29
  # then we need to delete it.
30
- elsif configuration_column[:exists] == false && database_column[:exists] == true
30
+ elsif database_column[:exists] == true && !configuration_column[:exists]
31
31
  # a migration to create the column
32
32
  column = @database.loaded_schema(schema_name).table(table_name).column(column_name)
33
33
  @generator.remove_column column
@@ -20,14 +20,14 @@ module DynamicMigrations
20
20
  def process_foreign_key_constraint schema_name, table_name, foreign_key_constraint_name, configuration_foreign_key_constraint, database_foreign_key_constraint
21
21
  # If the foreign_key_constraint exists in the configuration but not in the database
22
22
  # then we have to create it.
23
- if configuration_foreign_key_constraint[:exists] == true && database_foreign_key_constraint[:exists] == false
23
+ if configuration_foreign_key_constraint[:exists] == true && !database_foreign_key_constraint[:exists]
24
24
  # a migration to create the foreign_key_constraint
25
25
  foreign_key_constraint = @database.configured_schema(schema_name).table(table_name).foreign_key_constraint(foreign_key_constraint_name)
26
26
  @generator.add_foreign_key_constraint foreign_key_constraint
27
27
 
28
28
  # If the schema exists in the database but not in the configuration
29
29
  # then we need to delete it.
30
- elsif configuration_foreign_key_constraint[:exists] == false && database_foreign_key_constraint[:exists] == true
30
+ elsif database_foreign_key_constraint[:exists] == true && !configuration_foreign_key_constraint[:exists]
31
31
  # a migration to create the foreign_key_constraint
32
32
  foreign_key_constraint = @database.loaded_schema(schema_name).table(table_name).foreign_key_constraint(foreign_key_constraint_name)
33
33
  @generator.remove_foreign_key_constraint foreign_key_constraint
@@ -20,14 +20,14 @@ module DynamicMigrations
20
20
  def process_index schema_name, table_name, index_name, configuration_index, database_index
21
21
  # If the index exists in the configuration but not in the database
22
22
  # then we have to create it.
23
- if configuration_index[:exists] == true && database_index[:exists] == false
23
+ if configuration_index[:exists] == true && !database_index[:exists]
24
24
  # a migration to create the index
25
25
  index = @database.configured_schema(schema_name).table(table_name).index(index_name)
26
26
  @generator.add_index index
27
27
 
28
28
  # If the schema exists in the database but not in the configuration
29
29
  # then we need to delete it.
30
- elsif configuration_index[:exists] == false && database_index[:exists] == true
30
+ elsif database_index[:exists] == true && !configuration_index[:exists]
31
31
  # a migration to create the index
32
32
  index = @database.loaded_schema(schema_name).table(table_name).index(index_name)
33
33
  @generator.remove_index index
@@ -20,14 +20,14 @@ module DynamicMigrations
20
20
  def process_trigger schema_name, table_name, trigger_name, configuration_trigger, database_trigger
21
21
  # If the trigger exists in the configuration but not in the database
22
22
  # then we have to create it.
23
- if configuration_trigger[:exists] == true && database_trigger[:exists] == false
23
+ if configuration_trigger[:exists] == true && !database_trigger[:exists]
24
24
  # a migration to create the trigger
25
25
  trigger = @database.configured_schema(schema_name).table(table_name).trigger(trigger_name)
26
26
  @generator.add_trigger trigger
27
27
 
28
28
  # If the schema exists in the database but not in the configuration
29
29
  # then we need to delete it.
30
- elsif configuration_trigger[:exists] == false && database_trigger[:exists] == true
30
+ elsif database_trigger[:exists] == true && !configuration_trigger[:exists]
31
31
  # a migration to create the trigger
32
32
  trigger = @database.loaded_schema(schema_name).table(table_name).trigger(trigger_name)
33
33
  @generator.remove_trigger trigger
@@ -20,14 +20,14 @@ module DynamicMigrations
20
20
  def process_unique_constraint schema_name, table_name, unique_constraint_name, configuration_unique_constraint, database_unique_constraint
21
21
  # If the unique_constraint exists in the configuration but not in the database
22
22
  # then we have to create it.
23
- if configuration_unique_constraint[:exists] == true && database_unique_constraint[:exists] == false
23
+ if configuration_unique_constraint[:exists] == true && !database_unique_constraint[:exists]
24
24
  # a migration to create the unique_constraint
25
25
  unique_constraint = @database.configured_schema(schema_name).table(table_name).unique_constraint(unique_constraint_name)
26
26
  @generator.add_unique_constraint unique_constraint
27
27
 
28
28
  # If the schema exists in the database but not in the configuration
29
29
  # then we need to delete it.
30
- elsif configuration_unique_constraint[:exists] == false && database_unique_constraint[:exists] == true
30
+ elsif database_unique_constraint[:exists] == true && !configuration_unique_constraint[:exists]
31
31
  # a migration to create the unique_constraint
32
32
  unique_constraint = @database.loaded_schema(schema_name).table(table_name).unique_constraint(unique_constraint_name)
33
33
  @generator.remove_unique_constraint unique_constraint
@@ -20,14 +20,14 @@ module DynamicMigrations
20
20
  def process_validation schema_name, table_name, validation_name, configuration_validation, database_validation
21
21
  # If the validation exists in the configuration but not in the database
22
22
  # then we have to create it.
23
- if configuration_validation[:exists] == true && database_validation[:exists] == false
23
+ if configuration_validation[:exists] == true && !database_validation[:exists]
24
24
  # a migration to create the validation
25
25
  validation = @database.configured_schema(schema_name).table(table_name).validation(validation_name)
26
26
  @generator.add_validation validation
27
27
 
28
28
  # If the schema exists in the database but not in the configuration
29
29
  # then we need to delete it.
30
- elsif configuration_validation[:exists] == false && database_validation[:exists] == true
30
+ elsif database_validation[:exists] == true && !configuration_validation[:exists]
31
31
  # a migration to create the validation
32
32
  validation = @database.loaded_schema(schema_name).table(table_name).validation(validation_name)
33
33
  @generator.remove_validation validation
@@ -136,7 +136,7 @@ module DynamicMigrations
136
136
  comparison_foreign_key_constraints = comparison_table.foreign_key_constraints_hash
137
137
  comparison_unique_constraints = comparison_table.unique_constraints_hash
138
138
  else
139
- comparison_primary_key = {}
139
+ comparison_primary_key = nil
140
140
  comparison_columns = {}
141
141
  comparison_indexes = {}
142
142
  comparison_triggers = {}
@@ -15,7 +15,7 @@ module DynamicMigrations
15
15
  def add_loaded_schema schema_name
16
16
  raise ExpectedSymbolError, schema_name unless schema_name.is_a? Symbol
17
17
  if has_loaded_schema? schema_name
18
- raise(LoadedSchemaAlreadyExistsError, "Loaded schema #{schema_name} already exists")
18
+ raise LoadedSchemaAlreadyExistsError, "Loaded schema #{schema_name} already exists"
19
19
  end
20
20
  included_target = self
21
21
  if included_target.is_a? Database
@@ -36,8 +36,12 @@ module DynamicMigrations
36
36
  # returns the loaded schema object for the provided schema name, and raises an
37
37
  # error if the schema does not exist
38
38
  def loaded_schema schema_name
39
- raise ExpectedSymbolError, schema_name unless schema_name.is_a? Symbol
40
- raise LoadedSchemaDoesNotExistError unless has_loaded_schema? schema_name
39
+ unless schema_name.is_a? Symbol
40
+ raise ExpectedSymbolError, schema_name
41
+ end
42
+ unless has_loaded_schema? schema_name
43
+ raise LoadedSchemaDoesNotExistError, "Loaded schema `#{schema_name}` does not exist"
44
+ end
41
45
  @loaded_schemas[schema_name]
42
46
  end
43
47
 
@@ -88,7 +88,8 @@ module DynamicMigrations
88
88
  end
89
89
  @action_condition = action_condition&.strip
90
90
 
91
- unless parameters.nil? || (parameters.is_a?(String) && parameters[/\A'[\w\d_ -]+'(, ?'[\w\d_ -]+')*\z/])
91
+ is_comma_sperated_list_of_strings = (parameters.is_a?(String) && parameters[/\A'[\w\d_ -]+'(, ?'[\w\d_ -]+')*\z/])
92
+ unless parameters.nil? || is_comma_sperated_list_of_strings
92
93
  raise UnexpectedParametersError, "unexpected parameters `#{parameters}`, currently only a comma seeparated list of strings is supported"
93
94
  end
94
95
  @parameters = parameters&.strip
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DynamicMigrations
4
- VERSION = "3.5.0"
4
+ VERSION = "3.5.2"
5
5
  end
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.5.0
4
+ version: 3.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Craig Ulliott