uff_db_loader 2.1.0 → 2.2.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: 1b136a4cf8a5a4bbbe44371bdee9f33a97417bc22c88937d3e826af7c4a8b459
4
- data.tar.gz: bc16630dc38a5cf6de7af81307b61dabe20f9b83675303b22addeb80288ae20c
3
+ metadata.gz: 1a2c7c42ed0513c36d938f46d9346c462ec22e978ed234f519d9825eb8701c8f
4
+ data.tar.gz: 6036d5f67b2447a2e747b6b242d4a69a96730c57f5ce45a01d618d4af91085a4
5
5
  SHA512:
6
- metadata.gz: da774d613024ae9ff97ad3a8d6d7500b9f4e7b69dff732a9877941d2f810234b00899a7d1bcc3e69c97fe5689a96e98eeba218bbe467fa9584d2f04f44d8deca
7
- data.tar.gz: 577d9b103ae12261c9d6a099a274f33f54413062d487a391e50e811e6fa91c64f122c706100df1d99fef9b9fe4869acbd5a1e171e857f402b5d7ca08e1d8b6c9
6
+ metadata.gz: e843d03ce1e569f9bd03a84ec9f95321dd34f08f23ad3897392343cffb4779cc91c9d44bb6b1634c94ef6b763177cefe2489c64207bb31cbf20140e73610fa82
7
+ data.tar.gz: 25d012b2ba4e6bfbc066b074a95523f8782c9da9a345ad0326014c8b7da87f343452966bfa7a217c3e1783ace8c90a82e5a19777be87ce7b89b69f7fb79cd063
data/README.md CHANGED
@@ -37,6 +37,7 @@ UffDbLoader.configure do |config|
37
37
  config.app_name = 'my_app' # Defaults to the Rails app name
38
38
  config.dumps_directory = '/path/to/dumps' # Defaults to Rails.root.join('dumps')
39
39
  config.database_config_file = 'path/to/database.yml' # Defaults to Rails.root.join('config', 'database.yml')
40
+ config.container_name = ->(app_name, environment) { "#{app_name}_#{environment}_custom_suffix" } # Defaults to "#{app_name}_#{environment}_db". It accepts a static string too.
40
41
  end
41
42
  ```
42
43
  For example in a file like `config/initializers/uff_db_loader.rb`.
data/lib/configuration.rb CHANGED
@@ -5,7 +5,17 @@ require "uff_db_loader/mysql"
5
5
 
6
6
  module UffDbLoader
7
7
  class Configuration
8
- attr_accessor :environments, :ssh_host, :ssh_user, :db_name, :db_system, :app_name, :dumps_directory, :database_config_file
8
+ attr_accessor(
9
+ :environments,
10
+ :ssh_host,
11
+ :ssh_user,
12
+ :db_name,
13
+ :db_system,
14
+ :app_name,
15
+ :dumps_directory,
16
+ :database_config_file,
17
+ :container_name
18
+ )
9
19
 
10
20
  def initialize
11
21
  @environments = nil
@@ -16,6 +26,7 @@ module UffDbLoader
16
26
  @app_name = Dir.pwd.split("/").last
17
27
  @dumps_directory = File.join(Dir.pwd, "dumps")
18
28
  @database_config_file = File.join(Dir.pwd, "config", "database.yml")
29
+ @container_name = nil
19
30
  end
20
31
 
21
32
  def database
@@ -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 %app_name%_%environment%_db 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 --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,7 +7,7 @@ module UffDbLoader
7
7
  end
8
8
 
9
9
  def self.dump_command_template
10
- "ssh %user%@%host% \"docker exec -i %app_name%_%environment%_db sh -c 'exec pg_dump --username \\$POSTGRES_USER --clean --no-owner --no-acl --format=c %database%'\" > %target%"
10
+ "ssh %user%@%host% \"docker exec -i %container_name% sh -c 'exec pg_dump --username \\$POSTGRES_USER --clean --no-owner --no-acl --format=c %database%'\" > %target%"
11
11
  end
12
12
 
13
13
  def self.restore_command(database_name, result_file_path)
@@ -14,5 +14,6 @@ if defined?(UffDbLoader)
14
14
  # config.app_name = 'my_app' # Defaults to the Rails app name
15
15
  # config.dumps_directory = '/path/to/dumps' # Defaults to Rails.root.join('dumps')
16
16
  # config.database_config_file = 'path/to/database.yml' # Defaults to Rails.root.join('config', 'database.yml')
17
+ # config.container_name = ->(app_name, environment) { "#{app_name}_#{environment}_custom_suffix" } # Defaults to "#{app_name}_#{environment}_db". It accepts a static string too.
17
18
  end
18
19
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module UffDbLoader
4
- VERSION = "2.1.0"
4
+ VERSION = "2.2.0"
5
5
  end
data/lib/uff_db_loader.rb CHANGED
@@ -125,6 +125,13 @@ module UffDbLoader
125
125
 
126
126
  private
127
127
 
128
+ def container_name(environment)
129
+ return "#{config.app_name}_#{environment}_db" if config.container_name.blank?
130
+ return config.container_name unless config.container_name.respond_to? :call
131
+
132
+ config.container_name.call(config.app_name, environment)
133
+ end
134
+
128
135
  def initializer_template_path
129
136
  File.join(__dir__, "uff_db_loader", "templates", "uff_db_loader_initializer.erb")
130
137
  end
@@ -144,12 +151,11 @@ module UffDbLoader
144
151
  config
145
152
  .database_system
146
153
  .dump_command_template
147
- .gsub("%environment%", environment)
148
154
  .gsub("%host%", config.ssh_host)
149
155
  .gsub("%user%", config.ssh_user)
150
156
  .gsub("%database%", config.database)
151
157
  .gsub("%target%", target)
152
- .gsub("%app_name%", config.app_name)
158
+ .gsub("%container_name%", container_name(environment))
153
159
  end
154
160
 
155
161
  def restore_command(database_name, result_file_path)
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: 2.1.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andreas Hellwig
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2022-10-06 00:00:00.000000000 Z
13
+ date: 2023-02-23 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: tty-prompt
@@ -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/2.1.0
91
+ changelog_uri: https://github.com/rmehner/uff_db_loader/releases/tag/2.2.0
92
92
  homepage_uri: https://github.com/rmehner/uff_db_loader
93
- source_code_uri: https://github.com/rmehner/uff_db_loader/tree/2.1.0
93
+ source_code_uri: https://github.com/rmehner/uff_db_loader/tree/2.2.0
94
94
  post_install_message: Please run `bin/rails uff_db_loader:install` to complete the
95
95
  installation.
96
96
  rdoc_options: []
@@ -107,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
107
  - !ruby/object:Gem::Version
108
108
  version: '0'
109
109
  requirements: []
110
- rubygems_version: 3.3.8
110
+ rubygems_version: 3.4.7
111
111
  signing_key:
112
112
  specification_version: 4
113
113
  summary: Allows to dump, download and restore databases from docker servers.