activerecord-snapshot 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +31 -2
- data/lib/active_record/snapshot/configuration.rb +5 -1
- data/lib/active_record/snapshot/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2fc3722d4953762ee7d2ac775f11d110f0d6ac4c
|
4
|
+
data.tar.gz: d49e4ed6291a1b72a9745c9afe42030fed3d9c4b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1029fe16710bc94994d9f8b258e4c05724f71ac7125afe932f3618dc0a1bba10332997a109bbd21e53f1a46b4eb263463bdd8a3048a6d11c42d0166c6ff7d202
|
7
|
+
data.tar.gz: 76c8ad1ace91656a1b7d8c4fc150e9bb922dd153e885ae6fc4535c44f6abc437d6437bc6dc9af222396a465ef7a262e89fdb6619469f935806a9e209c411cc25
|
data/README.md
CHANGED
@@ -47,6 +47,35 @@ tables:
|
|
47
47
|
- "example_table"
|
48
48
|
```
|
49
49
|
|
50
|
+
##### Database
|
51
|
+
|
52
|
+
Database configuration happens in your normal `config/database.yml`. If you want
|
53
|
+
a database configuration that is NOT tied to your Rails environment, you can run
|
54
|
+
these tasks with `SNAPSHOT_ENV` set, and that will override where in the
|
55
|
+
`config/database.yml` it looks. For example:
|
56
|
+
|
57
|
+
|
58
|
+
With this config file:
|
59
|
+
|
60
|
+
```yml
|
61
|
+
# config/database.yml
|
62
|
+
production:
|
63
|
+
username: root
|
64
|
+
password: secret
|
65
|
+
|
66
|
+
snapshot:
|
67
|
+
username: readonly
|
68
|
+
password: secret
|
69
|
+
```
|
70
|
+
|
71
|
+
Running the below:
|
72
|
+
|
73
|
+
```
|
74
|
+
SNAPSHOT_ENV=snapshot bundle exec rake db:snapshot:create
|
75
|
+
```
|
76
|
+
|
77
|
+
It will use `readonly` instead of the `root` user.
|
78
|
+
|
50
79
|
### Tasks
|
51
80
|
|
52
81
|
##### `db:snapshot:create`
|
@@ -89,9 +118,9 @@ Reloads the current snapshot
|
|
89
118
|
|
90
119
|
Shows a list of snapshots
|
91
120
|
|
92
|
-
|
121
|
+
Can be given arguments for amount of entries to show:
|
93
122
|
|
94
|
-
|
123
|
+
`db:snapshot:list[5]` will show the last 5 snapshots
|
95
124
|
|
96
125
|
## Installation
|
97
126
|
Add this line to your application's Gemfile:
|
@@ -52,7 +52,11 @@ module ActiveRecord
|
|
52
52
|
include Hashie::Extensions::Dash::Coercion
|
53
53
|
include Hashie::Extensions::Dash::IndifferentAccess
|
54
54
|
|
55
|
-
|
55
|
+
def self.env
|
56
|
+
ENV.fetch("SNAPSHOT_ENV", Rails.env)
|
57
|
+
end
|
58
|
+
|
59
|
+
property :db, default: ->(_) { ::Rails.application.config.database_configuration[env] }, coerce: DBConfig
|
56
60
|
property :s3, required: true, coerce: S3Config
|
57
61
|
property :ssl_key, required: true
|
58
62
|
property :tables, required: true
|