schema-evolution-manager 0.9.58 → 0.9.60

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: 5a59b34cee82db218b0008110f365a64567ec8dcbaa9f59a0fcd30acce9586f0
4
- data.tar.gz: 5a6066de334be67b4915debfc0670e27c56d40eeb008c60bbc2348da8be37603
3
+ metadata.gz: 9ac86130a475dfedad8e6d56d0bf250b717e44698205fb612e7561096f45c796
4
+ data.tar.gz: 79af5be19d627253552a44e73e753865e3b84baf8d91076859fcd269dda1b0e2
5
5
  SHA512:
6
- metadata.gz: 21fe48093f5386013d3eed04dec8a9ebd512a670608a6b5a663b2c68c0b9af3fedb910577a58c3e3abe8098d3e66ac76cc25019cad0ebaa47e22014aa061c10c
7
- data.tar.gz: 447e2949614cb4f2c332f317596195b796ff811016d8d6259b42a351e59b8a04c324b8bbb8bae3e8248b9a521bb3ba719db4d35676ea2ad1ebbc011ce6984caf
6
+ metadata.gz: 4283a52241a30e38cefac92040ea14a4e15f2b9af51912c9ae5017e8599f0e84912b5db8d2198515875c2ffcca84c261a63cde849fa58ee1369499546c4f4504
7
+ data.tar.gz: 39152c48787380c306725fd15dabb0ab0574ce0ed3620d405bf0707f3d24252c1ecc91bd41127117e9a005a9bee648ee278e8cad458aea5ae998a6c1693a4fbf
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.58
136
+ git checkout 0.9.60
137
137
  ruby ./configure.rb
138
138
  sudo ./install.rb
139
139
 
@@ -26,6 +26,7 @@ module SchemaEvolutionManager
26
26
  :dry_run => "Include flag to echo commands that will run without actually executing them",
27
27
  :non_interactive => "Avoid all prompts and use defaults for any option that requires user input",
28
28
  :help => "Display help",
29
+ :version => "Display the version of schema-evolution-manager",
29
30
  :verbose => "Enable verbose logging of all system calls",
30
31
  }
31
32
  end
@@ -51,6 +52,9 @@ module SchemaEvolutionManager
51
52
  if !optional.include?(:verbose)
52
53
  optional << :verbose
53
54
  end
55
+ if !optional.include?(:version)
56
+ optional << :version
57
+ end
54
58
 
55
59
  found_arguments = parse_string_arguments(args)
56
60
  missing = required.select { |field| blank?(found_arguments[field]) }
@@ -71,6 +75,7 @@ module SchemaEvolutionManager
71
75
  @password = found_arguments.delete(:password)
72
76
  @help = found_arguments.delete(:help)
73
77
  @verbose = found_arguments.delete(:verbose)
78
+ @version = found_arguments.delete(:version)
74
79
 
75
80
  Preconditions.check_state(found_arguments.empty?,
76
81
  "Did not handle all flags: %s" % found_arguments.keys.join(" "))
@@ -79,6 +84,11 @@ module SchemaEvolutionManager
79
84
  RdocUsage.printAndExit(0)
80
85
  end
81
86
 
87
+ if @version
88
+ puts SemVersion::VERSION
89
+ exit(0)
90
+ end
91
+
82
92
  if @verbose
83
93
  Library.set_verbose(true)
84
94
  end
@@ -2,8 +2,15 @@ module SchemaEvolutionManager
2
2
  class Library
3
3
 
4
4
  unless defined?(TMPFILE_DIR)
5
- TMPFILE_DIR = "/tmp"
5
+ # A directory private to this process. Temp file names below are
6
+ # "<prefix>.<counter>", and sem-apply uses a migration's basename as the
7
+ # prefix, so two processes applying the same scripts would otherwise
8
+ # compute the same path and delete each other's copy mid-run. mktmpdir
9
+ # honours TMPDIR and creates the directory mode 0700 with a random name.
10
+ TMPFILE_DIR = Dir.mktmpdir("schema-evolution-manager-")
6
11
  TMPFILE_PREFIX = "schema-evolution-manager-#{Process.pid}.tmp"
12
+ tmpfile_dir_owner = Process.pid
13
+ at_exit { FileUtils.rm_rf(TMPFILE_DIR) if Process.pid == tmpfile_dir_owner }
7
14
  end
8
15
  @@tmpfile_count = 0
9
16
  @@verbose = false
@@ -12,23 +12,49 @@ module SchemaEvolutionManager
12
12
 
13
13
  if !valid.include?(subcommand)
14
14
  if subcommand.empty?
15
- puts "ERROR: Missing db subcommand. Must be one of: %s" % valid.join(", ")
15
+ $stderr.puts "ERROR: Missing db subcommand. Must be one of: %s" % valid.join(", ")
16
16
  else
17
- puts "ERROR: Invalid db subcommand[%s]. Must be one of: %s" % [subcommand, valid.join(", ")]
17
+ $stderr.puts "ERROR: Invalid db subcommand[%s]. Must be one of: %s" % [subcommand, valid.join(", ")]
18
18
  end
19
19
  exit(4)
20
20
  end
21
21
 
22
22
  db_args = SchemaEvolutionManager::Args.new(args.join(" "), :optional => ['url', 'host', 'user', 'name', 'port', 'set'])
23
- db = SchemaEvolutionManager::Db.from_args(db_args)
24
-
25
- if subcommand == "version"
26
- version = SchemaEvolutionManager::Versions.new(db).latest
27
- puts version unless version.nil?
28
- elsif subcommand == "scripts"
29
- SchemaEvolutionManager::Scripts.new(db, SchemaEvolutionManager::Scripts::SCRIPTS).applied.each do |filename|
30
- puts filename
23
+
24
+ if db_args.url.to_s.strip.empty? && db_args.name.to_s.strip.empty?
25
+ $stderr.puts "ERROR: Missing database connection. Provide --url <postgres url> or --host/--name."
26
+ exit(3)
27
+ end
28
+
29
+ # A common mistake is passing a bare database name to --url. Catch it with
30
+ # an actionable hint instead of letting parse_url raise a raw backtrace.
31
+ if db_args.url && !db_args.url.include?("://")
32
+ $stderr.puts "ERROR: --url must be a full connection string (e.g. postgres://localhost:5432/%s). To connect by database name, use --name %s." % [db_args.url, db_args.url]
33
+ exit(3)
34
+ end
35
+
36
+ begin
37
+ db = SchemaEvolutionManager::Db.from_args(db_args)
38
+ if subcommand == "version"
39
+ version = SchemaEvolutionManager::Versions.new(db).latest
40
+ if version.nil?
41
+ $stderr.puts "No deployed version recorded"
42
+ else
43
+ puts version
44
+ end
45
+ elsif subcommand == "scripts"
46
+ applied = SchemaEvolutionManager::Scripts.new(db, SchemaEvolutionManager::Scripts::SCRIPTS).applied
47
+ if applied.empty?
48
+ $stderr.puts "No scripts recorded"
49
+ else
50
+ applied.each { |filename| puts filename }
51
+ end
31
52
  end
53
+ rescue => e
54
+ # Surface a single clean line (e.g. bad url, unreachable host, missing
55
+ # database) rather than a Ruby stack trace.
56
+ $stderr.puts "ERROR: %s" % e.message.to_s.split("\n").first
57
+ exit(3)
32
58
  end
33
59
  end
34
60
 
@@ -3,7 +3,7 @@ module SchemaEvolutionManager
3
3
 
4
4
  module SemVersion
5
5
 
6
- VERSION ||= '0.9.43'
6
+ VERSION ||= '0.9.60'
7
7
 
8
8
  end
9
9
 
@@ -1,6 +1,7 @@
1
1
  require 'fileutils'
2
2
  require 'pathname'
3
3
  require 'tempfile'
4
+ require 'tmpdir'
4
5
  require 'shellwords'
5
6
 
6
7
  dir = File.dirname(__FILE__)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: schema-evolution-manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.58
4
+ version: 0.9.60
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Bryzek
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2026-07-17 00:00:00.000000000 Z
10
+ date: 2026-09-27 00:00:00.000000000 Z
11
11
  dependencies: []
12
12
  description: '["Michael Bryzek"]'
13
13
  email: mbryzek@alum.mit.edu
@@ -72,7 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
72
72
  - !ruby/object:Gem::Version
73
73
  version: '0'
74
74
  requirements: []
75
- rubygems_version: 3.7.1
75
+ rubygems_version: 4.0.17
76
76
  specification_version: 4
77
77
  summary: Schema evolution manager is a simple schema migration tool for postgresql
78
78
  databases.