activerecord-dbsnapshot 0.1.2 → 0.1.4
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/lib/activerecord/dbsnapshot/version.rb +1 -1
- data/lib/activerecord/dbsnapshot.rb +8 -8
- data/lib/tasks/snapshot_tasks.rake +2 -2
- 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: e938f0d40cb2cacdee6e945a636dcbe93bbb3afd5551210a73e83ea74dafa6fd
|
4
|
+
data.tar.gz: f77a699645305449f48b13abd797ba389836491f4235c71f60d7485e13d4a55b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de37a86fc51115ffaa646175b6aff1dcf9c5d0389c075d2699315b66cb8c9f591a47b7b3641befc237a914d76dc864b3108967956191b9109a854d3942184cda
|
7
|
+
data.tar.gz: 57928660848cea956f837b9e49c3dc38d3c612e07e466d804c10cc5d24f506b3e1d5cca690398670d4f53cea2f9df89eb89c47eaed874a081a1b0121e6d0ace1
|
@@ -42,7 +42,7 @@ module ActiveRecord
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def build_restore_command(db_config, file)
|
45
|
-
command = "pg_restore"
|
45
|
+
command = "PGPASSWORD=#{db_config[:password]} pg_restore"
|
46
46
|
command << " --host=#{db_config[:host]}" if db_config[:host]
|
47
47
|
command << " --port=#{db_config[:port]}" if db_config[:port]
|
48
48
|
command << " --username=#{db_config[:username]}" if db_config[:username]
|
@@ -56,21 +56,21 @@ module ActiveRecord
|
|
56
56
|
|
57
57
|
# Builds the dump command based on configuration
|
58
58
|
def build_dump_command(config, db_config, output_file)
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
59
|
+
command = "PGPASSWORD=#{db_config[:password]} pg_dump"
|
60
|
+
command << " -U #{db_config[:username]}"
|
61
|
+
command << " -h #{db_config[:host]}"
|
62
|
+
command << " #{db_config[:database]}"
|
63
63
|
|
64
64
|
excluded_tables = config.excluded_tables.map(&:to_s).join(" ")
|
65
65
|
if excluded_tables.empty?
|
66
|
-
return "#{
|
66
|
+
return "#{command} > #{output_file}"
|
67
67
|
else
|
68
68
|
excluded_tables_option = "--exclude-table=" + excluded_tables
|
69
|
-
return "#{
|
69
|
+
return "#{command} #{excluded_tables_option} > #{output_file}"
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
|
-
# Executes the
|
73
|
+
# Executes the command
|
74
74
|
def execute_command(command)
|
75
75
|
system(command)
|
76
76
|
end
|
@@ -25,7 +25,7 @@ namespace :db do
|
|
25
25
|
next
|
26
26
|
end
|
27
27
|
|
28
|
-
db_config = ActiveRecord::Base.
|
28
|
+
db_config = ActiveRecord::Base.connection_db_config.configuration_hash
|
29
29
|
output_file = Rails.root.join('db', 'snapshots', "#{config.snapshot_name}.sql")
|
30
30
|
|
31
31
|
command = ActiveRecord::DbSnapshot.build_dump_command(config, db_config, output_file)
|
@@ -60,7 +60,7 @@ namespace :db do
|
|
60
60
|
end
|
61
61
|
|
62
62
|
# Restore the SQL file into the database
|
63
|
-
db_config = ActiveRecord::Base.
|
63
|
+
db_config = ActiveRecord::Base.connection_db_config.configuration_hash
|
64
64
|
command = ActiveRecord::DbSnapshot.build_restore_command(db_config, filename)
|
65
65
|
ActiveRecord::DbSnapshot.execute_command(command)
|
66
66
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-dbsnapshot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Mammina
|
@@ -56,7 +56,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
56
56
|
- !ruby/object:Gem::Version
|
57
57
|
version: '0'
|
58
58
|
requirements: []
|
59
|
-
rubygems_version: 3.
|
59
|
+
rubygems_version: 3.4.18
|
60
60
|
signing_key:
|
61
61
|
specification_version: 4
|
62
62
|
summary: Dump and Restore database snapshots.
|