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 +4 -4
- data/README.md +1 -0
- data/lib/configuration.rb +12 -1
- data/lib/uff_db_loader/mysql.rb +1 -1
- data/lib/uff_db_loader/postgresql.rb +1 -1
- data/lib/uff_db_loader/templates/uff_db_loader_initializer.erb +1 -0
- data/lib/uff_db_loader/version.rb +1 -1
- data/lib/uff_db_loader.rb +8 -2
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a2c7c42ed0513c36d938f46d9346c462ec22e978ed234f519d9825eb8701c8f
|
4
|
+
data.tar.gz: 6036d5f67b2447a2e747b6b242d4a69a96730c57f5ce45a01d618d4af91085a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
data/lib/uff_db_loader/mysql.rb
CHANGED
@@ -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 %
|
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 %
|
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
|
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("%
|
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.
|
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:
|
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.
|
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.
|
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.
|
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.
|