dynamic_migrations 1.0.0 → 1.1.0

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: d0a6f800da284a67951749b309cfd74aff4a769ce0c60bfc6798b07dd0108f5d
4
- data.tar.gz: 5e07832f150f6362aaf982bcd701739747347d48d5d63176bd7c4f00e43b38a2
3
+ metadata.gz: ccf1d1bb6e3e6cd8ee50486a73c36113b6e3d1827d65cd3372100e2da7fc0fe7
4
+ data.tar.gz: 1d5d496a2f8bc9632b2511eb90e52ed1be6018be25f7609f2119413ba18cfac9
5
5
  SHA512:
6
- metadata.gz: 192e7713b23050b8087218e741dc5204141bdee1783015c2d100a4a8935584ba365fb9e34200c359128763ed619f93fa4289ba01f7f33c79c463745fef64f70a
7
- data.tar.gz: 4c02f5f6ec71c1d0795ad0f57d899a8bdd311809055e390959e80d9fc75ee98adf59ea5bcb7c44a60b460367ed9bb1a2f2642d1e70fc4d3d6a3ed30e05d7e929
6
+ metadata.gz: 05a7df93bf0b8a2f555a6e485fff7b9322f78c83e4b729fc1caf2103f409301330ab3eafd1e7e7675b6675a2ea5e9bde123ae3bd05b7e05a3169b72f1351a40b
7
+ data.tar.gz: 5ef389f80d979b915f999883677d36228bb1d8ee37604e2e08b07eceec12af21bb808c085a05c83bcb42169405ef5fd1e98d3083b9462e16da29611cdf459a4c
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.1.0](https://github.com/craigulliott/dynamic_migrations/compare/v1.0.0...v1.1.0) (2023-07-10)
4
+
5
+
6
+ ### Features
7
+
8
+ * storing and returning database structure objects in alphabetical order of their names ([1b3255b](https://github.com/craigulliott/dynamic_migrations/commit/1b3255b220349bfb63d7f72d990557a104131cf7))
9
+
3
10
  ## 1.0.0 (2023-07-05)
4
11
 
5
12
 
data/README.md CHANGED
@@ -33,7 +33,7 @@ Note, this gem depends on the postgres gem `pg`, which depends on the `libpq` pa
33
33
  # required for pg gem on apple silicon
34
34
  brew install libpq
35
35
  export PATH="/opt/homebrew/opt/libpq/bin:$PATH"
36
- ``
36
+ ```
37
37
 
38
38
  ## Getting Started
39
39
 
@@ -19,10 +19,18 @@ module DynamicMigrations
19
19
  end
20
20
  included_target = self
21
21
  if included_target.is_a? Database
22
- @configured_schemas[schema_name] = Schema.new :configuration, included_target, schema_name
22
+ new_schema = @configured_schemas[schema_name] = Schema.new :configuration, included_target, schema_name
23
23
  else
24
24
  raise ModuleIncludedIntoUnexpectedTargetError, included_target
25
25
  end
26
+ # sort the hash so that the schemas are in alphabetical order by name
27
+ sorted_schemas = {}
28
+ @configured_schemas.keys.sort.each do |schema_name|
29
+ sorted_schemas[schema_name] = @configured_schemas[schema_name]
30
+ end
31
+ @configured_schemas = sorted_schemas
32
+ # return the new schema
33
+ new_schema
26
34
  end
27
35
 
28
36
  # returns the configured schema object for the provided schema name, and raises an
@@ -19,10 +19,18 @@ module DynamicMigrations
19
19
  end
20
20
  included_target = self
21
21
  if included_target.is_a? Database
22
- @loaded_schemas[schema_name] = Schema.new :database, included_target, schema_name
22
+ new_schema = @loaded_schemas[schema_name] = Schema.new :database, included_target, schema_name
23
23
  else
24
24
  raise ModuleIncludedIntoUnexpectedTargetError, included_target
25
25
  end
26
+ # sort the hash so that the schemas are in alphabetical order by name
27
+ sorted_schemas = {}
28
+ @loaded_schemas.keys.sort.each do |schema_name|
29
+ sorted_schemas[schema_name] = @loaded_schemas[schema_name]
30
+ end
31
+ @loaded_schemas = sorted_schemas
32
+ # return the new schema
33
+ new_schema
26
34
  end
27
35
 
28
36
  # returns the loaded schema object for the provided schema name, and raises an
@@ -44,10 +44,18 @@ module DynamicMigrations
44
44
  end
45
45
  included_target = self
46
46
  if included_target.is_a? Table
47
- @columns[column_name] = Column.new source, included_target, column_name, data_type, **column_options
47
+ new_column = @columns[column_name] = Column.new source, included_target, column_name, data_type, **column_options
48
48
  else
49
49
  raise ModuleIncludedIntoUnexpectedTargetError, included_target
50
50
  end
51
+ # sort the hash so that the columns are in alphabetical order by name
52
+ sorted_columns = {}
53
+ @columns.keys.sort.each do |column_name|
54
+ sorted_columns[column_name] = @columns[column_name]
55
+ end
56
+ @columns = sorted_columns
57
+ # return the new column
58
+ new_column
51
59
  end
52
60
  end
53
61
  end
@@ -48,10 +48,18 @@ module DynamicMigrations
48
48
  foreign_columns = foreign_column_names.map { |column_name| foreign_table.column column_name }
49
49
  included_target = self
50
50
  if included_target.is_a? Table
51
- @foreign_key_constraints[foreign_key_constraint_name] = ForeignKeyConstraint.new source, included_target, columns, foreign_table, foreign_columns, foreign_key_constraint_name, **foreign_key_constraint_options
51
+ new_foreign_key_constraint = @foreign_key_constraints[foreign_key_constraint_name] = ForeignKeyConstraint.new source, included_target, columns, foreign_table, foreign_columns, foreign_key_constraint_name, **foreign_key_constraint_options
52
52
  else
53
53
  raise ModuleIncludedIntoUnexpectedTargetError, included_target
54
54
  end
55
+ # sort the hash so that the foreign_key_constraints are in alphabetical order by name
56
+ sorted_foreign_key_constraints = {}
57
+ @foreign_key_constraints.keys.sort.each do |foreign_key_constraint_name|
58
+ sorted_foreign_key_constraints[foreign_key_constraint_name] = @foreign_key_constraints[foreign_key_constraint_name]
59
+ end
60
+ @foreign_key_constraints = sorted_foreign_key_constraints
61
+ # return the new foreign_key_constraint
62
+ new_foreign_key_constraint
55
63
  end
56
64
  end
57
65
  end
@@ -49,10 +49,18 @@ module DynamicMigrations
49
49
  include_columns = include_column_names.map { |column_name| column column_name }
50
50
  included_target = self
51
51
  if included_target.is_a? Table
52
- @indexes[index_name] = Index.new source, included_target, columns, index_name, include_columns: include_columns, **index_options
52
+ new_index = @indexes[index_name] = Index.new source, included_target, columns, index_name, include_columns: include_columns, **index_options
53
53
  else
54
54
  raise ModuleIncludedIntoUnexpectedTargetError, included_target
55
55
  end
56
+ # sort the hash so that the indexes are in alphabetical order by name
57
+ sorted_indexes = {}
58
+ @indexes.keys.sort.each do |index_name|
59
+ sorted_indexes[index_name] = @indexes[index_name]
60
+ end
61
+ @indexes = sorted_indexes
62
+ # return the new index
63
+ new_index
56
64
  end
57
65
  end
58
66
  end
@@ -45,10 +45,18 @@ module DynamicMigrations
45
45
  columns = column_names.map { |column_name| column column_name }
46
46
  included_target = self
47
47
  if included_target.is_a? Table
48
- @unique_constraints[unique_constraint_name] = UniqueConstraint.new source, included_target, columns, unique_constraint_name, **unique_constraint_options
48
+ new_unique_constraint = @unique_constraints[unique_constraint_name] = UniqueConstraint.new source, included_target, columns, unique_constraint_name, **unique_constraint_options
49
49
  else
50
50
  raise ModuleIncludedIntoUnexpectedTargetError, included_target
51
51
  end
52
+ # sort the hash so that the unique_constraints are in alphabetical order by name
53
+ sorted_unique_constraints = {}
54
+ @unique_constraints.keys.sort.each do |unique_constraint_name|
55
+ sorted_unique_constraints[unique_constraint_name] = @unique_constraints[unique_constraint_name]
56
+ end
57
+ @unique_constraints = sorted_unique_constraints
58
+ # return the new unique_constraint
59
+ new_unique_constraint
52
60
  end
53
61
  end
54
62
  end
@@ -45,10 +45,18 @@ module DynamicMigrations
45
45
  columns = column_names.map { |column_name| column column_name }
46
46
  included_target = self
47
47
  if included_target.is_a? Table
48
- @validations[validation_name] = Validation.new source, included_target, columns, validation_name, check_clause, **validation_options
48
+ new_validation = @validations[validation_name] = Validation.new source, included_target, columns, validation_name, check_clause, **validation_options
49
49
  else
50
50
  raise ModuleIncludedIntoUnexpectedTargetError, included_target
51
51
  end
52
+ # sort the hash so that the validations are in alphabetical order by name
53
+ sorted_validations = {}
54
+ @validations.keys.sort.each do |validation_name|
55
+ sorted_validations[validation_name] = @validations[validation_name]
56
+ end
57
+ @validations = sorted_validations
58
+ # return the new validation
59
+ new_validation
52
60
  end
53
61
  end
54
62
  end
@@ -38,10 +38,18 @@ module DynamicMigrations
38
38
  end
39
39
  included_target = self
40
40
  if included_target.is_a? Schema
41
- @tables[table_name] = Table.new source, included_target, table_name, description
41
+ new_table = @tables[table_name] = Table.new source, included_target, table_name, description
42
42
  else
43
43
  raise ModuleIncludedIntoUnexpectedTargetError, included_target
44
44
  end
45
+ # sort the hash so that the tables are in alphabetical order by name
46
+ sorted_tables = {}
47
+ @tables.keys.sort.each do |table_name|
48
+ sorted_tables[table_name] = @tables[table_name]
49
+ end
50
+ @tables = sorted_tables
51
+ # return the new table
52
+ new_table
45
53
  end
46
54
 
47
55
  # return a table by its name, raises an error if the table does not exist
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DynamicMigrations
4
- VERSION = "1.0.0"
4
+ VERSION = "1.1.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynamic_migrations
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Craig Ulliott
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-05 00:00:00.000000000 Z
11
+ date: 2023-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0.2'
41
+ - !ruby/object:Gem::Dependency
42
+ name: pg_spec_helper
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.0'
41
55
  description: Monitor and generate database migrations based on difference between
42
56
  current schema and configuration
43
57
  email:
@@ -85,13 +99,13 @@ files:
85
99
  - lib/dynamic_migrations/postgres/server/database/structure_loader.rb
86
100
  - lib/dynamic_migrations/postgres/server/database/validations_loader.rb
87
101
  - lib/dynamic_migrations/version.rb
88
- homepage:
102
+ homepage:
89
103
  licenses:
90
104
  - MIT
91
105
  metadata:
92
106
  source_code_uri: https://github.com/craigulliott/dynamic_migrations/
93
107
  changelog_uri: https://github.com/craigulliott/dynamic_migrations/blob/main/CHANGELOG.md
94
- post_install_message:
108
+ post_install_message:
95
109
  rdoc_options: []
96
110
  require_paths:
97
111
  - lib
@@ -106,8 +120,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
120
  - !ruby/object:Gem::Version
107
121
  version: '0'
108
122
  requirements: []
109
- rubygems_version: 3.3.26
110
- signing_key:
123
+ rubygems_version: 3.2.3
124
+ signing_key:
111
125
  specification_version: 4
112
126
  summary: Manage your database schema through configuration
113
127
  test_files: []