schema-evolution-manager 0.9.53 → 0.9.55

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: 0d5bef9063ede01772251882e1ff8652bda678ec8401a3344e706f303b48c420
4
- data.tar.gz: 0ad47d946818ce331acc713730a8e456a7a8948823d8e40cc2b7e55936bc9e6c
3
+ metadata.gz: 13f084ac4b6a9429196469f2b1f52d04167aa443edbe7a65c68a160aab7fc041
4
+ data.tar.gz: 3676fe675b11d5b718b655ac806f66a2986c9745cd63ea52938a030af4a88d22
5
5
  SHA512:
6
- metadata.gz: 707c14f6b932b1c7e02da6b40ae385d12006355afedbbe275213b8eea8092b7d01187ab046d38578c5719d2fa39ac2f78fcf83677cee324b66f655ea41dde389
7
- data.tar.gz: 83f0713085aa02e47f80136da6b61ad8679af7a36650d36d40236e77a0d6b4946f1767c23f716552b08db9d1d5e1f3ee062d1a32a905b20c09c0eee539f2a7ef
6
+ metadata.gz: a94a3a279cc858c04637c3e0cb5c9b120699e7fac2091cce7d915bda06761b4eece3fa39c2d76b4d55ec65306ae72977ca204894f130b3a633eb8e331a87c3f5
7
+ data.tar.gz: e7b3d5196adef32e19ed60f58bdcdeed6f377193ddc15f30e44f3a1018325b0ddbf2e4415269645965f24ee4cefa099e36c64cbf77722d5bacfdaed657b565b8
data/README.md CHANGED
@@ -133,7 +133,7 @@ There are three ways to install schema evolution manager:
133
133
 
134
134
  git clone git@github.com:mbryzek/schema-evolution-manager.git
135
135
  cd schema-evolution-manager
136
- git checkout 0.9.53
136
+ git checkout 0.9.55
137
137
  ruby ./configure.rb
138
138
  sudo ./install.rb
139
139
 
data/bin/sem-apply CHANGED
@@ -15,7 +15,7 @@ require 'tempfile'
15
15
 
16
16
  load File.join(File.dirname(__FILE__), 'sem-config')
17
17
 
18
- args = SchemaEvolutionManager::Args.from_stdin(:optional => %w(url host port name user dry_run non_interactive password set))
18
+ args = SchemaEvolutionManager::Args.from_stdin(:optional => %w(url host port name user dry_run password set))
19
19
 
20
20
  password = if args.password
21
21
  SchemaEvolutionManager::Ask.for_password("Please enter your password: ")
@@ -24,12 +24,12 @@ password = if args.password
24
24
  end
25
25
 
26
26
  db = SchemaEvolutionManager::Db.from_args(args, :password => password)
27
- util = SchemaEvolutionManager::ApplyUtil.new(db, :dry_run => args.dry_run || false, :non_interactive => args.non_interactive || false)
27
+ util = SchemaEvolutionManager::ApplyUtil.new(db, :dry_run => args.dry_run || false)
28
28
 
29
29
  begin
30
30
  db.bootstrap!
31
31
 
32
- puts "Upgrading schema for #{db.url}"
32
+ puts "Upgrading schema for #{db.sanitized_url}"
33
33
  count = util.apply!("./scripts")
34
34
  if count == 0
35
35
  puts " All scripts have been previously applied"
@@ -8,11 +8,6 @@ module SchemaEvolutionManager
8
8
  @dry_run = true
9
9
  end
10
10
 
11
- @non_interactive = opts.delete(:non_interactive)
12
- if @non_interactive.nil?
13
- @non_interactive = false
14
- end
15
-
16
11
  @db = Preconditions.assert_class(db, Db)
17
12
  @scripts = Scripts.new(@db, Scripts::SCRIPTS)
18
13
  end
@@ -21,32 +16,14 @@ module SchemaEvolutionManager
21
16
  @dry_run
22
17
  end
23
18
 
24
- def non_interactive?
25
- @non_interactive
26
- end
27
-
28
19
  # Applies scripts in order, returning number of scripts applied
29
20
  def apply!(dir)
30
21
  Preconditions.check_state(File.directory?(dir),
31
22
  "Dir[%s] does not exist" % dir)
32
23
 
33
- pending_scripts = []
24
+ count = 0
34
25
  @scripts.each_pending(dir) do |filename, path|
35
- pending_scripts << [filename, path]
36
- end
37
-
38
- if pending_scripts.size > 1 && !dry_run? && !non_interactive?
39
- puts "Please confirm that you would like to apply all (#{pending_scripts.size}) of the pending scripts:"
40
- pending_scripts.each do |filename, path|
41
- puts " #{filename}"
42
- end
43
- continue = SchemaEvolutionManager::Ask.for_boolean("Continue?")
44
- if !continue
45
- return 0
46
- end
47
- end
48
-
49
- pending_scripts.each do |filename, path|
26
+ count += 1
50
27
  if @dry_run
51
28
  puts "[DRY RUN] Applying #{filename}"
52
29
  puts path
@@ -58,8 +35,9 @@ module SchemaEvolutionManager
58
35
  puts " Done"
59
36
  end
60
37
  end
