rails_data_fix 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/data_fix/version.rb +1 -1
- data/lib/tasks/data_fix_tasks.rake +19 -8
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 996eb4ae785df03d116c4ea96a790f4ef788750ca41eb85f99df2ae7f76ed835
|
4
|
+
data.tar.gz: dab788752610b9ee408ce298e74329c4abf65ce2c446b0a0db8095ed9885ff5f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7036ae2d223d26ed6a9393f11b794b5924146c9a76c65c3f935351a026502b54f6c2f215998a44957437179ddbbfcfd4a8e6c4620e79da9c006a4ccd841fcf6d
|
7
|
+
data.tar.gz: 6e4e64ad4e5babc3fc4e81d11f7b86c50ff65d61a7a6a8fb10561e2aa0591ed8ad15ea87fb062d7a4561b73c4fe3739c85d535f2e9fe186b464b7d7d5906909c
|
data/lib/data_fix/version.rb
CHANGED
@@ -57,7 +57,7 @@ namespace :data_fix do
|
|
57
57
|
backup_db_name = db_name.gsub(/\.sqlite3$/, "-#{Date.today.strftime('%Y-%m-%d')}.sqlite3")
|
58
58
|
cmd = "cp \"#{db_name}\" \"#{backup_db_name}\""
|
59
59
|
dry_run_msg = "WOULD RUN: #{cmd}"
|
60
|
-
|
60
|
+
when "mysql2"
|
61
61
|
db_host = config["host"]
|
62
62
|
db_name = config["database"]
|
63
63
|
db_username = config["username"]
|
@@ -65,6 +65,15 @@ namespace :data_fix do
|
|
65
65
|
backup_db_name = "db/#{db_name}-#{Rails.env}-#{Date.today.strftime('%Y-%m-%d')}.sql"
|
66
66
|
cmd = "mysqldump -u #{db_name} -p#{db_password} #{db_name} > \"#{backup_db_name}\""
|
67
67
|
dry_run_msg = "WOULD RUN: #{cmd}"
|
68
|
+
when "sqlserver"
|
69
|
+
db_host = config["host"]
|
70
|
+
db_name = config["database"]
|
71
|
+
db_username = config["username"]
|
72
|
+
db_password = config["password"]
|
73
|
+
db_azure = config["azure"]
|
74
|
+
backup_db_name = "db/#{db_name}-#{Rails.env}-#{Date.today.strftime('%Y-%m-%d')}.sql"
|
75
|
+
cmd = "sqlcmd -E -S #{db_host} –Q “BACKUP DATABASE #{db_name} TO DISK='#{backup_db_name}'"
|
76
|
+
dry_run_msg = "WOULD RUN: #{cmd}"
|
68
77
|
else
|
69
78
|
dry_run_mgs = ""
|
70
79
|
end
|
@@ -75,13 +84,9 @@ namespace :data_fix do
|
|
75
84
|
system cmd
|
76
85
|
puts_and_log "backup performed and available as #{backup_db_name}."
|
77
86
|
else
|
78
|
-
puts "
|
79
|
-
|
80
|
-
|
81
|
-
puts "Proceed anyway? [Y/n]"
|
82
|
-
answer = gets.chomp
|
83
|
-
end
|
84
|
-
exit unless answer == "Y"
|
87
|
+
puts "FATAL ERROR: I don't know how to backup for #{config[:adapter]})"
|
88
|
+
puts "--> Use rake data_fix:force_run to execute with no backup"
|
89
|
+
exit
|
85
90
|
end
|
86
91
|
end
|
87
92
|
|
@@ -136,6 +141,12 @@ namespace :data_fix do
|
|
136
141
|
df_run false, ENV["STEP"]
|
137
142
|
end
|
138
143
|
|
144
|
+
desc 'Run the required data fixes (STEP= to specify the optional number of steps)'
|
145
|
+
task force_run: :environment do
|
146
|
+
exit_if_not_installed
|
147
|
+
df_run false, ENV["STEP"], true
|
148
|
+
end
|
149
|
+
|
139
150
|
desc 'Status: show which data fixes have been run'
|
140
151
|
task status: :environment do
|
141
152
|
exit_if_not_installed
|