uff_db_loader 1.1.1 → 1.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 -1
- data/lib/uff_db_loader/tasks/remote_database.rake +6 -31
- data/lib/uff_db_loader/tasks/uff_db_loader.rake +48 -0
- data/lib/uff_db_loader/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7bd8cbc61f1a00104d4331da35c5e46cd08d3458977a8b59f2f16bd97ff1d9f3
|
4
|
+
data.tar.gz: c164595210489cc21d090672c3ff2e571184440a1a1aeb7810e070ad976d6ad4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c63cf3e6671df456a8a5094505e28151d4c98c9410b920742ca685c91ecf683167471ad6c91d16f43dcac97e0f93f9b7ed21e784cb9f8d808fd36f3ab15544b
|
7
|
+
data.tar.gz: bd6e2f2f5b5ea9e5d95dd7e2fe3eb40280d52d7b2803601f71fe3daa4f5b5edb3921fe7ddabd9e0868662457c30d760a5ef63920c2881443c59ff01d963c1216
|
data/README.md
CHANGED
@@ -43,7 +43,7 @@ Make sure the app's database user has the superuser role. Otherwise the app will
|
|
43
43
|
|
44
44
|
## Usage
|
45
45
|
|
46
|
-
`uff_db_loader` provides `rails
|
46
|
+
`uff_db_loader` provides `rails uff_db_loader:dump` and `rails uff_db_loader:load` which will prompt for a configured environment.
|
47
47
|
`dump` will only create and download a current database dump, while `load`, will do the same and restore the database content into a new database and gives instructions on how to use it in development.
|
48
48
|
|
49
49
|
|
@@ -5,44 +5,19 @@ require "tty-prompt"
|
|
5
5
|
namespace :remote_database do
|
6
6
|
desc "Dumps a remote database to #{UffDbLoader.config.dumps_directory}"
|
7
7
|
task dump: :environment do
|
8
|
-
|
9
|
-
|
10
|
-
UffDbLoader.ensure_valid_environment!(environment)
|
11
|
-
UffDbLoader.dump_from(environment)
|
8
|
+
puts "🧐 Please note this task is called 'uff_db_loader:dump' now."
|
9
|
+
Rake::Task["uff_db_loader:dump"].invoke
|
12
10
|
end
|
13
11
|
|
14
12
|
desc "Gets a dump from remote and loads it into the local database"
|
15
13
|
task load: :environment do
|
16
|
-
|
17
|
-
|
18
|
-
UffDbLoader.ensure_valid_environment!(environment)
|
19
|
-
result_file_path = UffDbLoader.dump_from(environment)
|
20
|
-
|
21
|
-
puts "🤓 Reading from to #{result_file_path}"
|
22
|
-
|
23
|
-
database_name = File.basename(result_file_path, ".*")
|
24
|
-
UffDbLoader.create_database(database_name)
|
25
|
-
|
26
|
-
puts "🗂 Created database #{database_name}"
|
27
|
-
|
28
|
-
command_successful = system(UffDbLoader.restore_command(database_name, result_file_path))
|
29
|
-
raise "Command did not run succesful: #{UffDbLoader.restore_command(database_name, result_file_path)}" unless command_successful
|
30
|
-
|
31
|
-
puts "✅ Succesfully loaded #{result_file_path} into #{database_name}"
|
32
|
-
|
33
|
-
puts "💩 Because YAML is a wonderful format, you need to adapt your config file by hand."
|
34
|
-
puts "🆗 Go to #{UffDbLoader.config.database_config_file} and change the development database value to: #{database_name}"
|
35
|
-
puts "🧑🏾🏫 Don't forgot to restart the Rails server after changing the database config (`rails restart`)"
|
14
|
+
puts "🧐 Please note this task is called 'uff_db_loader:load' now."
|
15
|
+
Rake::Task["uff_db_loader:load"].invoke
|
36
16
|
end
|
37
17
|
|
38
18
|
desc "Delete all downloaded db dumps and emove all databases created by UffDbLoader"
|
39
19
|
task prune: :environment do
|
40
|
-
|
41
|
-
|
42
|
-
UffDbLoader.drop_database(database_name)
|
43
|
-
end
|
44
|
-
|
45
|
-
puts "Removing dumps from #{UffDbLoader.config.dumps_directory}"
|
46
|
-
UffDbLoader.prune_dump_directory
|
20
|
+
puts "🧐 Please note this task is called 'uff_db_loader:prune' now."
|
21
|
+
Rake::Task["uff_db_loader:prune"].invoke
|
47
22
|
end
|
48
23
|
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "tty-prompt"
|
4
|
+
|
5
|
+
namespace :uff_db_loader do
|
6
|
+
desc "Dumps a remote database to #{UffDbLoader.config.dumps_directory}"
|
7
|
+
task dump: :environment do
|
8
|
+
prompt = TTY::Prompt.new
|
9
|
+
environment = prompt.select("Which environment should we get the dump from?", UffDbLoader.config.environments)
|
10
|
+
UffDbLoader.ensure_valid_environment!(environment)
|
11
|
+
UffDbLoader.dump_from(environment)
|
12
|
+
end
|
13
|
+
|
14
|
+
desc "Gets a dump from remote and loads it into the local database"
|
15
|
+
task load: :environment do
|
16
|
+
prompt = TTY::Prompt.new
|
17
|
+
environment = prompt.select("Which environment should we get the dump from?", UffDbLoader.config.environments)
|
18
|
+
UffDbLoader.ensure_valid_environment!(environment)
|
19
|
+
result_file_path = UffDbLoader.dump_from(environment)
|
20
|
+
|
21
|
+
puts "🤓 Reading from to #{result_file_path}"
|
22
|
+
|
23
|
+
database_name = File.basename(result_file_path, ".*")
|
24
|
+
UffDbLoader.create_database(database_name)
|
25
|
+
|
26
|
+
puts "🗂 Created database #{database_name}"
|
27
|
+
|
28
|
+
command_successful = system(UffDbLoader.restore_command(database_name, result_file_path))
|
29
|
+
raise "Command did not run succesful: #{UffDbLoader.restore_command(database_name, result_file_path)}" unless command_successful
|
30
|
+
|
31
|
+
puts "✅ Succesfully loaded #{result_file_path} into #{database_name}"
|
32
|
+
|
33
|
+
puts "💩 Because YAML is a wonderful format, you need to adapt your config file by hand."
|
34
|
+
puts "🆗 Go to #{UffDbLoader.config.database_config_file} and change the development database value to: #{database_name}"
|
35
|
+
puts "🧑🏾🏫 Don't forgot to restart the Rails server after changing the database config (`rails restart`)"
|
36
|
+
end
|
37
|
+
|
38
|
+
desc "Delete all downloaded db dumps and emove all databases created by UffDbLoader"
|
39
|
+
task prune: :environment do
|
40
|
+
UffDbLoader.databases.each do |database_name|
|
41
|
+
puts "Dropping #{database_name}"
|
42
|
+
UffDbLoader.drop_database(database_name)
|
43
|
+
end
|
44
|
+
|
45
|
+
puts "Removing dumps from #{UffDbLoader.config.dumps_directory}"
|
46
|
+
UffDbLoader.prune_dump_directory
|
47
|
+
end
|
48
|
+
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: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andreas Hellwig
|
@@ -80,6 +80,7 @@ files:
|
|
80
80
|
- lib/uff_db_loader/mysql.rb
|
81
81
|
- lib/uff_db_loader/postgresql.rb
|
82
82
|
- lib/uff_db_loader/tasks/remote_database.rake
|
83
|
+
- lib/uff_db_loader/tasks/uff_db_loader.rake
|
83
84
|
- lib/uff_db_loader/version.rb
|
84
85
|
- uff_db_loader.gemspec
|
85
86
|
homepage: https://github.com/rmehner/uff_db_loader
|
@@ -87,9 +88,9 @@ licenses:
|
|
87
88
|
- MIT
|
88
89
|
metadata:
|
89
90
|
bug_tracker_uri: https://github.com/rmehner/uff_db_loader/issues
|
90
|
-
changelog_uri: https://github.com/rmehner/uff_db_loader/releases/tag/1.
|
91
|
+
changelog_uri: https://github.com/rmehner/uff_db_loader/releases/tag/1.2.0
|
91
92
|
homepage_uri: https://github.com/rmehner/uff_db_loader
|
92
|
-
source_code_uri: https://github.com/rmehner/uff_db_loader/tree/1.
|
93
|
+
source_code_uri: https://github.com/rmehner/uff_db_loader/tree/1.2.0
|
93
94
|
post_install_message:
|
94
95
|
rdoc_options: []
|
95
96
|
require_paths:
|