data_keeper 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/data_keeper/loader.rb +19 -12
- data/lib/data_keeper/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2fc356b01f1619f2ec815a556092bd13fc28b44b2b201707c6a820da00fcff70
|
4
|
+
data.tar.gz: 8f2d4dcc59035b7fee1131daa3cfed6dedb0bf5c635e781d48dc65c7c43a58e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5102f1e716045e8bc425d69c71b03c8cad46b805d3caf7db12a0eb9ff073f53c1c94cebfd70a9909b8d806f543c66e1ecd7f3c3d3d344a688bacf8bdf6d2f3f5
|
7
|
+
data.tar.gz: 0b4459b6441c79cb3768fa769271ccb7661f458cf4f69b75562a4fc92ebfa2e28502bf294102689112b399cf97938c25ee703775444132f39c2a38e6d402bfa4
|
data/lib/data_keeper/loader.rb
CHANGED
@@ -7,6 +7,9 @@ module DataKeeper
|
|
7
7
|
def initialize(dump, file)
|
8
8
|
@dump = dump
|
9
9
|
@file = file
|
10
|
+
@psql_version = Terrapin::CommandLine.new('psql', '--version').run
|
11
|
+
.match(/[0-9]{1,}\.[0-9]{1,}/)
|
12
|
+
.to_s.to_f
|
10
13
|
end
|
11
14
|
|
12
15
|
def load!
|
@@ -24,12 +27,7 @@ module DataKeeper
|
|
24
27
|
private
|
25
28
|
|
26
29
|
def load_full_database!
|
27
|
-
|
28
|
-
'psql',
|
29
|
-
"#{connection_args} -d :database -c :command",
|
30
|
-
environment: psql_env
|
31
|
-
)
|
32
|
-
cmd.run(database: database, host: host, port: port, command: "drop schema if exists public")
|
30
|
+
ensure_schema_compatibility!
|
33
31
|
|
34
32
|
pg_restore = Terrapin::CommandLine.new(
|
35
33
|
'pg_restore',
|
@@ -59,12 +57,7 @@ module DataKeeper
|
|
59
57
|
|
60
58
|
def load_partial_database!
|
61
59
|
inflate(@file.path) do |schema_path, tables_path, sql_files|
|
62
|
-
|
63
|
-
'psql',
|
64
|
-
"#{connection_args} -d :database -c :command",
|
65
|
-
environment: psql_env
|
66
|
-
)
|
67
|
-
cmd.run(database: database, host: host, port: port, command: "drop schema if exists public")
|
60
|
+
ensure_schema_compatibility!
|
68
61
|
|
69
62
|
pg_restore = Terrapin::CommandLine.new(
|
70
63
|
'pg_restore',
|
@@ -110,6 +103,20 @@ module DataKeeper
|
|
110
103
|
end
|
111
104
|
end
|
112
105
|
|
106
|
+
def ensure_schema_compatibility!
|
107
|
+
cmd = Terrapin::CommandLine.new(
|
108
|
+
'psql',
|
109
|
+
"#{connection_args} -d :database -c :command",
|
110
|
+
environment: psql_env
|
111
|
+
)
|
112
|
+
|
113
|
+
if @psql_version >= 11.0
|
114
|
+
cmd.run(database: database, host: host, port: port, command: "drop schema if exists public")
|
115
|
+
else
|
116
|
+
cmd.run(database: database, host: host, port: port, command: "create schema if not exists public")
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
113
120
|
class InflatedFiles
|
114
121
|
attr_reader :errors
|
115
122
|
|
data/lib/data_keeper/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: data_keeper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roger Campos
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-09-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -115,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
115
115
|
- !ruby/object:Gem::Version
|
116
116
|
version: '0'
|
117
117
|
requirements: []
|
118
|
-
rubygems_version: 3.
|
118
|
+
rubygems_version: 3.1.6
|
119
119
|
signing_key:
|
120
120
|
specification_version: 4
|
121
121
|
summary: Easy management of database dumps for dev env
|