psql-cm 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.md +5 -0
- data/lib/psql-cm/base.rb +2 -1
- data/lib/psql-cm/restore.rb +15 -17
- data/lib/psql-cm/setup.rb +1 -1
- data/lib/psql-cm/version.rb +1 -1
- metadata +2 -2
data/History.md
CHANGED
data/lib/psql-cm/base.rb
CHANGED
data/lib/psql-cm/restore.rb
CHANGED
@@ -22,10 +22,10 @@ module PSQLCM
|
|
22
22
|
psqlrc_file = File.join(ENV['HOME'],'.psqlrc')
|
23
23
|
FileUtils.touch(psqlrc_file) unless File.exists?(psqlrc_file)
|
24
24
|
psqlrc = File.read(psqlrc_file)
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
25
|
+
|
26
|
+
file = File.open(psqlrc_file,'w')
|
27
|
+
file.write "SET search_path TO #{schema}; "
|
28
|
+
file.close
|
29
29
|
|
30
30
|
begin
|
31
31
|
tag = "restore:#{database}:#{schema}>"
|
@@ -39,10 +39,10 @@ module PSQLCM
|
|
39
39
|
debug tag, "base:sql> #{sql}"
|
40
40
|
db(database).exec(sql).each do |base_row|
|
41
41
|
debug "BASE content:", base_row['content']
|
42
|
-
Tempfile.open('base.sql')
|
43
|
-
|
44
|
-
|
45
|
-
|
42
|
+
tempfile = Tempfile.open('base.sql')
|
43
|
+
tempfile.write(base_row['content'])
|
44
|
+
sh "psql #{db(database).psql_args} #{database} < #{tempfile.path}"
|
45
|
+
tempfile.close
|
46
46
|
end
|
47
47
|
|
48
48
|
sql = "SELECT content from #{schema}.#{config.cm_table}
|
@@ -54,17 +54,15 @@ module PSQLCM
|
|
54
54
|
debug tag, "change:count>#{changes.cmd_tuples}"
|
55
55
|
changes.each do |row|
|
56
56
|
debug tag, "content>\n#{row['content']}"
|
57
|
-
Tempfile.open('change.sql')
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
end
|
57
|
+
tempfile = Tempfile.open('change.sql')
|
58
|
+
tempfile.write(row['content'])
|
59
|
+
sh "psql #{db(database).psql_args} #{database} < #{tempfile.path}"
|
60
|
+
tempfile.close
|
62
61
|
end
|
63
62
|
ensure
|
64
|
-
File.open(psqlrc_file,'w')
|
65
|
-
|
66
|
-
|
67
|
-
end
|
63
|
+
file = File.open(psqlrc_file,'w')
|
64
|
+
file.write psqlrc
|
65
|
+
file.close
|
68
66
|
end
|
69
67
|
end
|
70
68
|
end
|
data/lib/psql-cm/setup.rb
CHANGED
@@ -9,7 +9,7 @@ module PSQLCM
|
|
9
9
|
|
10
10
|
Tempfile.open('base.sql') do |temp_file|
|
11
11
|
sh %W[ pg_dump #{db(database).psql_args}
|
12
|
-
--schema-only --no-owner --no-privileges
|
12
|
+
--schema-only --no-owner --no-privileges --exclude-table=pg_psql_cm
|
13
13
|
--schema=#{schema} --file=#{temp_file.path} #{database}
|
14
14
|
].join(' ')
|
15
15
|
|
data/lib/psql-cm/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: psql-cm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-05-
|
12
|
+
date: 2012-05-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: pg
|