uff_db_loader 3.0.1 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 808414f4eabaeb5ce4f34cbe179a78f730c9d26ad8ad15b69255b15038ffe803
4
- data.tar.gz: 84543d60988b10a30c002d6a3922a23b9818e1c0d6d8e548dec9d51bbd6fdfe8
3
+ metadata.gz: da9439294400f1649a17e1cfe572708d68c043096fa5d2d8ec7b9d9c16aa44c1
4
+ data.tar.gz: b21a7eecaf6942bd18032a7c7a198d8bac84e7e0ee69558c887da8b07733f26b
5
5
  SHA512:
6
- metadata.gz: 3375429c2ba7351f575f8e1a658a9962d00ef5b4dbce63e496ca2534e2febd014f482eb98d4fbd6419f6d19461df99fc903f75e1859426fa5400d75f78646778
7
- data.tar.gz: 035eb70eaf893677206aaf0b8be8b68bae37322d0d1ad870612ef4ff7c14b79b36a72c5c2823a15722d3e91b8e269d652a90fa71dfea3e0224b4a2fcb423aea6
6
+ metadata.gz: b9cd41e8a56a23d406e3672179ab16d309cc93336d35319102e3c28cfc625a0992747b24da97237b5e55f59e6dd9b578681b0c689d31ae6fd0164e51a5aa8c7e
7
+ data.tar.gz: 5b39ed2a2c2975d8a0dec526a2a4897987fe7e33b618bbbf96abc465fb9e7fbf3c8cd66700fbd03c7030cd208ae1dfa4e4eab1b3a58e0795bf20ca5f3820bdf4
@@ -7,7 +7,7 @@ module UffDbLoader
7
7
  end
8
8
 
9
9
  def self.dump_command_template
10
- "ssh %user%@%host% \"docker exec -i %container_name% sh -c 'exec mysqldump --opt --no-tablespaces -uroot -p\"\\$MYSQL_ROOT_PASSWORD\" %database%'\" > %target%"
10
+ "ssh %user%@%host% \"docker exec -i %container_name% sh -c 'exec mysqldump --opt --single-transaction --routines --triggers --events --no-tablespaces -uroot -p\"\\$MYSQL_ROOT_PASSWORD\" %database%'\" > %target%"
11
11
  end
12
12
 
13
13
  def self.restore_command(database_name, result_file_path)
@@ -7,20 +7,20 @@ namespace :uff_db_loader do
7
7
  task install: :environment do
8
8
  UffDbLoader.create_initializer
9
9
 
10
- puts "👶 Created a Rails initializer file at #{UffDbLoader.initializer_path}."
10
+ UffDbLoader.log "👶 Created a Rails initializer file at #{UffDbLoader.initializer_path}."
11
11
 
12
12
  if UffDbLoader.setup_dynamic_database_name_in_config
13
- puts "🤖 Updated #{UffDbLoader.config.database_config_file}. Happy hacking, beep boop!"
13
+ UffDbLoader.log "🤖 Updated #{UffDbLoader.config.database_config_file}. Happy hacking, beep boop!"
14
14
  else
15
- puts "💩 Because YAML is a wonderful format, you need to adapt your config file by hand."
16
- puts "🆗 Go to #{UffDbLoader.config.database_config_file} and change the development database value to: #{UffDbLoader.database_name_template("default_database_name")}"
15
+ UffDbLoader.log "💩 Because YAML is a wonderful format, you need to adapt your config file by hand."
16
+ UffDbLoader.log "🆗 Go to #{UffDbLoader.config.database_config_file} and change the development database value to: #{UffDbLoader.database_name_template("default_database_name")}"
17
17
  end
18
18
  end
19
19
 
20
20
  desc "Dumps a remote database from a selected environment to #{UffDbLoader.config.dumps_directory}"
21
21
  task dump: :environment do
22
22
  prompt = TTY::Prompt.new
23
- environment = prompt.select("Which environment should we get the dump from?", UffDbLoader.config.environments)
23
+ environment = prompt.select("Which environment should we get the dump from?", UffDbLoader.config.environments, filter: true)
24
24
  UffDbLoader.ensure_valid_environment!(environment)
25
25
  UffDbLoader.dump_from(environment)
26
26
  end
@@ -35,7 +35,7 @@ namespace :uff_db_loader do
35
35
  ActiveRecord::Base.establish_connection(Rails.configuration.database_configuration["development"])
36
36
 
37
37
  prompt = TTY::Prompt.new
38
- database_name = prompt.select("Which dump should be restored?", UffDbLoader.dumps)
38
+ database_name = prompt.select("Which dump should be restored?", UffDbLoader.dumps, filter: true)
39
39
 
40
40
  UffDbLoader.load_dump_into_database(database_name)
41
41
  end
@@ -46,12 +46,12 @@ namespace :uff_db_loader do
46
46
 
47
47
  prompt = TTY::Prompt.new
48
48
  databases = UffDbLoader.databases
49
- new_database = prompt.select("Which database do you want to switch to?", databases)
49
+ new_database = prompt.select("Which database do you want to switch to?", databases, filter: true)
50
50
 
51
51
  UffDbLoader.remember_database_name(new_database)
52
52
  UffDbLoader.restart_rails_server
53
53
 
54
- puts "♻️ Restarted rails server with new database."
54
+ UffDbLoader.log "♻️ Restarted rails server with new database."
55
55
  end
56
56
 
57
57
  desc "Dumps a remote database from a selected environment to #{UffDbLoader.config.dumps_directory}, then restores and selects the database"
@@ -59,11 +59,11 @@ namespace :uff_db_loader do
59
59
  UffDbLoader.ensure_installation!
60
60
 
61
61
  prompt = TTY::Prompt.new
