pgmove 0.1.3 → 0.1.4

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
  SHA1:
3
- metadata.gz: 00b005d8b2d38bd0eb5b5480326f534076e494ab
4
- data.tar.gz: 1056b670b437a30e687eeeecc4549c02393fa83d
3
+ metadata.gz: 72e8b160ec6cd5035d7929d3292c16ce847857ff
4
+ data.tar.gz: 1a94727cf4048c10ba4320633bb769c9eeed32bc
5
5
  SHA512:
6
- metadata.gz: d945e20d99cdcd74d23c2556f8ebc481011754c1ad3fd5484436253c44d650a9aff512925ed105e3a004a8f2cb68646701e9ae909c76ab87440efe791eb167c6
7
- data.tar.gz: f4bbb8fabccf30308e1d69bf715322d84dcb443c9dbab0ce7b031785a4c247a020d1576559cce6920f7b7a7a2d7477eabace8999506e83fe835c75791755ef14
6
+ metadata.gz: 8174380bd325718bc39f85907605ca8e68acab7161d0797e6346efd16783882187fe0c1f786e5fda62b8a040af9790634872c44cd9cc966073c0d5595931314a
7
+ data.tar.gz: c8c40418ddad7b569aad9beae397b7294ff7ab90f09fa1f5364740a8078d57e6d2c985b00c1744f93e9e67f4b2070408cda4a51eaf3fec78709e90def5dd7840
@@ -15,6 +15,7 @@ module Pgmove
15
15
  def initialize(src_db, dest_db)
16
16
  @src_db = src_db
17
17
  @dest_db = dest_db
18
+ @dbname = "bucardo_#{@src_db.name}"
18
19
  end
19
20
 
20
21
  def setup
@@ -28,7 +29,7 @@ module Pgmove
28
29
  end
29
30
 
30
31
  def bucardo(command, db: nil, env: {})
31
- db ||= "bucardo"
32
+ db ||= @dbname
32
33
  system! "bucardo -U #{@src_db.user} -P #{@src_db.pass} -h #{@src_db.host} -p #{@src_db.port} -d #{db} #{command}", env: env
33
34
  end
34
35
 
@@ -110,12 +111,20 @@ module Pgmove
110
111
  logger.bullet "removing bucardo"
111
112
  conn.exec "DROP schema if exists bucardo cascade"
112
113
  conn.exec "DROP database IF EXISTS bucardo"
114
+ conn.exec "DROP database IF EXISTS #{@dbname}"
113
115
  conn.exec "drop role IF EXISTS bucardo"
114
116
  end
115
117
 
116
118
  def install
117
119
  env = { "DBUSER" => @src_db.user }
118
120
  bucardo "install --batch --pid-dir tmp", db: "postgres", env: env
121
+ @src_db.pg_conn do |conn|
122
+ conn.exec "alter database bucardo rename to #{@dbname}"
123
+ end
124
+ @src_db.pg_conn(@dbname) do |conn|
125
+ conn.exec "reassign owned by bucardo to #{@src_db.user}"
126
+ conn.exec "drop role bucardo"
127
+ end
119
128
  end
120
129
 
121
130
  def copy_schema
data/lib/pgmove/db.rb CHANGED
@@ -14,7 +14,7 @@ module Pgmove
14
14
  @port = port
15
15
 
16
16
  if use_tmp
17
- @name = "#{name}_bucardo_tmp"
17
+ @name = "#{name}_pgmove_tmp"
18
18
  @final_name = name
19
19
  else
20
20
  @name = name
@@ -1,3 +1,3 @@
1
1
  module Pgmove
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pgmove
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Neeraj
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-12-02 00:00:00.000000000 Z
11
+ date: 2016-12-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg