osmosis 0.1.5 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -4
- data/lib/osmosis/command.rb +15 -13
- data/lib/osmosis/tasks/db/connect.rake +1 -2
- data/lib/osmosis/tasks/db/export.rake +2 -3
- data/lib/osmosis/tasks/db/import.rake +1 -2
- data/lib/osmosis/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 71ac09cfd040c7360d2933ad76965fe5aa13fdeac749109975b8dbad0d8b313d
|
4
|
+
data.tar.gz: 0b957d2a60d2598bd3ebf2905f1b083031acea53c3c2db8fb95c5686f65d9d84
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2bcc855f967c3f7e355bdcc44e7422066014a5d4e2572000d64663a6a04a75e9241a97579af9be78617cd38593f1d45544c2c834b8fc32406e516bd11e2d4370
|
7
|
+
data.tar.gz: a49afe1e290c5b8c9499ba2d0fa33d0f8c9c0933e7a5bea9dcb90484c4be4d3faf6f6a82beccfbe5b2f423a11aa987694f3dd17e6e2b415e294d8aeaaabbf0b4
|
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'),
|
@@ -25,23 +26,24 @@ module Osmosis
|
|
25
26
|
]
|
26
27
|
end
|
27
28
|
|
28
|
-
def self.export(
|
29
|
-
|
30
|
-
|
31
|
-
|
29
|
+
def self.export()
|
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}'"),
|
41
43
|
]
|
42
44
|
end
|
43
45
|
|
44
|
-
def self.connect(
|
46
|
+
def self.connect()
|
45
47
|
cmd = "PGPASSWORD=#{password} psql -U #{username} -h #{host} -d #{database}"
|
46
48
|
return [
|
47
49
|
OpenStruct.new(type: :pty, command: cmd)
|
data/lib/osmosis/version.rb
CHANGED