activerecord-snapshot 0.2.1 → 0.3.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dcf198dbf40940ddc9a3cc50767c89f8f6ca88f3
4
- data.tar.gz: 3e41aa133c618b1f687417596ef836baff755902
3
+ metadata.gz: 2fc3722d4953762ee7d2ac775f11d110f0d6ac4c
4
+ data.tar.gz: d49e4ed6291a1b72a9745c9afe42030fed3d9c4b
5
5
  SHA512:
6
- metadata.gz: 3e19714fd936fa8c671327b006ad08c8d8b2c2c0e20613ea05e36500e8627b19a3c1c24aeb66275e16ae6fae3c7461998f672a3434b70b86e499e3b06d1ee4de
7
- data.tar.gz: 84cba03937050b8ed4ca0efb54420635c2b98ee400e1f7a7b11c962d5dc25411b919a43ee78a65a793fbe1b4cb9834352cfc19e19a83971e96d96892f8f1de84
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
- ##### `db:snapshot:list:load[n]`
121
+ Can be given arguments for amount of entries to show:
93
122
 
94
- Shows a list of the last `n` snapshots
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
- property :db, default: ->(_) { ::Rails.application.config.database_configuration[Rails.env] }, coerce: DBConfig
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
@@ -1,5 +1,5 @@
1
1
  module ActiveRecord
2
2
  module Snapshot
3
- VERSION = '0.2.1'
3
+ VERSION = '0.3.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-snapshot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bernardo Farah