62
- environment = prompt.select("Which environment should we get the dump from?", UffDbLoader.config.environments)
62
+ environment = prompt.select("Which environment should we get the dump from?", UffDbLoader.config.environments, filter: true)
63
63
  UffDbLoader.ensure_valid_environment!(environment)
64
64
  result_file_path = UffDbLoader.dump_from(environment)
65
65
 
66
- puts "🤓 Reading from to #{result_file_path}"
66
+ UffDbLoader.log "🤓 Reading from to #{result_file_path}"
67
67
 
68
68
  database_name = File.basename(result_file_path, ".*")
69
69
  UffDbLoader.load_dump_into_database(database_name)
@@ -74,11 +74,11 @@ namespace :uff_db_loader do
74
74
  UffDbLoader.databases.each do |database_name|
75
75
  next if database_name == ActiveRecord::Base.connection.current_database
76
76
 
77
- puts "Dropping #{database_name}"
77
+ UffDbLoader.log "Dropping #{database_name}"
78
78
  UffDbLoader.drop_database(database_name)
79
79
  end
80
80
 
81
- puts "Removing dumps from #{UffDbLoader.config.dumps_directory}"
81
+ UffDbLoader.log "Removing dumps from #{UffDbLoader.config.dumps_directory}"
82
82
  UffDbLoader.prune_dump_directory
83
83
  end
84
84
 
@@ -87,6 +87,6 @@ namespace :uff_db_loader do
87
87
  UffDbLoader.remember_database_name("")
88
88
  UffDbLoader.restart_rails_server
89
89
 
90
- puts "♻️ Restarted rails server with default database."
90
+ UffDbLoader.log "♻️ Restarted rails server with default database."
91
91
  end
92
92
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module UffDbLoader
4
- VERSION = "3.0.1"
4
+ VERSION = "3.1.0"
5
5
  end
data/lib/uff_db_loader.rb CHANGED
@@ -14,6 +14,10 @@ module UffDbLoader
14
14
  @configuration ||= Configuration.new
15
15
  end
16
16
 
17
+ def log(message)
18
+ puts "[UffDbLoader] #{message}"
19
+ end
20
+
17
21
  def reset
18
22
  @configuration = Configuration.new
19
23
  end
@@ -29,14 +33,14 @@ module UffDbLoader
29
33
  def dump_from(environment)
30
34
  FileUtils.mkdir_p(config.dumps_directory)
31
35
 
32
- puts "⬇️ Creating dump ..."
36
+ log "⬇️ Creating dump ..."
33
37
 
34
38
  target = dump_file_path(Time.now.strftime("#{config.app_name}_#{environment}_#{TIMESTAMP_FORMAT}"))
35
39
 
36
40
  command_successful = system(dump_command(environment, target))
37
41
  raise "Command did not run succesful: #{dump_command(environment, target)}" unless command_successful
38
42
 
39
- puts "✅ Succesfully dumped to #{target}"
43
+ log "✅ Succesfully dumped to #{target}"
40
44
 
41
45
  target
42
46
  end
@@ -106,19 +110,19 @@ module UffDbLoader
106
110
  UffDbLoader.drop_database(database_name)
107
111
  UffDbLoader.create_database(database_name)
108
112
 
109
- puts "🗂 Created database #{database_name}"
113
+ log "🗂 Created database #{database_name}"
110
114
 
111
115
  dump_file_path = dump_file_path(database_name)
112
116
 
113
117
  command_successful = system(restore_command(database_name, dump_file_path))
114
118
  raise "Command did not run succesful: #{restore_command(database_name, dump_file_path)}" unless command_successful
115
119
 
116
- puts "✅ Succesfully loaded #{dump_file_path} into #{database_name}"
120
+ log "✅ Succesfully loaded #{dump_file_path} into #{database_name}"
117
121
 
118
122
  remember_database_name(database_name)
119
123
  restart_rails_server
120
124
 
121
- puts "♻️ Restarted rails server with new database."
125
+ log "♻️ Restarted rails server with new database."
122
126
  end
123
127
 
124
128
  def initializer_path
@@ -194,13 +198,13 @@ module UffDbLoader
194
198
  when "postgresql"
195
199
  ":postgresql"
196
200
  else
197
- puts "🙃 Could not automatically determine your used database system. Please adapt in the initializer."
201
+ log "🙃 Could not automatically determine your used database system. Please adapt in the initializer."
198
202
  ":unknown"
199
203
  end
200
204
  end
201
205
 
202
206
  def environments
203
- ActiveRecord::Base.configurations.configurations.to_a.map(&:env_name) - ["test", "development"]
207
+ ActiveRecord::Base.configurations.configurations.to_a.map(&:env_name) - ["default", "test", "development"]
204
208
  end
205
209
 
206
210
  class ForbiddenEnvironmentError < StandardError; end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uff_db_loader
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andreas Hellwig
@@ -88,9 +88,9 @@ licenses:
88
88
  - MIT
89
89
  metadata:
90
90
  bug_tracker_uri: https://github.com/rmehner/uff_db_loader/issues
91
- changelog_uri: https://github.com/rmehner/uff_db_loader/releases/tag/3.0.1
91
+ changelog_uri: https://github.com/rmehner/uff_db_loader/releases/tag/3.1.0
92
92
  homepage_uri: https://github.com/rmehner/uff_db_loader
93
- source_code_uri: https://github.com/rmehner/uff_db_loader/tree/3.0.1
93
+ source_code_uri: https://github.com/rmehner/uff_db_loader/tree/3.1.0
94
94
  post_install_message: Please run `bin/rails uff_db_loader:install` to complete the
95
95
  installation.
96
96
  rdoc_options: []