schema-evolution-manager 0.9.27 → 0.9.28
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/README.md +1 -1
- data/bin/sem-add +3 -10
- data/bin/sem-apply +11 -1
- data/lib/schema-evolution-manager/apply_util.rb +4 -22
- data/lib/schema-evolution-manager/db.rb +11 -3
- data/lib/schema-evolution-manager/script_error.rb +5 -3
- data/lib/schema-evolution-manager/sem_version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a2b3925d1baff6b4fea5a7967b28a179903609d
|
4
|
+
data.tar.gz: cb346790f69179476bfd5d26d20460a270a4a9f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bc5c07b0484b6173fdd807caaedd9e3ef5f38a3af05743f8769310122baec9975a751b00f5f1b1d8ac0a390c0fd67b78ff17dcb388dd8c14d6df6cd6cc54e03b
|
7
|
+
data.tar.gz: 881ad9e1b5a458b637f2579cdf275a163eca74c640680e6aec308b15d316a787398939d9b9f2ab58629813b6ed9416e52cd2d76761fbc4add05516c581712bbd
|
data/README.md
CHANGED
@@ -127,7 +127,7 @@ There are two ways to install schema evolution manager:
|
|
127
127
|
|
128
128
|
git clone git://github.com/mbryzek/schema-evolution-manager.git
|
129
129
|
cd schema-evolution-manager
|
130
|
-
git checkout 0.9.
|
130
|
+
git checkout 0.9.28
|
131
131
|
ruby ./configure.rb
|
132
132
|
sudo ./install.rb
|
133
133
|
|
data/bin/sem-add
CHANGED
@@ -26,17 +26,10 @@ contents = IO.read(file)
|
|
26
26
|
now = Time.now.strftime('%Y%m%d-%H%M%S')
|
27
27
|
target = File.join(scripts_dir, "#{now}.sql")
|
28
28
|
|
29
|
-
padding = 1000
|
30
|
-
counter = 0
|
31
29
|
while File.exists?(target)
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
end
|
36
|
-
# The .z prefix is here to ensure these files sort AFTER the first
|
37
|
-
# .sql file. Maintaining lexicographic sorting is important to
|
38
|
-
# support simple command line tools (e.g. ls)
|
39
|
-
target = File.join(scripts_dir, "#{now}.z#{padding + counter}.sql")
|
30
|
+
sleep 0.1
|
31
|
+
now = Time.now.strftime('%Y%m%d-%H%M%S')
|
32
|
+
target = File.join(scripts_dir, "#{now}.sql")
|
40
33
|
end
|
41
34
|
|
42
35
|
puts "Adding #{target}"
|
data/bin/sem-apply
CHANGED
@@ -36,7 +36,17 @@ begin
|
|
36
36
|
end
|
37
37
|
rescue SchemaEvolutionManager::ScriptError => e
|
38
38
|
puts ""
|
39
|
-
puts "ERROR applying script: %s" % e.
|
39
|
+
puts "ERROR applying script: %s" % e.path
|
40
|
+
|
41
|
+
puts ""
|
42
|
+
if e.output.strip.empty?
|
43
|
+
puts " ==> There was no error output"
|
44
|
+
else
|
45
|
+
puts " " + e.output.strip.split("\n").map { |l|
|
46
|
+
" #{l}"
|
47
|
+
}.join("\n").strip
|
48
|
+
end
|
49
|
+
|
40
50
|
puts ""
|
41
51
|
puts "If this script has previously been applied to this database, you can record it as having been applied by:"
|
42
52
|
puts " " + e.dml
|
@@ -26,35 +26,17 @@ module SchemaEvolutionManager
|
|
26
26
|
count += 1
|
27
27
|
if @dry_run
|
28
28
|
puts "[DRY RUN] Applying #{filename}"
|
29
|
-
|
29
|
+
puts path
|
30
|
+
puts ""
|
30
31
|
else
|
31
32
|
puts "Applying #{filename}"
|
32
|
-
|
33
|
+
@db.psql_file(filename, path)
|
34
|
+
@scripts.record_as_run!(filename)
|
33
35
|
end
|
34
36
|
end
|
35
37
|
count
|
36
38
|
end
|
37
39
|
|
38
|
-
private
|
39
|
-
def apply_dry_run(filename, path)
|
40
|
-
puts path
|
41
|
-
puts ""
|
42
|
-
end
|
43
|
-
|
44
|
-
def apply_real(filename, path)
|
45
|
-
have_error = true
|
46
|
-
begin
|
47
|
-
@db.psql_file(path)
|
48
|
-
have_error = false
|
49
|
-
ensure
|
50
|
-
if have_error
|
51
|
-
raise ScriptError.new(@db, filename)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
@scripts.record_as_run!(filename)
|
56
|
-
end
|
57
|
-
|
58
40
|
end
|
59
41
|
|
60
42
|
end
|
@@ -20,7 +20,7 @@ module SchemaEvolutionManager
|
|
20
20
|
scripts = Scripts.new(self, Scripts::BOOTSTRAP_SCRIPTS)
|
21
21
|
dir = File.join(Library.base_dir, "scripts")
|
22
22
|
scripts.each_pending(dir) do |filename, path|
|
23
|
-
psql_file(path)
|
23
|
+
psql_file(filename, path)
|
24
24
|
scripts.record_as_run!(filename)
|
25
25
|
end
|
26
26
|
end
|
@@ -59,7 +59,7 @@ module SchemaEvolutionManager
|
|
59
59
|
end
|
60
60
|
|
61
61
|
# executes sql commands from a file in a single transaction
|
62
|
-
def psql_file(path)
|
62
|
+
def psql_file(filename, path)
|
63
63
|
Preconditions.assert_class(path, String)
|
64
64
|
Preconditions.check_state(File.exists?(path), "File[%s] not found" % path)
|
65
65
|
|
@@ -72,7 +72,15 @@ module SchemaEvolutionManager
|
|
72
72
|
end
|
73
73
|
|
74
74
|
command = "psql --file \"%s\" #{options} %s" % [tmp, @url]
|
75
|
-
|
75
|
+
|
76
|
+
Library.with_temp_file do |output|
|
77
|
+
result = `#{command} &> #{output}`.strip
|
78
|
+
status = $?
|
79
|
+
if status.to_i > 0
|
80
|
+
errors = File.exists?(output) ? IO.read(output) : result
|
81
|
+
raise ScriptError.new(self, filename, path, errors)
|
82
|
+
end
|
83
|
+
end
|
76
84
|
end
|
77
85
|
end
|
78
86
|
|
@@ -2,15 +2,17 @@ module SchemaEvolutionManager
|
|
2
2
|
|
3
3
|
class ScriptError < Exception
|
4
4
|
|
5
|
-
attr_reader :
|
5
|
+
attr_reader :path, :output
|
6
6
|
|
7
|
-
def initialize(db, filename)
|
7
|
+
def initialize(db, filename, path, output)
|
8
8
|
@db = Preconditions.assert_class(db, Db)
|
9
9
|
@filename = Preconditions.assert_class(filename, String)
|
10
|
+
@path = Preconditions.assert_class(path, String)
|
11
|
+
@output = Preconditions.assert_class(output, String)
|
10
12
|
end
|
11
13
|
|
12
14
|
def dml
|
13
|
-
sql_command = "insert into %s.%s (filename) values ('%s')" % [Db.schema_name, Scripts::SCRIPTS, filename]
|
15
|
+
sql_command = "insert into %s.%s (filename) values ('%s')" % [Db.schema_name, Scripts::SCRIPTS, @filename]
|
14
16
|
"psql --command \"%s\" %s" % [sql_command, @db.url]
|
15
17
|
end
|
16
18
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: schema-evolution-manager
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.28
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Bryzek
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-05-18 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: '["Michael Bryzek"]'
|
14
14
|
email: mbryzek@alum.mit.edu
|
@@ -73,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
73
73
|
version: '0'
|
74
74
|
requirements: []
|
75
75
|
rubyforge_project:
|
76
|
-
rubygems_version: 2.0.14
|
76
|
+
rubygems_version: 2.0.14.1
|
77
77
|
signing_key:
|
78
78
|
specification_version: 4
|
79
79
|
summary: Schema evolution manager is a simple schema migration tool for postgresql
|