activerecord-snapshot 0.3.3 → 0.6.1.jcprepermissions.1
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 +5 -5
- data/README.md +2 -0
- data/lib/active_record/snapshot/actions/import.rb +6 -0
- data/lib/active_record/snapshot/commands/mysql.rb +2 -2
- data/lib/active_record/snapshot/commands/openssl.rb +2 -2
- data/lib/active_record/snapshot/files/version.rb +9 -1
- data/lib/active_record/snapshot/version.rb +1 -1
- data/lib/tasks/active_record/snapshot_tasks.rake +3 -1
- metadata +25 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ecd3e15ae6586b3905c854f832bcd25cc5f85dc92e065b0764127fba0bf56331
|
4
|
+
data.tar.gz: 4db3d8674e0904efecf22cc7e1091d14f06b6726eff72b4b55837a8a158ee64d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: af758ef076b71ee00025adec5727532f563b0b4cfdcdf53e80dc25c2795ba05fcbd1308518faf1d2ec520bf066ef989eca9b72fa72a9e22088dddfd3008d26ae
|
7
|
+
data.tar.gz: 57ff38c3f192c03334790452f29ebb42657c72c357efffe297809ceb6f87bda82474fb2464911e87c110b8749756bc6f7feddbf117fbd83748fe8232656dae46
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# ActiveRecord::Snapshot
|
2
2
|
|
3
|
+
[](https://travis-ci.org/coverhound/activerecord-snapshot)
|
4
|
+
|
3
5
|
This gem provides rake tasks to create and import MySQL snapshots using S3. This
|
4
6
|
is pretty specialized for how CoverHound uses snapshots.
|
5
7
|
|
@@ -52,6 +52,8 @@ module ActiveRecord
|
|
52
52
|
|
53
53
|
steps[:import] = "Importing the snapshot into #{config.db.database}"
|
54
54
|
steps[:save] = "Caching the new snapshot version" unless named_version? || tables.present?
|
55
|
+
steps[:set_env] = "Setting database environment to #{Rails.env}" if Rails::VERSION::MAJOR >= 5
|
56
|
+
|
55
57
|
steps
|
56
58
|
end
|
57
59
|
|
@@ -84,6 +86,10 @@ module ActiveRecord
|
|
84
86
|
Rake::Task["db:schema:dump"].invoke
|
85
87
|
end
|
86
88
|
|
89
|
+
def set_env
|
90
|
+
Rake::Task["db:environment:set"].invoke
|
91
|
+
end
|
92
|
+
|
87
93
|
def save
|
88
94
|
Version.write(version)
|
89
95
|
end
|
@@ -8,8 +8,8 @@ module ActiveRecord
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def dump(tables:, output:)
|
11
|
-
dump_command("--no-data #{database} > #{output}") &&
|
12
|
-
dump_command("--quick #{database} #{tables.join(" ")} >> #{output}")
|
11
|
+
dump_command("--no-data --set-gtid-purged=OFF #{database} > #{output}") &&
|
12
|
+
dump_command("--quick --set-gtid-purged=OFF #{database} #{tables.join(" ")} >> #{output}")
|
13
13
|
end
|
14
14
|
|
15
15
|
def self.import(*args)
|
@@ -3,7 +3,7 @@ module ActiveRecord
|
|
3
3
|
class OpenSSL
|
4
4
|
def self.encrypt(input:, output:)
|
5
5
|
system(<<-SH)
|
6
|
-
nice openssl aes-256-cbc \\
|
6
|
+
nice openssl aes-256-cbc -md sha256 \\
|
7
7
|
-in #{input} \\
|
8
8
|
-out #{output} \\
|
9
9
|
-kfile #{ActiveRecord::Snapshot.config.ssl_key}
|
@@ -12,7 +12,7 @@ module ActiveRecord
|
|
12
12
|
|
13
13
|
def self.decrypt(input:, output:)
|
14
14
|
system(<<-SH)
|
15
|
-
nice openssl enc -d -aes-256-cbc \\
|
15
|
+
nice openssl enc -d -aes-256-cbc -md sha256 \\
|
16
16
|
-in #{input} \\
|
17
17
|
-out #{output} \\
|
18
18
|
-kfile #{ActiveRecord::Snapshot.config.ssl_key}
|
@@ -20,8 +20,12 @@ module ActiveRecord
|
|
20
20
|
File.write(path, version)
|
21
21
|
end
|
22
22
|
|
23
|
+
def download
|
24
|
+
s3.download_to(path)
|
25
|
+
end
|
26
|
+
|
23
27
|
def upload
|
24
|
-
|
28
|
+
s3.upload(path)
|
25
29
|
end
|
26
30
|
|
27
31
|
def filename
|
@@ -34,6 +38,10 @@ module ActiveRecord
|
|
34
38
|
|
35
39
|
private
|
36
40
|
|
41
|
+
def s3
|
42
|
+
S3.new(directory: config.s3.paths.snapshots)
|
43
|
+
end
|
44
|
+
|
37
45
|
def config
|
38
46
|
ActiveRecord::Snapshot.config
|
39
47
|
end
|
@@ -3,6 +3,8 @@ namespace :db do
|
|
3
3
|
desc "Create a snapshot of the current database and store it in S3"
|
4
4
|
task create: :load do
|
5
5
|
abort "Meant for production only!" unless Rails.env.production?
|
6
|
+
ActiveRecord::Snapshot::List.download
|
7
|
+
ActiveRecord::Snapshot::Version.download
|
6
8
|
ActiveRecord::Snapshot::Create.call
|
7
9
|
end
|
8
10
|
|
@@ -23,7 +25,7 @@ namespace :db do
|
|
23
25
|
|
24
26
|
desc "Import production database snapshot."
|
25
27
|
task :import, [:version] => [:load] do |_t, args|
|
26
|
-
abort "Do not run in
|
28
|
+
abort "Do not run in production mode!" if Rails.env.production?
|
27
29
|
version = args.fetch(:version, "").strip
|
28
30
|
ActiveRecord::Snapshot::Import.call(version: version)
|
29
31
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-snapshot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.1.jcprepermissions.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bernardo Farah
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-04-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -58,6 +58,26 @@ dependencies:
|
|
58
58
|
- - ">="
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: 3.4.3
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: mime-types
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '1.16'
|
68
|
+
- - "<"
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '4'
|
71
|
+
type: :runtime
|
72
|
+
prerelease: false
|
73
|
+
version_requirements: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '1.16'
|
78
|
+
- - "<"
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '4'
|
61
81
|
- !ruby/object:Gem::Dependency
|
62
82
|
name: mocha
|
63
83
|
requirement: !ruby/object:Gem::Requirement
|
@@ -149,12 +169,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
149
169
|
version: '0'
|
150
170
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
151
171
|
requirements:
|
152
|
-
- - "
|
172
|
+
- - ">"
|
153
173
|
- !ruby/object:Gem::Version
|
154
|
-
version:
|
174
|
+
version: 1.3.1
|
155
175
|
requirements: []
|
156
|
-
|
157
|
-
rubygems_version: 2.6.12
|
176
|
+
rubygems_version: 3.0.3
|
158
177
|
signing_key:
|
159
178
|
specification_version: 4
|
160
179
|
summary: Snapshots for ActiveRecord
|