mysql_to_pg_dump 0.1.1 → 0.1.2

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: 543e1b6ff8522d54236b9884c9f600a7b0c4e3c9
4
- data.tar.gz: 1333c7894151117264896d44e0d446204725189b
3
+ metadata.gz: a54878752500814773db3ebeb0498c5cd4d695e0
4
+ data.tar.gz: 39dcbb6d98f6ec8984ec7a0fcc75b76aba2b61b1
5
5
  SHA512:
6
- metadata.gz: fbba2e7c2a7314c8ee173e2de4766dfca113c85ac509ff2c0944a4b156d24abf5bb820424fcc12f8f2e2980c3df136852751c4352e19a6c66a60108fa15ae81c
7
- data.tar.gz: 501fbff1cec1c4e4e0fbad972ad90f1887ea15c2a3c2c748625b71c604b9314f7a78ed5a4f85f58b13c3371a4193cb5e8f0f2ccb64cbacb4e9571cd5247c3830
6
+ metadata.gz: 2e5331f6f9088f90c5c47e4276b4087e136b02c74f2a4092a33f35b090d76d2b4a8ae4ac7856f957eadcc7ba1c31eeff95ba74bc5efce280bb652fe71de8955b
7
+ data.tar.gz: f7d32cbcb5d92cc5cfe4539dfd160b7656a527e0853aa769e9e60590bfcc64adca1f1ec4f971bc669d4b19b875a1ae1d87fba7c909d2da29d4868a39b735ce3b
data/README.md CHANGED
@@ -39,6 +39,9 @@ Or install it yourself as:
39
39
  ```bash
40
40
  $ gem install mysql_to_pg_dump
41
41
  ```
42
+ ## TODO
43
+ - add something for multi-user usage
44
+ - ssh -i key.pem username@server supporting
42
45
 
43
46
  ## License
44
47
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -1,3 +1,4 @@
1
1
  module MysqlToPgDump
2
- require 'mysql_to_pg_dump/task_uploader' if defined?(Rails)
2
+ require 'mysql_to_pg_dump/tasks_uploader' if defined?(Rails)
3
+ require 'mysql_to_pg_dump/tasks_helper'
3
4
  end
@@ -0,0 +1,64 @@
1
+ require 'mysql_to_pg_dump'
2
+
3
+ module MysqlToPgDump
4
+ module TasksHelper
5
+ def server_addr_input
6
+ printf "Enter server address like 'server@123.4.5.6': "
7
+ STDIN.gets.strip
8
+ end
9
+
10
+ def data_already_pulled?
11
+ if %x{ls tmp}.split("\n").include? 'db_server_data'
12
+ %x(ls tmp/db_server_data).split("\n").size == db_tables.size
13
+ else
14
+ false
15
+ end
16
+ end
17
+
18
+ def psql_import_query table_name
19
+ "\\copy #{table_name} from " \
20
+ "'tmp/db_server_data/#{production['database']}_#{table_name}.txt' " \
21
+ "delimiter E'\\t' null as 'NULL' csv header"
22
+ end
23
+
24
+ def clean_database
25
+ task_names = %w(db:drop db:create db:migrate)
26
+ task_names.each { |t| Rake::Task[t].invoke }
27
+ end
28
+
29
+ def login_to_mysql
30
+ "mysql " \
31
+ "--user=#{production['username']} " \
32
+ "--password=#{production['password']} " \
33
+ "#{production['database']}"
34
+ end
35
+
36
+ def file_to_save table_name
37
+ "#{tmp_location}/#{production['database']}_#{table_name}.txt"
38
+ end
39
+
40
+ def sql_select table_name
41
+ "SELECT * FROM #{table_name};"
42
+ end
43
+
44
+ def db_tables
45
+ ActiveRecord::Base.connection.tables - ['schema_migrations']
46
+ end
47
+
48
+ def tmp_location
49
+ 'app/current/tmp/db_server_data'
50
+ end
51
+
52
+ def show_db_info env
53
+ Rails.application.config.database_configuration[env]
54
+ end
55
+
56
+ def dev
57
+ show_db_info 'development'
58
+ end
59
+
60
+ def production
61
+ show_db_info 'production'
62
+ end
63
+ end
64
+ end
@@ -2,7 +2,7 @@ require 'mysql_to_pg_dump'
2
2
  require 'rails'
