dynamic_migrations 3.5.1 → 3.5.3
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 +4 -4
- data/CHANGELOG.md +14 -0
- data/lib/dynamic_migrations/postgres/server/database/differences/to_migrations/extensions.rb +2 -2
- data/lib/dynamic_migrations/postgres/server/database/differences/to_migrations/schemas/enums.rb +2 -2
- data/lib/dynamic_migrations/postgres/server/database/differences/to_migrations/schemas/functions.rb +2 -2
- data/lib/dynamic_migrations/postgres/server/database/differences/to_migrations/schemas/tables/columns.rb +2 -2
- data/lib/dynamic_migrations/postgres/server/database/differences/to_migrations/schemas/tables/foreign_key_constraints.rb +2 -2
- data/lib/dynamic_migrations/postgres/server/database/differences/to_migrations/schemas/tables/indexes.rb +2 -2
- data/lib/dynamic_migrations/postgres/server/database/differences/to_migrations/schemas/tables/triggers.rb +2 -2
- data/lib/dynamic_migrations/postgres/server/database/differences/to_migrations/schemas/tables/unique_constraints.rb +2 -2
- data/lib/dynamic_migrations/postgres/server/database/differences/to_migrations/schemas/tables/validations.rb +2 -2
- data/lib/dynamic_migrations/postgres/server/database/differences/to_migrations/schemas/tables.rb +2 -2
- data/lib/dynamic_migrations/postgres/server/database/differences/to_migrations/schemas.rb +2 -2
- data/lib/dynamic_migrations/postgres/server/database/loaded_schemas.rb +7 -3
- data/lib/dynamic_migrations/postgres/server/database/schema/table/trigger.rb +2 -1
- data/lib/dynamic_migrations/version.rb +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: 8db557bd15584279e5453bf8e11664fbc5c9cbce80da60feaede298aa2931450
|
4
|
+
data.tar.gz: 52c990e7611103a9bc60daa33d673f7f9d62cf753253419d3a237c44394eeecf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ba74991b8200a6b0725b77e6db992783f994ebebf6c362b92077757f11a0a5bd48cbf1b6a88c324caa23b461011a2248bfeafbb833610f7d82ad9a5e8d74291
|
7
|
+
data.tar.gz: 10ac70b56fe1a6c5ddd429321ee88b8134f3c1d20e9fe5ef70460f75117d73374a2d79893169b12289c755295491e99dc627f8ec851498a387cd6fe3812f0fdc
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [3.5.3](https://github.com/craigulliott/dynamic_migrations/compare/v3.5.2...v3.5.3) (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) ([de63879](https://github.com/craigulliott/dynamic_migrations/commit/de638791035a0a1ad4658149777aa6e2ac7dc2ed))
|
9
|
+
|
10
|
+
## [3.5.2](https://github.com/craigulliott/dynamic_migrations/compare/v3.5.1...v3.5.2) (2023-09-11)
|
11
|
+
|
12
|
+
|
13
|
+
### Bug Fixes
|
14
|
+
|
15
|
+
* 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))
|
16
|
+
|
3
17
|
## [3.5.1](https://github.com/craigulliott/dynamic_migrations/compare/v3.5.0...v3.5.1) (2023-09-11)
|
4
18
|
|
5
19
|
|
data/lib/dynamic_migrations/postgres/server/database/differences/to_migrations/extensions.rb
CHANGED
@@ -10,13 +10,13 @@ module DynamicMigrations
|
|
10
10
|
def process_extension extension_name, configuration_extension, database_extension
|
11
11
|
# if the extension exists in the configuration but not in the database
|
12
12
|
# then we have to create it
|
13
|
-
if configuration_extension[:exists] == true && database_extension[:exists]
|
13
|
+
if configuration_extension[:exists] == true && !database_extension[:exists]
|
14
14
|
# a migration to create the extension
|
15
15
|
@generator.create_extension extension_name
|
16
16
|
|
17
17
|
# if the extension exists in the database but not in the configuration
|
18
18
|
# then we need to delete it
|
19
|
-
elsif
|
19
|
+
elsif database_extension[:exists] == true && !configuration_extension[:exists]
|
20
20
|
# a migration to drop the extension
|
21
21
|
@generator.drop_extension extension_name
|
22
22
|
end
|
data/lib/dynamic_migrations/postgres/server/database/differences/to_migrations/schemas/enums.rb
CHANGED
@@ -19,7 +19,7 @@ module DynamicMigrations
|
|
19
19
|
def process_enum schema_name, enum_name, configuration_enum, database_enum
|
20
20
|
# If the enum exists in the configuration but not in the database
|
21
21
|
# then we have to create it.
|
22
|
-
if configuration_enum[:exists] == true && database_enum[:exists]
|
22
|
+
if configuration_enum[:exists] == true && !database_enum[:exists]
|
23
23
|
# a migration to create the enum
|
24
24
|
enum = @database.configured_schema(schema_name).enum(enum_name)
|
25
25
|
@generator.create_enum enum
|
@@ -30,7 +30,7 @@ module DynamicMigrations
|
|
30
30
|
|
31
31
|
# If the schema exists in the database but not in the configuration
|
32
32
|
# then we need to delete it.
|
33
|
-
elsif
|
33
|
+
elsif database_enum[:exists] == true && !configuration_enum[:exists]
|
34
34
|
# a migration to create the enum
|
35
35
|
enum = @database.loaded_schema(schema_name).enum(enum_name)
|
36
36
|
@generator.drop_enum enum
|
data/lib/dynamic_migrations/postgres/server/database/differences/to_migrations/schemas/functions.rb
CHANGED
@@ -19,14 +19,14 @@ module DynamicMigrations
|
|
19
19
|
def process_function schema_name, function_name, configuration_function, database_function
|
20
20
|
# If the function exists in the configuration but not in the database
|
21
21
|
# then we have to create it.
|
22
|
-
if configuration_function[:exists] == true && database_function[:exists]
|
22
|
+
if configuration_function[:exists] == true && !database_function[:exists]
|
23
23
|
# a migration to create the function
|
24
24
|
function = @database.configured_schema(schema_name).function(function_name)
|
25
25
|
@generator.create_function function
|
26
26
|
|
27
27
|
# If the schema exists in the database but not in the configuration
|
28
28
|
# then we need to delete it.
|
29
|
-
elsif
|
29
|
+
elsif database_function[:exists] == true && !configuration_function[:exists]
|
30
30
|
# a migration to create the function
|
31
31
|
function = @database.loaded_schema(schema_name).function(function_name)
|
32
32
|
@generator.drop_function function
|
@@ -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]
|
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
|
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]
|
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
|
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]
|
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
|
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]
|
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
|
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]
|
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
|
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]
|
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
|
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
|
data/lib/dynamic_migrations/postgres/server/database/differences/to_migrations/schemas/tables.rb
CHANGED
@@ -19,7 +19,7 @@ module DynamicMigrations
|
|
19
19
|
def process_table schema_name, table_name, configuration_table, database_table
|
20
20
|
# If the table exists in the configuration but not in the database
|
21
21
|
# then we have to create it.
|
22
|
-
if configuration_table[:exists] == true && database_table[:exists]
|
22
|
+
if configuration_table[:exists] == true && !database_table[:exists]
|
23
23
|
# a migration to create the table
|
24
24
|
table = @database.configured_schema(schema_name).table(table_name)
|
25
25
|
@generator.create_table table
|
@@ -30,7 +30,7 @@ module DynamicMigrations
|
|
30
30
|
|
31
31
|
# If the schema exists in the database but not in the configuration
|
32
32
|
# then we need to delete it.
|
33
|
-
elsif
|
33
|
+
elsif database_table[:exists] == true && !configuration_table[:exists]
|
34
34
|
# we process everything else before we drop the table, because the other
|
35
35
|
# database objects are dependent on the table
|
36
36
|
process_dependents schema_name, table_name, {}, database_table
|
@@ -10,7 +10,7 @@ module DynamicMigrations
|
|
10
10
|
def process_schema schema_name, configuration_schema, database_schema
|
11
11
|
# if the schema exists in the configuration but not in the database
|
12
12
|
# then we have to create it
|
13
|
-
if configuration_schema[:exists] == true && database_schema[:exists]
|
13
|
+
if configuration_schema[:exists] == true && !database_schema[:exists]
|
14
14
|
# a migration to create the schema
|
15
15
|
schema = @database.configured_schema schema_name
|
16
16
|
@generator.create_schema schema
|
@@ -23,7 +23,7 @@ module DynamicMigrations
|
|
23
23
|
|
24
24
|
# if the schema exists in the database but not in the configuration
|
25
25
|
# then we need to delete it
|
26
|
-
elsif
|
26
|
+
elsif database_schema[:exists] == true && !configuration_schema[:exists]
|
27
27
|
# we process the tables and functions before we drop the schema
|
28
28
|
# as this will drop any dependencies on the schema
|
29
29
|
process_functions schema_name, {}, database_schema[:functions]
|
@@ -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
|
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
|
-
|
40
|
-
|
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
|
-
|
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
|