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 +4 -4
- data/README.md +2 -3
- data/lib/mysql_to_pg_dump/tasks_helper.rb +11 -5
- data/lib/mysql_to_pg_dump/version.rb +1 -1
- data/lib/tasks/db.rake +3 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d1359241e8cb2d238bced2b4261d92ec11eddc79
|
4
|
+
data.tar.gz: fd29a266b06a48c60a56e3505d1092263b2c4287
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 .
|
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
|
-
-
|
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}.
|
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
|
-
"#{
|
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
|
49
|
-
|
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
|
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.
|
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-
|
11
|
+
date: 2016-09-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|