3
3
 
4
4
  module MysqlToPgDump
5
- module TaskUploader
5
+ module TasksUploader
6
6
  spec = Gem::Specification.find_by_name 'mysql_to_pg_dump'
7
7
  load "#{spec.gem_dir}/lib/tasks/db.rake"
8
8
  end
@@ -1,3 +1,3 @@
1
1
  module MysqlToPgDump
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
data/lib/tasks/db.rake CHANGED
@@ -1,11 +1,11 @@
1
- # require 'rake/rdoctask'
2
- # require 'rake/testtask'
3
- # require 'tasks/rails'
4
1
  require 'rake'
5
2
  require 'colorize'
6
3
  require 'rake-progressbar'
4
+ require 'mysql_to_pg_dump/tasks_helper'
7
5
 
8
6
  namespace :db do
7
+ include MysqlToPgDump::TasksHelper
8
+
9
9
  desc "Copies db content from production " \
10
10
  "server into tmp/db_server_data"
11
11
  task pull: :environment do
@@ -65,65 +65,4 @@ namespace :db do
65
65
  "local postgres and cleans junk"
66
66
  task force: ['db:pull', 'db:pull:load', 'db:pull:clean']
67
67
  end
68
-
69
- private
70
-
71
- def server_addr_input
72
- printf "Enter server address like 'server@123.4.5.6': "
73
- STDIN.gets.strip
74
- end
75
-
76
- def data_already_pulled?
77
- if %x{ls tmp}.split("\n").include? 'db_server_data'
78
- %x(ls tmp/db_server_data).split("\n").size == db_tables.size
79
- else
80
- false
81
- end
82
- end
83
-
84
- def psql_import_query table_name
85
- "\\copy #{table_name} from " \
86
- "'tmp/db_server_data/#{production['database']}_#{table_name}.txt' " \
87
- "delimiter E'\\t' null as 'NULL' csv header"
88
- end
89
-
90
- def clean_database
91
- task_names = %w(db:drop db:create db:migrate)
92
- task_names.each { |t| Rake::Task[t].invoke }
93
- end
94
-
95
- def login_to_mysql
96
- "mysql " \
97
- "--user=#{production['username']} " \
98
- "--password=#{production['password']} " \
99
- "#{production['database']}"
100
- end
101
-
102
- def file_to_save table_name
103
- "#{tmp_location}/#{production['database']}_#{table_name}.txt"
104
- end
105
-
106
- def sql_select table_name
107
- "SELECT * FROM #{table_name};"
108
- end
109
-
110
- def db_tables
111
- ActiveRecord::Base.connection.tables - ['schema_migrations']
112
- end
113
-
114
- def tmp_location
115
- 'app/current/tmp/db_server_data'
116
- end
117
-
118
- def show_db_info env
119
- Rails.application.config.database_configuration[env]
120
- end
121
-
122
- def dev
123
- show_db_info 'development'
124
- end
125
-
126
- def production
127
- show_db_info 'production'
128
- end
129
68
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mysql_to_pg_dump
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dimkarodinz
@@ -63,7 +63,8 @@ files:
63
63
  - README.md
64
64
  - Rakefile
65
65
  - lib/mysql_to_pg_dump.rb
66
- - lib/mysql_to_pg_dump/task_uploader.rb
66
+ - lib/mysql_to_pg_dump/tasks_helper.rb
67
+ - lib/mysql_to_pg_dump/tasks_uploader.rb
67
68
  - lib/mysql_to_pg_dump/version.rb
68
69
  - lib/tasks/db.rake
69
70
  homepage: https://github.com/Dimkarodinz/mysql_to_pg_dump.git