schema-evolution-manager 0.9.45 → 0.9.47
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -4
- data/bin/sem-add +2 -2
- data/bin/sem-apply +1 -1
- data/bin/sem-dist +1 -1
- data/bin/sem-init +3 -3
- data/lib/schema-evolution-manager/args.rb +11 -4
- data/lib/schema-evolution-manager/db.rb +7 -5
- data/lib/schema-evolution-manager/install_template.rb +2 -2
- data/lib/schema-evolution-manager/library.rb +1 -1
- data/lib/schema-evolution-manager/migration_file.rb +1 -1
- data/lib/schema-evolution-manager/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed6b170d492bc54dae6e23bec8915bc63ee60cf623cc58d7fe501513e5ac51cb
|
4
|
+
data.tar.gz: d8cc588c9fdbf909b7f74d0caf5733f2e19fb42904ed5162e884fdca07e520a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c49a71d7e017ba6a8a2b16dc817e7e02df007e2f715a102daf9d291beb9085145d5ec2fd9da1f769c169df7aef8bdec968d7bda3ce597bf61ec2f9efdac6a4af
|
7
|
+
data.tar.gz: 0b7fafcd88dab54fbdfab0bed71763c5c2cfc206514f78bbf25e73cc687f6882282b102729958b90b0775ebce993d2fb0a95c80d78545af606d8b7ab299b10b9
|
data/README.md
CHANGED
@@ -123,17 +123,21 @@ First presented at [PGDay NYC 2013](https://speakerdeck.com/mbryzek/schema-evolu
|
|
123
123
|
|
124
124
|
## Installation
|
125
125
|
|
126
|
-
There are
|
126
|
+
There are three ways to install schema evolution manager:
|
127
|
+
|
128
|
+
1. Via brew
|
129
|
+
|
130
|
+
brew install schema-evolution-manager
|
127
131
|
|
128
132
|
1. Direct install using ruby (no dependency on ruby gems)
|
129
133
|
|
130
|
-
git clone git
|
134
|
+
git clone git@github.com:mbryzek/schema-evolution-manager.git
|
131
135
|
cd schema-evolution-manager
|
132
|
-
git checkout 0.9.
|
136
|
+
git checkout 0.9.47
|
133
137
|
ruby ./configure.rb
|
134
138
|
sudo ./install.rb
|
135
139
|
|
136
|
-
|
140
|
+
1. If you have ruby gems:
|
137
141
|
|
138
142
|
gem install schema-evolution-manager
|
139
143
|
|
data/bin/sem-add
CHANGED
@@ -16,7 +16,7 @@ if file.to_s.strip == ""
|
|
16
16
|
SchemaEvolutionManager::RdocUsage.printAndExit(1)
|
17
17
|
end
|
18
18
|
|
19
|
-
SchemaEvolutionManager::Preconditions.check_state(File.
|
19
|
+
SchemaEvolutionManager::Preconditions.check_state(File.exist?(file), "File[#{file}] could not be found")
|
20
20
|
SchemaEvolutionManager::Preconditions.check_state(file.match(/\.sql/i), "File[#{file}] must end with .sql")
|
21
21
|
|
22
22
|
scripts_dir = File.join(`pwd`.strip, "scripts")
|
@@ -26,7 +26,7 @@ contents = IO.read(file)
|
|
26
26
|
now = Time.now.utc.strftime('%Y%m%d-%H%M%S')
|
27
27
|
target = File.join(scripts_dir, "#{now}.sql")
|
28
28
|
|
29
|
-
while File.
|
29
|
+
while File.exist?(target)
|
30
30
|
sleep 0.1
|
31
31
|
now = Time.now.utc.strftime('%Y%m%d-%H%M%S')
|
32
32
|
target = File.join(scripts_dir, "#{now}.sql")
|
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 password))
|
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: ")
|
data/bin/sem-dist
CHANGED
data/bin/sem-init
CHANGED
@@ -54,7 +54,7 @@ Dir.chdir(args.dir) do
|
|
54
54
|
wrappers = []
|
55
55
|
Dir.glob("#{template_dir}/*").each do |path|
|
56
56
|
wrapper = File.basename(path)
|
57
|
-
if !File.
|
57
|
+
if !File.exist?(wrapper)
|
58
58
|
puts "Creating wrapper script #{wrapper}"
|
59
59
|
copy_file(path, wrapper, subs)
|
60
60
|
SchemaEvolutionManager::Library.system_or_error("chmod +x #{wrapper}")
|
@@ -67,14 +67,14 @@ Dir.chdir(args.dir) do
|
|
67
67
|
end
|
68
68
|
|
69
69
|
readme = "README.md"
|
70
|
-
if !File.
|
70
|
+
if !File.exist?(readme)
|
71
71
|
puts "Creating #{readme}"
|
72
72
|
copy_file("schema-evolution-manager/template/README.md", "README.md", subs)
|
73
73
|
SchemaEvolutionManager::Library.system_or_error("git add #{readme}")
|
74
74
|
SchemaEvolutionManager::Library.system_or_error("git commit -m 'Adding README.md' README.md")
|
75
75
|
end
|
76
76
|
|
77
|
-
if !File.
|
77
|
+
if !File.exist?("scripts")
|
78
78
|
SchemaEvolutionManager::Library.system_or_error("mkdir scripts")
|
79
79
|
SchemaEvolutionManager::Library.system_or_error("touch scripts/.exists")
|
80
80
|
SchemaEvolutionManager::Library.system_or_error("git add scripts/.exists")
|
@@ -5,7 +5,9 @@ module SchemaEvolutionManager
|
|
5
5
|
# tests around it... so we have our own internal simple implementation.
|
6
6
|
class Args
|
7
7
|
|
8
|
-
if !defined?(
|
8
|
+
if !defined?(ARRAY_FLAGS)
|
9
|
+
ARRAY_FLAGS = [:set]
|
10
|
+
|
9
11
|
FLAGS_WITH_ARGUMENTS = {
|
10
12
|
:artifact_name => "Specifies the name of the artifact. Tag will be appended to this name",
|
11
13
|
:user => "Connect to the database as this username instead of the default",
|
@@ -16,7 +18,7 @@ module SchemaEvolutionManager
|
|
16
18
|
:dir => "Path to a directory",
|
17
19
|
:tag => "A git tag (e.g. 0.0.1)",
|
18
20
|
:prefix => "Configure installer to use this prefix",
|
19
|
-
:set => "Passthrough for postgresql --set argument"
|
21
|
+
:set => "Passthrough for postgresql --set argument. Returns an array of the options set"
|
20
22
|
}
|
21
23
|
|
22
24
|
FLAGS_NO_ARGUMENTS = {
|
@@ -61,7 +63,7 @@ module SchemaEvolutionManager
|
|
61
63
|
@user = found_arguments.delete(:user)
|
62
64
|
@dir = found_arguments.delete(:dir)
|
63
65
|
@tag = found_arguments.delete(:tag)
|
64
|
-
@set = found_arguments.delete(:set)
|
66
|
+
@set = found_arguments.delete(:set) || []
|
65
67
|
|
66
68
|
@dry_run = found_arguments.delete(:dry_run)
|
67
69
|
@password = found_arguments.delete(:password)
|
@@ -138,7 +140,12 @@ module SchemaEvolutionManager
|
|
138
140
|
index += 1
|
139
141
|
|
140
142
|
if FLAGS_WITH_ARGUMENTS.has_key?(flag)
|
141
|
-
|
143
|
+
if ARRAY_FLAGS.include?(flag)
|
144
|
+
found[flag] ||= []
|
145
|
+
found[flag] << values[index]
|
146
|
+
else
|
147
|
+
found[flag] = values[index]
|
148
|
+
end
|
142
149
|
index += 1
|
143
150
|
|
144
151
|
elsif FLAGS_NO_ARGUMENTS.has_key?(flag)
|
@@ -2,14 +2,16 @@ module SchemaEvolutionManager
|
|
2
2
|
|
3
3
|
class Db
|
4
4
|
|
5
|
-
attr_reader :url
|
5
|
+
attr_reader :url, :psql_executable_with_options
|
6
6
|
|
7
7
|
def initialize(url, opts={})
|
8
8
|
@url = Preconditions.check_not_blank(url, "url cannot be blank")
|
9
9
|
password = opts.delete(:password)
|
10
10
|
|
11
|
-
|
12
|
-
|
11
|
+
@psql_executable_with_options = "psql"
|
12
|
+
(opts.delete(:set) || []).each do |arg|
|
13
|
+
@psql_executable_with_options << " --set #{arg}"
|
14
|
+
end
|
13
15
|
|
14
16
|
Preconditions.assert_empty_opts(opts)
|
15
17
|
connection_data = ConnectionData.parse_url(@url)
|
@@ -65,7 +67,7 @@ module SchemaEvolutionManager
|
|
65
67
|
# executes sql commands from a file in a single transaction
|
66
68
|
def psql_file(filename, path)
|
67
69
|
Preconditions.assert_class(path, String)
|
68
|
-
Preconditions.check_state(File.
|
70
|
+
Preconditions.check_state(File.exist?(path), "File[%s] not found" % path)
|
69
71
|
|
70
72
|
options = Db.attribute_values(path).join(" ")
|
71
73
|
|
@@ -81,7 +83,7 @@ module SchemaEvolutionManager
|
|
81
83
|
result = `#{command} > #{output} 2>&1`.strip
|
82
84
|
status = $?
|
83
85
|
if status.to_i > 0
|
84
|
-
errors = File.
|
86
|
+
errors = File.exist?(output) ? IO.read(output) : result
|
85
87
|
raise ScriptError.new(self, filename, path, errors)
|
86
88
|
end
|
87
89
|
end
|
@@ -47,7 +47,7 @@ SchemaEvolutionManager::Library.ensure_dir!(version_dir)
|
|
47
47
|
SchemaEvolutionManager::Library.ensure_dir!(bin_dir)
|
48
48
|
|
49
49
|
Dir.chdir(lib_dir) do
|
50
|
-
if File.
|
50
|
+
if File.exist?("schema-evolution-manager")
|
51
51
|
if File.symlink?("schema-evolution-manager")
|
52
52
|
SchemaEvolutionManager::Library.system_or_error("rm schema-evolution-manager")
|
53
53
|
SchemaEvolutionManager::Library.system_or_error("ln -s %s %s" % [version_name, 'schema-evolution-manager'])
|
@@ -89,7 +89,7 @@ end
|
|
89
89
|
|
90
90
|
# Overrwrite bin/sem-config with proper location of lib dir
|
91
91
|
init_file = File.join(version_dir, "bin/sem-config")
|
92
|
-
SchemaEvolutionManager::Preconditions.check_state(File.
|
92
|
+
SchemaEvolutionManager::Preconditions.check_state(File.exist?(init_file), "Init file[%s] not found" % init_file)
|
93
93
|
File.open(init_file, "w") do |out|
|
94
94
|
out << "load File.join('%s')\n" % File.join(version_dir, 'lib/schema-evolution-manager.rb')
|
95
95
|
end
|
@@ -48,7 +48,7 @@ module SchemaEvolutionManager
|
|
48
48
|
|
49
49
|
def initialize(path)
|
50
50
|
@path = path
|
51
|
-
Preconditions.check_state(File.
|
51
|
+
Preconditions.check_state(File.exist?(@path), "File[#{@path}] does not exist")
|
52
52
|
@attribute_values = parse_attribute_values
|
53
53
|
end
|
54
54
|
|
@@ -60,7 +60,7 @@ module SchemaEvolutionManager
|
|
60
60
|
# Reads the current version (from the VERSION FILE), returning an
|
61
61
|
# instance of the Version class
|
62
62
|
def Version.read
|
63
|
-
Preconditions.check_state(File.
|
63
|
+
Preconditions.check_state(File.exist?(VERSION_FILE), "Version file at path[%s] not found" % VERSION_FILE)
|
64
64
|
version = IO.read(VERSION_FILE).strip
|
65
65
|
Version.parse(version)
|
66
66
|
end
|
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.47
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Bryzek
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: '["Michael Bryzek"]'
|
14
14
|
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.0.3
|
75
|
+
rubygems_version: 3.0.3.1
|
76
76
|
signing_key:
|
77
77
|
specification_version: 4
|
78
78
|
summary: Schema evolution manager is a simple schema migration tool for postgresql
|