61
- pending_scripts.size
38
+ count
62
39
  end
63
40
 
64
41
  end
42
+
65
43
  end
@@ -67,7 +67,7 @@ module SchemaEvolutionManager
67
67
  @set = found_arguments.delete(:set) || []
68
68
 
69
69
  @dry_run = found_arguments.delete(:dry_run)
70
- @non_interactive = found_arguments.delete(:non_interactive)
70
+ @non_interactice = found_arguments.delete(:non_interactive)
71
71
  @password = found_arguments.delete(:password)
72
72
  @help = found_arguments.delete(:help)
73
73
  @verbose = found_arguments.delete(:verbose)
@@ -34,8 +34,10 @@ module SchemaEvolutionManager
34
34
  # executes a simple sql command.
35
35
  def psql_command(sql_command)
36
36
  Preconditions.assert_class(sql_command, String)
37
- command = "#{@psql_executable_with_options} --no-align --tuples-only --no-psqlrc --command \"%s\" %s" % [sql_command, @url]
38
- Library.system_or_error(command)
37
+ template = "#{@psql_executable_with_options} --no-align --tuples-only --no-psqlrc --command \"%s\" %s"
38
+ command = template % [sql_command, @url]
39
+ command_to_log = template % [sql_command, sanitized_url]
40
+ Library.system_or_error(command, command_to_log)
39
41
  end
40
42
 
41
43
  def Db.attribute_values(path)
@@ -132,6 +134,37 @@ module SchemaEvolutionManager
132
134
  file.path
133
135
  end
134
136
 
137
+ # Returns a sanitized version of the URL with the password removed
138
+ # to prevent passwords from being logged or displayed in error messages
139
+ def sanitized_url
140
+ # Parse the URL to extract components
141
+ if @url.include?("://")
142
+ protocol, rest = @url.split("://", 2)
143
+ lead, name = rest.split("/", 2)
144
+
145
+ # Check if there's a username:password@ pattern
146
+ if lead.include?("@")
147
+ # Take the last element as host_part to handle passwords with @ symbols
148
+ host_part = lead.split("@").last
149
+ # Take everything before the last @ as user_part
150
+ user_part = lead.split("@")[0..-2].join("@")
151
+
152
+ if user_part.include?(":")
153
+ # Remove password, keep only username (everything before the first colon)
154
+ username = user_part.split(":", 2)[0]
155
+ sanitized_lead = "#{username}:[REDACTED]@#{host_part}"
156
+ else
157
+ sanitized_lead = lead
158
+ end
159
+ "#{protocol}://#{sanitized_lead}/#{name}"
160
+ else
161
+ @url
162
+ end
163
+ else
164
+ @url
165
+ end
166
+ end
167
+
135
168
  end
136
169
 
137
170
  end
@@ -121,9 +121,9 @@ module SchemaEvolutionManager
121
121
  # Runs the specified command, raising an error if there is a problem
122
122
  # (based on status code of the process executed). Otherwise returns
123
123
  # all the output from the script invoked.
124
- def Library.system_or_error(command)
124
+ def Library.system_or_error(command, cmd_to_log=nil)
125
125
  if Library.is_verbose?
126
- puts command
126
+ puts cmd_to_log || command
127
127
  end
128
128
 
129
129
  begin
@@ -13,7 +13,7 @@ module SchemaEvolutionManager
13
13
 
14
14
  def dml
15
15
  sql_command = "insert into %s.%s (filename) values ('%s')" % [Db.schema_name, Scripts::SCRIPTS, @filename]
16
- "psql --command \"%s\" %s" % [sql_command, @db.url]
16
+ "psql --command \"%s\" %s" % [sql_command, @db.sanitized_url]
17
17
  end
18
18
 
19
19
  end
metadata CHANGED
@@ -1,25 +1,24 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: schema-evolution-manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.53
4
+ version: 0.9.55
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Bryzek
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-07-10 00:00:00.000000000 Z
10
+ date: 2025-08-25 00:00:00.000000000 Z
12
11
  dependencies: []
13
12
  description: '["Michael Bryzek"]'
14
13
  email: mbryzek@alum.mit.edu
15
14
  executables:
16
- - sem-info
17
- - sem-config
18
15
  - sem-add
19
- - sem-init
20
16
  - sem-apply
21
- - sem-dist
22
17
  - sem-baseline
18
+ - sem-config
19
+ - sem-dist
20
+ - sem-info
21
+ - sem-init
23
22
  extensions: []
24
23
  extra_rdoc_files: []
25
24
  files:
@@ -57,7 +56,6 @@ homepage: https://github.com/gilt/schema-evolution-manager
57
56
  licenses:
58
57
  - Apache-2.0
59
58
  metadata: {}
60
- post_install_message:
61
59
  rdoc_options: []
62
60
  require_paths:
63
61
  - lib
@@ -72,8 +70,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
72
70
  - !ruby/object:Gem::Version
73
71
  version: '0'
74
72
  requirements: []
75
- rubygems_version: 3.0.3.1
76
- signing_key:
73
+ rubygems_version: 3.7.1
77
74
  specification_version: 4
78
75
  summary: Schema evolution manager is a simple schema migration tool for postgresql
79
76
  databases.