pgchief 0.5.2 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -1
- data/lib/pgchief/command/database_backup.rb +12 -3
- data/lib/pgchief/command/database_privileges_grant.rb +3 -0
- data/lib/pgchief/version.rb +1 -1
- data/lib/pgchief.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c695989f5431e21f2c33b016b34a7197fb5cca9ea62592391fab10fcdbfe385
|
4
|
+
data.tar.gz: 195ab95c85943e54d41455ae25b1458aa538d6bc4b6319685b609de7549504f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 352d1edab7569b64483b3abf178297cf2a213ff1c24dfdc40f39ecd8548a06acfffd650ae30a7284fba34368c15e7d58c09e9f3153e9cfc8657613fa01fe4da0
|
7
|
+
data.tar.gz: e6e5f42192398383a2b8bc481c6a2b5f37722eef72111a04e2250a84bd1ac4125a9e783123ea1b3d4d64d2c3721a177482b3c83fd1bc656cc4d9b564ac2af4fc
|
data/CHANGELOG.md
CHANGED
@@ -13,6 +13,24 @@ and this project will try its best to adhere to [Semantic Versioning](https://se
|
|
13
13
|
|
14
14
|
### Fixes
|
15
15
|
|
16
|
+
## [0.5.3]
|
17
|
+
|
18
|
+
### Additions
|
19
|
+
|
20
|
+
* Add spec for database backup command class.
|
21
|
+
* Add check on the resulting db dump file. Make sure it's > 0 bytes.
|
22
|
+
|
23
|
+
### Changes
|
24
|
+
|
25
|
+
* Allow created users the proper permissions to add PG extensions to a database.
|
26
|
+
|
27
|
+
### Fixes
|
28
|
+
|
29
|
+
* Fix typo in backup command class description.
|
30
|
+
* Fix backup command to use full database connection string to the database when
|
31
|
+
executing the pg_dump command.
|
32
|
+
* Reset s3 config in db backup spec to prevent config leaks from other test runs.
|
33
|
+
|
16
34
|
## [0.5.2]
|
17
35
|
|
18
36
|
### Changes
|
@@ -119,7 +137,8 @@ and this project will try its best to adhere to [Semantic Versioning](https://se
|
|
119
137
|
- Drop user ✅
|
120
138
|
- List databases ✅
|
121
139
|
|
122
|
-
[Unreleased]: https://github.com/jayroh/pgchief/compare/v0.5.
|
140
|
+
[Unreleased]: https://github.com/jayroh/pgchief/compare/v0.5.3...HEAD
|
141
|
+
[0.5.3]: https://github.com/jayroh/pgchief/releases/tag/v0.5.3
|
123
142
|
[0.5.2]: https://github.com/jayroh/pgchief/releases/tag/v0.5.2
|
124
143
|
[0.5.1]: https://github.com/jayroh/pgchief/releases/tag/v0.5.1
|
125
144
|
[0.5.0]: https://github.com/jayroh/pgchief/releases/tag/v0.5.0
|
@@ -4,7 +4,7 @@ require "forwardable"
|
|
4
4
|
|
5
5
|
module Pgchief
|
6
6
|
module Command
|
7
|
-
# Command object to
|
7
|
+
# Command object to back up a database
|
8
8
|
class DatabaseBackup < Base
|
9
9
|
extend Forwardable
|
10
10
|
|
@@ -12,12 +12,17 @@ module Pgchief
|
|
12
12
|
|
13
13
|
attr_reader :database
|
14
14
|
|
15
|
-
def
|
15
|
+
def initialize(*params)
|
16
|
+
super
|
16
17
|
@database = params.first
|
17
18
|
@uploader = Pgchief::Command::S3Upload.new(local_location)
|
19
|
+
end
|
20
|
+
|
21
|
+
def call
|
18
22
|
raise Pgchief::Errors::DatabaseMissingError unless db_exists?
|
19
23
|
|
20
24
|
backup!
|
25
|
+
check_backup!
|
21
26
|
upload! if configured?
|
22
27
|
|
23
28
|
"Database '#{database}' backed up to #{location}"
|
@@ -30,7 +35,11 @@ module Pgchief
|
|
30
35
|
private
|
31
36
|
|
32
37
|
def backup!
|
33
|
-
`pg_dump -Fc #{database} -f #{local_location}`
|
38
|
+
`pg_dump -Fc #{Pgchief::Config.pgurl}/#{database} -f #{local_location}`
|
39
|
+
end
|
40
|
+
|
41
|
+
def check_backup!
|
42
|
+
raise Pgchief::Errors::BackupError, "Backup file has 0 bytes" unless File.size?(local_location)
|
34
43
|
end
|
35
44
|
|
36
45
|
def db_exists?
|
@@ -27,6 +27,9 @@ module Pgchief
|
|
27
27
|
def grant_privs! # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
28
28
|
conn = PG.connect("#{Pgchief::Config.pgurl}/#{database}")
|
29
29
|
conn.exec("GRANT CONNECT ON DATABASE #{database} TO #{username};")
|
30
|
+
conn.exec("GRANT CREATE ON DATABASE #{database} TO #{username};")
|
31
|
+
conn.exec("GRANT USAGE ON SCHEMA pg_catalog TO #{username};")
|
32
|
+
conn.exec("GRANT CREATE ON SCHEMA pg_catalog TO #{username};")
|
30
33
|
conn.exec("GRANT CREATE ON SCHEMA public TO #{username};")
|
31
34
|
conn.exec("GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA public TO #{username};")
|
32
35
|
conn.exec("GRANT USAGE ON SCHEMA public TO #{username};")
|
data/lib/pgchief/version.rb
CHANGED
data/lib/pgchief.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pgchief
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joel Oliveira
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-12-
|
11
|
+
date: 2024-12-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-s3
|