dynamic_migrations 3.1.1 → 3.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 971a68fa07394767b18c8781df8be28eada7a1024256698f63bc4c0b0c06a560
4
- data.tar.gz: 266f91ca87e1da40a0fbd13a9cde183e167c2950f1d0718169fdb8e4ff4eec52
3
+ metadata.gz: ca3d0e63e744237ce50761c65a92516cc4c53bf5c3bc71b7108fc06220b65185
4
+ data.tar.gz: fc9ee993485d527e71558de3ac9d5f5e98b35f6fefadbaffe9a44a90fc44bcee
5
5
  SHA512:
6
- metadata.gz: f4f5ca51ab18b44f7a832d9442c7412e725c6b4d688fd481d45752168a6fb6665b15cf288934399d0eb7ef64e8a78a44730fa138cb0f1ff0e1435c135a8b627e
7
- data.tar.gz: 223b0432f2198a98f33dfeba24f156938b47d286908a62571f93b7acfebeef6fc5594f0eac8c47805e01c1038c25af6af68321e0e829d4f673b5a5292587eede
6
+ metadata.gz: '00922f2a680713f98d20258d25cc2a7be769a1c1088e7fd717f1de111dfc738301c45a9f022061670a67bd66882700df63b631728767e6591df8f677aaaf4c0f'
7
+ data.tar.gz: 449b4d2e2dc6d18a6d3a19f21b5800738b6bcd1e60d29440684f4286a0384bd22564589ad07b6b18122a26a1b5df4011a750468060c94ff9811daa59381c06bd
data/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Changelog
2
2
 
3
+ ## [3.2.1](https://github.com/craigulliott/dynamic_migrations/compare/v3.2.0...v3.2.1) (2023-08-17)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * making column descriptions optional ([c384225](https://github.com/craigulliott/dynamic_migrations/commit/c3842254841c677efb777a1beb519754a4e85cc1))
9
+ * trimming object descriptions when saving ([c384225](https://github.com/craigulliott/dynamic_migrations/commit/c3842254841c677efb777a1beb519754a4e85cc1))
10
+
11
+ ## [3.2.0](https://github.com/craigulliott/dynamic_migrations/compare/v3.1.1...v3.2.0) (2023-08-16)
12
+
13
+
14
+ ### Features
15
+
16
+ * adding a with_connection method to the database which yields to a block, and provides a connection object to that block ([fc1590a](https://github.com/craigulliott/dynamic_migrations/commit/fc1590a00be8d3f9f0ee0472a96be94b80e667e0))
17
+
3
18
  ## [3.1.1](https://github.com/craigulliott/dynamic_migrations/compare/v3.1.0...v3.1.1) (2023-08-16)
4
19
 
5
20
 
@@ -21,6 +21,15 @@ module DynamicMigrations
21
21
  options[:array] = true
22
22
  end
23
23
 
24
+ # comment has to be last
25
+ if column.description
26
+ options[:comment] = <<~RUBY
27
+ <<~COMMENT
28
+ #{indent column.description}
29
+ COMMENT
30
+ RUBY
31
+ end
32
+
24
33
  options_syntax = options.map { |k, v| "#{k}: #{v}" }.join(", ")
25
34
 
26
35
  data_type = column.data_type
@@ -34,9 +43,7 @@ module DynamicMigrations
34
43
  object: column,
35
44
  code_comment: code_comment,
36
45
  migration: <<~RUBY
37
- add_column :#{column.table.name}, :#{column.name}, :#{data_type}, #{options_syntax}, comment: <<~COMMENT
38
- #{indent column.description}
39
- COMMENT
46
+ add_column :#{column.table.name}, :#{column.name}, :#{data_type}, #{options_syntax}
40
47
  RUBY
41
48
  end
42
49
 
@@ -32,6 +32,21 @@ module DynamicMigrations
32
32
  raise NotConnectedError
33
33
  end
34
34
  end
35
+
36
+ # Opens a connection to the database server, and yields the provided block
37
+ # before automatically closing the connection again. This is useful for
38
+ # executing one time queries against the database server.
39
+ def with_connection &block
40
+ # create a temporary connection to the server
41
+ connect
42
+ # perform work with the connection
43
+ # todo: `yield connection` would have been preferred, but rbs/steep doesnt understand that syntax
44
+ if block.is_a? Proc
45
+ block.call connection
46
+ end
47
+ # close the connection
48
+ disconnect
49
+ end
35
50
  end
36
51
  end
37
52
  end
@@ -38,7 +38,8 @@ module DynamicMigrations
38
38
 
39
39
  unless description.nil?
40
40
  raise ExpectedStringError, description unless description.is_a? String
41
- @description = description
41
+ @description = description.strip
42
+ @description = nil if description == ""
42
43
  end
43
44
  end
44
45
 
@@ -34,7 +34,8 @@ module DynamicMigrations
34
34
 
35
35
  unless description.nil?
36
36
  raise ExpectedStringError, description unless description.is_a? String
37
- @description = description
37
+ @description = description.strip
38
+ @description = nil if description == ""
38
39
  end
39
40
 
40
41
  @interval_type = interval_type
@@ -72,7 +72,8 @@ module DynamicMigrations
72
72
 
73
73
  unless description.nil?
74
74
  raise ExpectedStringError, description unless description.is_a? String
75
- @description = description
75
+ @description = description.strip
76
+ @description = nil if description == ""
76
77
  end
77
78
 
78
79
  raise ExpectedBooleanError, deferrable unless [true, false].include?(deferrable)
@@ -61,7 +61,8 @@ module DynamicMigrations
61
61
 
62
62
  unless description.nil?
63
63
  raise ExpectedStringError, description unless description.is_a? String
64
- @description = description
64
+ @description = description.strip
65
+ @description = nil if description == ""
65
66
  end
66
67
 
67
68
  raise ExpectedBooleanError, unique unless [true, false].include?(unique)
@@ -45,7 +45,8 @@ module DynamicMigrations
45
45
 
46
46
  unless description.nil?
47
47
  raise ExpectedStringError, description unless description.is_a? String
48
- @description = description
48
+ @description = description.strip
49
+ @description = nil if description == ""
49
50
  end
50
51
  end
51
52
 
@@ -115,7 +115,8 @@ module DynamicMigrations
115
115
 
116
116
  unless description.nil?
117
117
  raise ExpectedStringError, description unless description.is_a? String
118
- @description = description
118
+ @description = description.strip
119
+ @description = nil if description == ""
119
120
  end
120
121
  end
121
122
 
@@ -50,7 +50,8 @@ module DynamicMigrations
50
50
 
51
51
  unless description.nil?
52
52
  raise ExpectedStringError, description unless description.is_a? String
53
- @description = description
53
+ @description = description.strip
54
+ @description = nil if description == ""
54
55
  end
55
56
 
56
57
  raise ExpectedBooleanError, deferrable unless [true, false].include?(deferrable)
@@ -48,7 +48,8 @@ module DynamicMigrations
48
48
 
49
49
  unless description.nil?
50
50
  raise ExpectedStringError, description unless description.is_a? String
51
- @description = description
51
+ @description = description.strip
52
+ @description = nil if description == ""
52
53
  end
53
54
 
54
55
  raise ExpectedBooleanError, deferrable unless [true, false].include?(deferrable)
@@ -39,7 +39,8 @@ module DynamicMigrations
39
39
 
40
40
  unless description.nil?
41
41
  raise ExpectedStringError, description unless description.is_a? String
42
- @description = description
42
+ @description = description.strip
43
+ @description = nil if description == ""
43
44
  end
44
45
 
45
46
  @columns = {}
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DynamicMigrations
4
- VERSION = "3.1.1"
4
+ VERSION = "3.2.1"
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: 3.1.1
4
+ version: 3.2.1
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-08-16 00:00:00.000000000 Z
11
+ date: 2023-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg
@@ -142,13 +142,13 @@ files:
142
142
  - lib/dynamic_migrations/postgres/server/database/triggers_and_functions_loader.rb
143
143
  - lib/dynamic_migrations/postgres/server/database/validations_loader.rb
144
144
  - lib/dynamic_migrations/version.rb
145
- homepage:
145
+ homepage:
146
146
  licenses:
147
147
  - MIT
148
148
  metadata:
149
149
  source_code_uri: https://github.com/craigulliott/dynamic_migrations/
150
150
  changelog_uri: https://github.com/craigulliott/dynamic_migrations/blob/main/CHANGELOG.md
151
- post_install_message:
151
+ post_install_message:
152
152
  rdoc_options: []
153
153
  require_paths:
154
154
  - lib
@@ -163,8 +163,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
163
163
  - !ruby/object:Gem::Version
164
164
  version: '0'
165
165
  requirements: []
166
- rubygems_version: 3.2.3
167
- signing_key:
166
+ rubygems_version: 3.3.26
167
+ signing_key:
168
168
  specification_version: 4
169
169
  summary: Manage your database schema through configuration
170
170
  test_files: []