mysql_to_pg_dump 0.1.2 → 0.2.0

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: a54878752500814773db3ebeb0498c5cd4d695e0
4
- data.tar.gz: 39dcbb6d98f6ec8984ec7a0fcc75b76aba2b61b1
3
+ metadata.gz: d1359241e8cb2d238bced2b4261d92ec11eddc79
4
+ data.tar.gz: fd29a266b06a48c60a56e3505d1092263b2c4287
5
5
  SHA512:
6
- metadata.gz: 2e5331f6f9088f90c5c47e4276b4087e136b02c74f2a4092a33f35b090d76d2b4a8ae4ac7856f957eadcc7ba1c31eeff95ba74bc5efce280bb652fe71de8955b
7
- data.tar.gz: f7d32cbcb5d92cc5cfe4539dfd160b7656a527e0853aa769e9e60590bfcc64adca1f1ec4f971bc669d4b19b875a1ae1d87fba7c909d2da29d4868a39b735ce3b
6
+ metadata.gz: 9a250944717993556612616386322011aa47d484cdf13d0c509351f3579ac3b470a9d0ad14c0e0077a6c08ef22e7293d5307fe76c8bffa7c9c2926f186b7b21a
7
+ data.tar.gz: 013a2f7dd3f26b229ef90bf989486136574f2f244bb14882ec1d2dac84827fe9f63381aed3b0e8430392ca3c9f378f3229d9750911f1fb6a28d47cf496d7dffb
data/README.md CHANGED
@@ -4,7 +4,7 @@ load it into your local postgres database.
4
4
  Technically, it is not a dump - but result is almost the same.
5
5
 
6
6
  ## Usage
7
- Copy content of remote mysql db to tmp/db_server_data as .txt files.
7
+ Copy content of remote mysql db to tmp/db_server_data as .csv files.
8
8
  ```bash
9
9
  $ rake db:pull your_server@123.4.5.6
10
10
  ```
@@ -40,8 +40,7 @@ Or install it yourself as:
40
40
  $ gem install mysql_to_pg_dump
41
41
  ```
42
42
  ## TODO
43
- - add something for multi-user usage
44
- - ssh -i key.pem username@server supporting
43
+ - ssh -i key.pub username@server supporting
45
44
 
46
45
  ## License
47
46
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -17,7 +17,7 @@ module MysqlToPgDump
17
17
 
18
18
  def psql_import_query table_name
19
19
  "\\copy #{table_name} from " \
20
- "'tmp/db_server_data/#{production['database']}_#{table_name}.txt' " \
20
+ "'tmp/db_server_data/#{production['database']}_#{table_name}.csv' " \
21
21
  "delimiter E'\\t' null as 'NULL' csv header"
22
22
  end
23
23
 
@@ -33,8 +33,8 @@ module MysqlToPgDump
33
33
  "#{production['database']}"
34
34
  end
35
35
 
36
- def file_to_save table_name
37
- "#{tmp_location}/#{production['database']}_#{table_name}.txt"
36
+ def file_to_save table_name, location
37
+ "#{location}/#{production['database']}_#{table_name}.csv"
38
38
  end
39
39
 
40
40
  def sql_select table_name
@@ -45,8 +45,14 @@ module MysqlToPgDump
45
45
  ActiveRecord::Base.connection.tables - ['schema_migrations']
46
46
  end
47
47
 
48
- def tmp_location
49
- 'app/current/tmp/db_server_data'
48
+ def uniq_dir_location
49
+ "app/current/tmp/db_server_data/#{uniq_string}"
50
+ end
51
+
52
+ def uniq_string
53
+ s = ""
54
+ 20.times { s << ('0'..'9').to_a.sample }
55
+ s
50
56
  end
51
57
 
52
58
  def show_db_info env
@@ -1,3 +1,3 @@
1
1
  module MysqlToPgDump
2
- VERSION = '0.1.2'
2
+ VERSION = '0.2.0'
3
3
  end
data/lib/tasks/db.rake CHANGED
@@ -15,15 +15,16 @@ namespace :db do
15
15
 
16
16
  if server_addr.include?("@")
17
17
  bar = RakeProgressbar.new(db_tables.size)
18
+ tmp_location = uniq_dir_location
18
19
 
19
20
  system "ssh #{server_addr} 'mkdir -p #{tmp_location}'"
20
21
  db_tables.each do |table|
21
- system %{ssh #{server_addr} "echo '#{sql_select(table)}' | #{login_to_mysql} > #{file_to_save(table)}"}
22
+ system %{ssh #{server_addr} "echo '#{sql_select(table)}' | #{login_to_mysql} > #{file_to_save(table, tmp_location)}"}
22
23
  bar.inc
23
24
  end
24
25
  bar.finished
25
26
 
26
- system "scp -r #{server_addr}:#{tmp_location} tmp"
27
+ system "scp -r #{server_addr}:#{tmp_location}/* tmp/db_server_data"
27
28
  system "ssh #{server_addr} 'rm -rf #{tmp_location}'"
28
29
 
29
30
  printf "Db data from production server " \
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mysql_to_pg_dump
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dimkarodinz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-29 00:00:00.000000000 Z
11
+ date: 2016-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails