historiographer 1.0.0 → 1.0.2
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/Gemfile +1 -1
- data/Gemfile.lock +18 -12
- data/README.md +12 -12
- data/VERSION +1 -1
- data/historiographer.gemspec +3 -3
- data/lib/historiographer/mysql_migration.rb +4 -0
- data/lib/historiographer/postgres_migration.rb +4 -0
- 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: e2afe07a84787befbaa291bd59589fdc5157b4ee1866e02c009897a2505d90e3
|
4
|
+
data.tar.gz: 1993b158d8598ae6c1322325021b5d0c98aa3abbbafeb776f91ff7535c01e813
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4bed70d409e600188ead5dd3a39d68af95cf9053ee982e8355607b5ad77240d222ec580d92fc593d9776b0c60b16dc8125df7db832e5903e01a7711a99b7af70
|
7
|
+
data.tar.gz: e5fa85d034c3a57481912e1f2b48e6c2ecdcb0526dd0132b2e3da7c57c1f8b4518770d18c38d9f5b73c991bdb8b810ecb43628d129dbd3566cec7d1bd2927097
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,3 +1,20 @@
|
|
1
|
+
GIT
|
2
|
+
remote: https://github.com/technicalpickles/jeweler
|
3
|
+
revision: 2ab86309fc2494ba2a4e9c86c514742cd4f681c2
|
4
|
+
branch: master
|
5
|
+
specs:
|
6
|
+
jeweler (2.3.9)
|
7
|
+
builder
|
8
|
+
bundler
|
9
|
+
git (>= 1.2.5)
|
10
|
+
github_api (~> 0.16.0)
|
11
|
+
highline (>= 1.6.15)
|
12
|
+
nokogiri (>= 1.5.10)
|
13
|
+
psych
|
14
|
+
rake
|
15
|
+
rdoc
|
16
|
+
semver2
|
17
|
+
|
1
18
|
GEM
|
2
19
|
remote: https://rubygems.org/
|
3
20
|
specs:
|
@@ -67,17 +84,6 @@ GEM
|
|
67
84
|
highline (2.0.2)
|
68
85
|
i18n (1.6.0)
|
69
86
|
concurrent-ruby (~> 1.0)
|
70
|
-
jeweler (2.3.9)
|
71
|
-
builder
|
72
|
-
bundler
|
73
|
-
git (>= 1.2.5)
|
74
|
-
github_api (~> 0.16.0)
|
75
|
-
highline (>= 1.6.15)
|
76
|
-
nokogiri (>= 1.5.10)
|
77
|
-
psych
|
78
|
-
rake
|
79
|
-
rdoc
|
80
|
-
semver2
|
81
87
|
json (1.8.6)
|
82
88
|
jwt (2.2.1)
|
83
89
|
listen (3.1.5)
|
@@ -177,7 +183,7 @@ DEPENDENCIES
|
|
177
183
|
database_cleaner
|
178
184
|
guard
|
179
185
|
guard-rspec
|
180
|
-
jeweler
|
186
|
+
jeweler!
|
181
187
|
mysql2 (= 0.4.10)
|
182
188
|
paranoia
|
183
189
|
pg
|
data/README.md
CHANGED
@@ -6,7 +6,7 @@ Supported for PostgreSQL and MySQL. If you need other adapters, help us make one
|
|
6
6
|
|
7
7
|
## Existing auditing gems for Rails suck
|
8
8
|
|
9
|
-
The Audited gem has some serious flaws.
|
9
|
+
The Audited gem has some serious flaws.
|
10
10
|
|
11
11
|
First, it only tracks a record of what changed, so there's no way to "go back in time" and see what the data looked like back when a problem occurred without replaying every single audit.
|
12
12
|
|
@@ -24,7 +24,7 @@ Moreover, there are benefits to the Active Record model of updating records in p
|
|
24
24
|
|
25
25
|
So how can we get the benefits of caching but NOT losing data, and continue to create, update, and destroy like we normally would in Rails?
|
26
26
|
|
27
|
-
Historiographer introduces the concept of
|
27
|
+
Historiographer introduces the concept of _history tables:_ tables that have the exact same structure as tables storing the latest snapshots of data. So if you have a `posts` table, you'll also have a `post_histories` table with all the same columns and indexes.
|
28
28
|
|
29
29
|
Whenever you include the `Historiographer` gem in your ActiveRecord model, it allows you to insert, update, or delete data as you normally would. If the changes are successful, it also inserts a new history snapshot in the histories table--an exact snapshot of the data at that point in time.
|
30
30
|
|
@@ -52,7 +52,7 @@ class CreatePosts < ActiveRecord::Migration
|
|
52
52
|
end
|
53
53
|
```
|
54
54
|
|
55
|
-
You should create a model named
|
55
|
+
You should create a model named _posts_histories_:
|
56
56
|
|
57
57
|
```ruby
|
58
58
|
require "historiographer/postgres_migration"
|
@@ -67,18 +67,18 @@ end
|
|
67
67
|
|
68
68
|
The `t.histories` method will automatically create a table with the following columns:
|
69
69
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
70
|
+
- `id` (because every model has a primary key)
|
71
|
+
- `post_id` (because this is the foreign key)
|
72
|
+
- `title` (because it was on the original model)
|
73
|
+
- `enabled` (because it was on the original model)
|
74
|
+
- `history_started_at` (to denote when this history became the canonical version)
|
75
|
+
- `history_ended_at` (to denote when this history was no longer the canonical version, if it has stopped being the canonical version)
|
76
|
+
- `history_user_id` (to denote the user that made this change, if one is known)
|
77
77
|
|
78
78
|
Additionally it will add indices on:
|
79
79
|
|
80
|
-
|
81
|
-
|
80
|
+
- The same columns that had indices on the original model (e.g. `enabled`)
|
81
|
+
- `history_started_at`, `history_ended_at`, and `history_user_id`
|
82
82
|
|
83
83
|
## models
|
84
84
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.2
|
data/historiographer.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: historiographer 1.0.
|
5
|
+
# stub: historiographer 1.0.2 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "historiographer".freeze
|
9
|
-
s.version = "1.0.
|
9
|
+
s.version = "1.0.2"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib".freeze]
|
13
13
|
s.authors = ["brettshollenberger".freeze]
|
14
|
-
s.date = "2019-
|
14
|
+
s.date = "2019-09-30"
|
15
15
|
s.description = "Creates separate tables for each history table".freeze
|
16
16
|
s.email = "brett.shollenberger@gmail.com".freeze
|
17
17
|
s.extra_rdoc_files = [
|
@@ -4,4 +4,8 @@ if defined?(ActiveRecord::ConnectionAdapters::Mysql2Adapter)
|
|
4
4
|
class ActiveRecord::ConnectionAdapters::TableDefinition
|
5
5
|
include Historiographer::HistoryMigrationMysql
|
6
6
|
end
|
7
|
+
elsif defined?(ActiveRecord::ConnectionAdapters::TableDefinition)
|
8
|
+
class ActiveRecord::ConnectionAdapters::TableDefinition
|
9
|
+
include Historiographer::HistoryMigration
|
10
|
+
end
|
7
11
|
end
|
@@ -4,4 +4,8 @@ if defined?(ActiveRecord::ConnectionAdapters::PostgreSQL::TableDefinition)
|
|
4
4
|
class ActiveRecord::ConnectionAdapters::PostgreSQL::TableDefinition
|
5
5
|
include Historiographer::HistoryMigration
|
6
6
|
end
|
7
|
+
elsif defined?(ActiveRecord::ConnectionAdapters::TableDefinition)
|
8
|
+
class ActiveRecord::ConnectionAdapters::TableDefinition
|
9
|
+
include Historiographer::HistoryMigration
|
10
|
+
end
|
7
11
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: historiographer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- brettshollenberger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-09-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|