uff_db_loader 3.2.0 → 4.0.0
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 +4 -4
- data/.github/workflows/test.yml +11 -11
- data/README.md +5 -0
- data/lib/configuration.rb +3 -1
- data/lib/uff_db_loader/mysql.rb +6 -2
- data/lib/uff_db_loader/postgresql.rb +7 -3
- data/lib/uff_db_loader/tasks/uff_db_loader.rake +11 -0
- data/lib/uff_db_loader/templates/uff_db_loader_initializer.erb +1 -1
- data/lib/uff_db_loader/version.rb +1 -1
- data/lib/uff_db_loader.rb +7 -1
- metadata +5 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: '060096b6203e8ec9ad703842bd1a0c8e54a8ac83bb242316b9d4e1943f3ac293'
|
|
4
|
+
data.tar.gz: 9957904bdfdd43ad6562d96e7d5cbb6b5fdc4e1c610687fcb11aff706707d051
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dc35bb6b7d806afdd007acbc131651fa232d904fdc8ff51f2253fd4d9e45002e37ab01d93e0aa8823b25d2e386a1c7ba65ce25ad9170a0f4e35b10abf67079b7
|
|
7
|
+
data.tar.gz: fb6f49b13663d44312fc38ba118b7b140c38ed7ab2bb99f38dc37619e500aee1ad1137b332f0a5460f5346791d66a1885153385edc72819175419df6146b0c8d
|
data/.github/workflows/test.yml
CHANGED
|
@@ -2,9 +2,9 @@ name: Test
|
|
|
2
2
|
|
|
3
3
|
on:
|
|
4
4
|
push:
|
|
5
|
-
branches: [
|
|
5
|
+
branches: ["main"]
|
|
6
6
|
pull_request:
|
|
7
|
-
branches: [
|
|
7
|
+
branches: ["main"]
|
|
8
8
|
|
|
9
9
|
permissions:
|
|
10
10
|
contents: read
|
|
@@ -14,14 +14,14 @@ jobs:
|
|
|
14
14
|
runs-on: ubuntu-latest
|
|
15
15
|
strategy:
|
|
16
16
|
matrix:
|
|
17
|
-
ruby-version: [
|
|
17
|
+
ruby-version: ["3.0", "3.1", "3.2", "3.3", "3.4", "4.0"]
|
|
18
18
|
|
|
19
19
|
steps:
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
20
|
+
- uses: actions/checkout@v6
|
|
21
|
+
- name: Set up Ruby
|
|
22
|
+
uses: ruby/setup-ruby@v1
|
|
23
|
+
with:
|
|
24
|
+
ruby-version: ${{ matrix.ruby-version }}
|
|
25
|
+
bundler-cache: true
|
|
26
|
+
- name: Run tests
|
|
27
|
+
run: bundle exec rake
|
data/README.md
CHANGED
|
@@ -27,6 +27,7 @@ Run the installation script:
|
|
|
27
27
|
## Configuration
|
|
28
28
|
|
|
29
29
|
You can configure the gem by running the following during the initialization of the Rails app:
|
|
30
|
+
|
|
30
31
|
```ruby
|
|
31
32
|
UffDbLoader.configure do |config|
|
|
32
33
|
config.environments = ['staging', 'production']
|
|
@@ -38,8 +39,11 @@ UffDbLoader.configure do |config|
|
|
|
38
39
|
config.dumps_directory = '/path/to/dumps' # Defaults to Rails.root.join('dumps')
|
|
39
40
|
config.database_config_file = 'path/to/database.yml' # Defaults to Rails.root.join('config', 'database.yml')
|
|
40
41
|
config.container_name = ->(app_name, environment) { "#{app_name}_#{environment}_custom_suffix" } # Defaults to "#{app_name}_#{environment}_db". It accepts a static string too.
|
|
42
|
+
config.local_restore_command_path = '' # Sets the path to the db-cli (pg_restore, mysql). Defaults to nil so it's using the default binary (mysql, pg_dump) in $PATH.
|
|
43
|
+
config.restore_command_template = '%command% --jobs=4 --dbname %database% %file%' # Customize the restore command. Available placeholders: %command% (e.g. `pg_restore`), %database%, %file%. Defaults to the database system's template.
|
|
41
44
|
end
|
|
42
45
|
```
|
|
46
|
+
|
|
43
47
|
For example in a file like `config/initializers/uff_db_loader.rb`.
|
|
44
48
|
|
|
45
49
|
Make sure the app's database user has the superuser role. Otherwise the app will crash on startup due to missing permissions.
|
|
@@ -54,6 +58,7 @@ Make sure the app's database user has the superuser role. Otherwise the app will
|
|
|
54
58
|
- `switch_to_default`: Switches database back to the default development database
|
|
55
59
|
- `load`: Dumps a remote database from a selected environment and downloads it then restores and selects the database
|
|
56
60
|
- `prune`: Delete all downloaded db dumps and removes all databases created by UffDbLoader
|
|
61
|
+
- `current`: Shows the currently connected database and the one UffDbLoader has selected
|
|
57
62
|
|
|
58
63
|
## Development
|
|
59
64
|
|
data/lib/configuration.rb
CHANGED
|
@@ -15,7 +15,8 @@ module UffDbLoader
|
|
|
15
15
|
:dumps_directory,
|
|
16
16
|
:database_config_file,
|
|
17
17
|
:container_name,
|
|
18
|
-
:local_restore_command_path
|
|
18
|
+
:local_restore_command_path,
|
|
19
|
+
:restore_command_template
|
|
19
20
|
)
|
|
20
21
|
|
|
21
22
|
def initialize
|
|
@@ -29,6 +30,7 @@ module UffDbLoader
|
|
|
29
30
|
@database_config_file = File.join(Dir.pwd, "config", "database.yml")
|
|
30
31
|
@container_name = nil
|
|
31
32
|
@local_restore_command_path = nil
|
|
33
|
+
@restore_command_template = nil
|
|
32
34
|
end
|
|
33
35
|
|
|
34
36
|
def database
|
data/lib/uff_db_loader/mysql.rb
CHANGED
|
@@ -10,8 +10,12 @@ module UffDbLoader
|
|
|
10
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
|
-
def self.
|
|
14
|
-
"
|
|
13
|
+
def self.restore_command_template
|
|
14
|
+
"%command% -uroot %database% < %file%"
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def self.default_restore_command
|
|
18
|
+
"mysql"
|
|
15
19
|
end
|
|
16
20
|
|
|
17
21
|
def self.list_databases
|
|
@@ -7,11 +7,15 @@ 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 pg_dump --username \\$POSTGRES_USER --
|
|
10
|
+
"ssh %user%@%host% \"docker exec -i %container_name% sh -c 'exec pg_dump --username \\$POSTGRES_USER --no-owner --no-acl --format=c %database%'\" > %target%"
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
-
def self.
|
|
14
|
-
"
|
|
13
|
+
def self.restore_command_template
|
|
14
|
+
"%command% --username postgres --no-owner --no-acl --dbname %database% %file%"
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def self.default_restore_command
|
|
18
|
+
"pg_restore"
|
|
15
19
|
end
|
|
16
20
|
|
|
17
21
|
def self.list_databases
|
|
@@ -89,4 +89,15 @@ namespace :uff_db_loader do
|
|
|
89
89
|
|
|
90
90
|
UffDbLoader.log "♻️ Restarted rails server with default database."
|
|
91
91
|
end
|
|
92
|
+
|
|
93
|
+
desc "Shows the currently selected and connected database"
|
|
94
|
+
task current: :environment do
|
|
95
|
+
UffDbLoader.ensure_installation!
|
|
96
|
+
selected_database = UffDbLoader.current_database_name
|
|
97
|
+
|
|
98
|
+
UffDbLoader.log "Active Record connected to: #{ActiveRecord::Base.connection.current_database}"
|
|
99
|
+
unless selected_database.nil?
|
|
100
|
+
UffDbLoader.log "Selected database: #{selected_database}"
|
|
101
|
+
end
|
|
102
|
+
end
|
|
92
103
|
end
|
|
@@ -15,6 +15,6 @@ if defined?(UffDbLoader)
|
|
|
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
17
|
# config.container_name = ->(app_name, environment) { "#{app_name}_#{environment}_custom_suffix" } # Defaults to "#{app_name}_#{environment}_db". It accepts a static string too.
|
|
18
|
-
# config.local_restore_command_path = '' # Sets the path to the db-cli (pg_restore, mysql). Defaults to nil so it
|
|
18
|
+
# config.local_restore_command_path = '' # Sets the path to the db-cli (pg_restore, mysql). Defaults to nil so it's using the default binary (mysql, pg_dump) in $PATH.
|
|
19
19
|
end
|
|
20
20
|
end
|
data/lib/uff_db_loader.rb
CHANGED
|
@@ -177,7 +177,13 @@ module UffDbLoader
|
|
|
177
177
|
end
|
|
178
178
|
|
|
179
179
|
def restore_command(database_name, result_file_path)
|
|
180
|
-
config.
|
|
180
|
+
template = config.restore_command_template || config.database_system.restore_command_template
|
|
181
|
+
command = config.local_restore_command_path || config.database_system.default_restore_command
|
|
182
|
+
|
|
183
|
+
template
|
|
184
|
+
.gsub("%command%", command)
|
|
185
|
+
.gsub("%database%", database_name)
|
|
186
|
+
.gsub("%file%", result_file_path)
|
|
181
187
|
end
|
|
182
188
|
|
|
183
189
|
def database_name_template(old_database_name)
|
metadata
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: uff_db_loader
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 4.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Andreas Hellwig
|
|
8
8
|
- Fynn Heintz
|
|
9
9
|
- Robin Mehner
|
|
10
|
-
autorequire:
|
|
11
10
|
bindir: exe
|
|
12
11
|
cert_chain: []
|
|
13
|
-
date:
|
|
12
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
14
13
|
dependencies:
|
|
15
14
|
- !ruby/object:Gem::Dependency
|
|
16
15
|
name: tty-prompt
|
|
@@ -88,9 +87,9 @@ licenses:
|
|
|
88
87
|
- MIT
|
|
89
88
|
metadata:
|
|
90
89
|
bug_tracker_uri: https://github.com/rmehner/uff_db_loader/issues
|
|
91
|
-
changelog_uri: https://github.com/rmehner/uff_db_loader/releases/tag/
|
|
90
|
+
changelog_uri: https://github.com/rmehner/uff_db_loader/releases/tag/4.0.0
|
|
92
91
|
homepage_uri: https://github.com/rmehner/uff_db_loader
|
|
93
|
-
source_code_uri: https://github.com/rmehner/uff_db_loader/tree/
|
|
92
|
+
source_code_uri: https://github.com/rmehner/uff_db_loader/tree/4.0.0
|
|
94
93
|
post_install_message: Please run `bin/rails uff_db_loader:install` to complete the
|
|
95
94
|
installation.
|
|
96
95
|
rdoc_options: []
|
|
@@ -107,8 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
107
106
|
- !ruby/object:Gem::Version
|
|
108
107
|
version: '0'
|
|
109
108
|
requirements: []
|
|
110
|
-
rubygems_version: 3.
|
|
111
|
-
signing_key:
|
|
109
|
+
rubygems_version: 3.6.9
|
|
112
110
|
specification_version: 4
|
|
113
111
|
summary: Allows to dump, download and restore databases from docker servers.
|
|
114
112
|
test_files: []
|