osmosis 0.1.4 → 0.1.6
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/README.md +4 -4
- data/lib/osmosis/command.rb +13 -11
- data/lib/osmosis/tasks/db/connect.rake +1 -1
- data/lib/osmosis/tasks/db/export.rake +7 -0
- data/lib/osmosis/tasks/db/import.rake +1 -7
- data/lib/osmosis/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cffa68a75573cf0f38437ec745876d6825a6e7004f5c76c3b2d29f186fda378e
|
4
|
+
data.tar.gz: e109c7e4cb9e993a8923f2e5f3065b00613848aeab47907fe3e6fcaa13122bc4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cb4a72f4f62a9b86642ee82821731ed231b9ca53622da2f3519c1dc7124a7e34096b2a02ecba15603e94071a2b8b83baceaab060b92275dfa601e14f624a362b
|
7
|
+
data.tar.gz: 68fede9c8e52f831302750d5652637efe8a68f3a0f761577e7d539d78c384a07c1407702459bc6c804265db27a5b2fe0e6bcc60e03bab10d2ca7ef75d13fc943
|
data/README.md
CHANGED
@@ -18,18 +18,18 @@ Osmosis provides you with different rake tasks that simplify the management of y
|
|
18
18
|
|
19
19
|
### Database import
|
20
20
|
|
21
|
-
The import command
|
21
|
+
The import command will ask you for a `.dump` file and restores it to the PostgreSQL database. Any pre-existing data is dropped.
|
22
22
|
|
23
23
|
```bash
|
24
|
-
bundle exec rails db:import
|
24
|
+
bundle exec rails db:import
|
25
25
|
```
|
26
26
|
|
27
27
|
### Database export
|
28
28
|
|
29
|
-
The export command exports the PostgreSQL database into
|
29
|
+
The export command will ask you for a `.dump` file and exports the PostgreSQL database into the file. If the file already exists, it is overwritten.
|
30
30
|
|
31
31
|
```bash
|
32
|
-
bundle exec rails db:export
|
32
|
+
bundle exec rails db:export
|
33
33
|
```
|
34
34
|
|
35
35
|
## Development
|
data/lib/osmosis/command.rb
CHANGED
@@ -4,19 +4,20 @@ require 'pty'
|
|
4
4
|
|
5
5
|
module Osmosis
|
6
6
|
class Command
|
7
|
-
def self.import(
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
def self.import()
|
8
|
+
print "Filename: (db.dump): "
|
9
|
+
filename = gets.chomp
|
10
|
+
if filename == ""
|
11
|
+
filename = "db.dump"
|
11
12
|
end
|
12
|
-
if !File.exist?(
|
13
|
-
return [OpenStruct.new(type: :print, command: "File #{
|
13
|
+
if !File.exist?(filename)
|
14
|
+
return [OpenStruct.new(type: :print, command: "File #{filename} does not exist")]
|
14
15
|
end
|
15
16
|
host = ActiveRecord::Base.connection_db_config.host
|
16
17
|
database = ActiveRecord::Base.connection_db_config.database
|
17
18
|
username = ActiveRecord::Base.connection_db_config.configuration_hash[:username]
|
18
19
|
password = ActiveRecord::Base.connection_db_config.configuration_hash[:password]
|
19
|
-
cmd = "PGPASSWORD=#{password} pg_restore -U #{username} -h #{host} -d #{database} -cO --if-exists -w < #{
|
20
|
+
cmd = "PGPASSWORD=#{password} pg_restore -U #{username} -h #{host} -d #{database} -cO --if-exists -w < #{filename}"
|
20
21
|
return [
|
21
22
|
OpenStruct.new(type: :rake, command: 'db:drop'),
|
22
23
|
OpenStruct.new(type: :rake, command: 'db:create'),
|
@@ -26,15 +27,16 @@ module Osmosis
|
|
26
27
|
end
|
27
28
|
|
28
29
|
def self.export(argv)
|
29
|
-
|
30
|
-
|
31
|
-
|
30
|
+
print "Filename: (db.dump): "
|
31
|
+
filename = gets.chomp
|
32
|
+
if filename == ""
|
33
|
+
filename = "db.dump"
|
32
34
|
end
|
33
35
|
host = ActiveRecord::Base.connection_db_config.host
|
34
36
|
database = ActiveRecord::Base.connection_db_config.database
|
35
37
|
username = ActiveRecord::Base.connection_db_config.configuration_hash[:username]
|
36
38
|
password = ActiveRecord::Base.connection_db_config.configuration_hash[:password]
|
37
|
-
cmd = "PGPASSWORD=#{password} pg_dump -Fc --no-acl --no-owner -h #{host} -U #{username} -w #{database} > #{
|
39
|
+
cmd = "PGPASSWORD=#{password} pg_dump -Fc --no-acl --no-owner -h #{host} -U #{username} -w #{database} > #{filename}"
|
38
40
|
return [
|
39
41
|
OpenStruct.new(type: :cmd, command: cmd),
|
40
42
|
OpenStruct.new(type: :print, command: "Exported database '#{database}'"),
|
@@ -1,13 +1,7 @@
|
|
1
1
|
namespace :db do
|
2
2
|
desc "Imports a database from a backup"
|
3
3
|
task import: :environment do
|
4
|
-
commands = Osmosis::Command.import(
|
5
|
-
Osmosis::Command.run(commands)
|
6
|
-
end
|
7
|
-
|
8
|
-
desc "Exports a database to a backup"
|
9
|
-
task import: :environment do
|
10
|
-
commands = Osmosis::Command.export(ARGV)
|
4
|
+
commands = Osmosis::Command.import()
|
11
5
|
Osmosis::Command.run(commands)
|
12
6
|
end
|
13
7
|
end
|
data/lib/osmosis/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: osmosis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lukas_Skywalker
|
@@ -29,6 +29,7 @@ files:
|
|
29
29
|
- lib/osmosis/command.rb
|
30
30
|
- lib/osmosis/railtie.rb
|
31
31
|
- lib/osmosis/tasks/db/connect.rake
|
32
|
+
- lib/osmosis/tasks/db/export.rake
|
32
33
|
- lib/osmosis/tasks/db/import.rake
|
33
34
|
- lib/osmosis/version.rb
|
34
35
|
- sig/osmosis.rbs
|