historiographer 4.1.0 → 4.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/{Users/brettshollenberger/programming/historiographer/lib → lib}/historiographer/history_migration.rb +1 -0
  3. data/lib/historiographer/version.rb +3 -0
  4. metadata +12 -41
  5. data/Users/brettshollenberger/programming/historiographer/Gemfile +0 -33
  6. data/Users/brettshollenberger/programming/historiographer/Gemfile.lock +0 -341
  7. data/Users/brettshollenberger/programming/historiographer/Guardfile +0 -4
  8. data/Users/brettshollenberger/programming/historiographer/LICENSE.txt +0 -20
  9. data/Users/brettshollenberger/programming/historiographer/README.md +0 -298
  10. data/Users/brettshollenberger/programming/historiographer/Rakefile +0 -54
  11. data/Users/brettshollenberger/programming/historiographer/historiographer-4.1.0.gem +0 -0
  12. data/Users/brettshollenberger/programming/historiographer/historiographer.gemspec +0 -65
  13. data/Users/brettshollenberger/programming/historiographer/init.rb +0 -18
  14. data/Users/brettshollenberger/programming/historiographer/lib/historiographer/version.rb +0 -3
  15. data/Users/brettshollenberger/programming/historiographer/spec/db/database.yml +0 -27
  16. data/Users/brettshollenberger/programming/historiographer/spec/db/migrate/20161121212228_create_posts.rb +0 -19
  17. data/Users/brettshollenberger/programming/historiographer/spec/db/migrate/20161121212229_create_post_histories.rb +0 -10
  18. data/Users/brettshollenberger/programming/historiographer/spec/db/migrate/20161121212230_create_authors.rb +0 -13
  19. data/Users/brettshollenberger/programming/historiographer/spec/db/migrate/20161121212231_create_author_histories.rb +0 -10
  20. data/Users/brettshollenberger/programming/historiographer/spec/db/migrate/20161121212232_create_users.rb +0 -9
  21. data/Users/brettshollenberger/programming/historiographer/spec/db/migrate/20171011194624_create_safe_posts.rb +0 -19
  22. data/Users/brettshollenberger/programming/historiographer/spec/db/migrate/20171011194715_create_safe_post_histories.rb +0 -9
  23. data/Users/brettshollenberger/programming/historiographer/spec/db/migrate/20191024142304_create_thing_with_compound_index.rb +0 -10
  24. data/Users/brettshollenberger/programming/historiographer/spec/db/migrate/20191024142352_create_thing_with_compound_index_history.rb +0 -11
  25. data/Users/brettshollenberger/programming/historiographer/spec/db/migrate/20191024203106_create_thing_without_history.rb +0 -7
  26. data/Users/brettshollenberger/programming/historiographer/spec/db/migrate/20221018204220_create_silent_posts.rb +0 -21
  27. data/Users/brettshollenberger/programming/historiographer/spec/db/migrate/20221018204255_create_silent_post_histories.rb +0 -9
  28. data/Users/brettshollenberger/programming/historiographer/spec/db/migrate/20241109182017_create_comments.rb +0 -13
  29. data/Users/brettshollenberger/programming/historiographer/spec/db/migrate/20241109182020_create_comment_histories.rb +0 -9
  30. data/Users/brettshollenberger/programming/historiographer/spec/db/schema.rb +0 -225
  31. data/Users/brettshollenberger/programming/historiographer/spec/examples.txt +0 -40
  32. data/Users/brettshollenberger/programming/historiographer/spec/factories/post.rb +0 -7
  33. data/Users/brettshollenberger/programming/historiographer/spec/historiographer_spec.rb +0 -813
  34. data/Users/brettshollenberger/programming/historiographer/spec/spec_helper.rb +0 -56
  35. /data/{Users/brettshollenberger/programming/historiographer/lib → lib}/historiographer/configuration.rb +0 -0
  36. /data/{Users/brettshollenberger/programming/historiographer/lib → lib}/historiographer/history.rb +0 -0
  37. /data/{Users/brettshollenberger/programming/historiographer/lib → lib}/historiographer/history_migration_mysql.rb +0 -0
  38. /data/{Users/brettshollenberger/programming/historiographer/lib → lib}/historiographer/mysql_migration.rb +0 -0
  39. /data/{Users/brettshollenberger/programming/historiographer/lib → lib}/historiographer/postgres_migration.rb +0 -0
  40. /data/{Users/brettshollenberger/programming/historiographer/lib → lib}/historiographer/relation.rb +0 -0
  41. /data/{Users/brettshollenberger/programming/historiographer/lib → lib}/historiographer/safe.rb +0 -0
  42. /data/{Users/brettshollenberger/programming/historiographer/lib → lib}/historiographer/silent.rb +0 -0
  43. /data/{Users/brettshollenberger/programming/historiographer/lib → lib}/historiographer.rb +0 -0
@@ -1,298 +0,0 @@
1
- # Historiographer
2
-
3
- Losing data sucks. Every time you update or destroy a record in Rails, you lose the old data.
4
-
5
- Historiographer fixes this problem in a better way than existing auditing gems.
6
-
7
- ## Existing auditing gems for Rails suck
8
-
9
- The Audited gem has some serious flaws.
10
-
11
- 1. The `versions` table quickly grows too large to query
12
-
13
- 2. It doesn't provide the indexes you need from your primary tables
14
-
15
- 3. It doesn't provdie out-of-the-box snapshots
16
-
17
- ## How does Historiographer solve these problems?
18
-
19
- Historiographer introduces the concept of _history tables:_ append-only tables that have the same structure and indexes as your primary table.
20
-
21
- If you have a `posts` table:
22
-
23
- | id | title |
24
- | :-- | :------------- |
25
- | 1 | My Great Post |
26
- | 2 | My Second Post |
27
-
28
- You'll also have a `post_histories_table`:
29
-
30
- | id | post_id | title | history_started_at | history_ended_at | history_user_id |
31
- | :-- | :------ | :------------- | :----------------- | :--------------- | :-------------- |
32
- | 1 | 1 | My Great Post | '2019-11-08' | NULL | 1 |
33
- | 2 | 2 | My Second Post | '2019-11-08' | NULL | 1 |
34
-
35
- If you change the title of the 1st post:
36
-
37
- `Post.find(1).update(title: "Title With Better SEO", history_user_id: current_user.id)`
38
-
39
- You'll expect your `posts` table to be updated directly:
40
-
41
- | id | title |
42
- | :-- | :-------------------- |
43
- | 1 | Title With Better SEO |
44
- | 2 | My Second Post |
45
-
46
- But also, your `histories` table will be updated:
47
-
48
- | id | post_id | title | history_started_at | history_ended_at | history_user_id |
49
- | :-- | :------ | :-------------------- | :----------------- | :--------------- | :-------------- |
50
- | 1 | 1 | My Great Post | '2019-11-08' | '2019-11-09' | 1 |
51
- | 2 | 2 | My Second Post | '2019-11-08' | NULL | 1 |
52
- | 1 | 1 | Title With Better SEO | '2019-11-09' | NULL | 1 |
53
-
54
- A few things have happened here:
55
-
56
- 1. The primary table (`posts`) is updated directly
57
- 2. The existing history for `post_id=1` is timestamped when its `history_ended_at`, so that we can see when the post had the title "My Great Post"
58
- 3. A new history record is appended to the table containing a complete snapshot of the record, and a `NULL` `history_ended_at`. That's because this is the current history.
59
- 4. A record of _who_ made the change is saved (`history_user_id`). You can join to your users table to see more data.
60
-
61
- ## Snapshots
62
-
63
- Snapshots are particularly useful for two key use cases:
64
-
65
- ### 1. Time Travel & Auditing
66
-
67
- When you need to see exactly what your data looked like at a specific point in time - not just individual records, but entire object graphs with all their associations. This is invaluable for:
68
-
69
- - Debugging production issues ("What did the entire order look like when this happened?")
70
- - Compliance requirements ("Show me the exact state of this patient's record on January 1st")
71
- - Auditing complex workflows ("What was the state of this loan application when it was approved?")
72
-
73
- ### 2. Machine Learning & Analytics
74
-
75
- When you need immutable snapshots of data for:
76
-
77
- - Training data versioning
78
- - Feature engineering
79
- - Model validation
80
- - A/B test analysis
81
- - Ensuring reproducibility of results
82
-
83
- ### Taking Snapshots
84
-
85
- You can take a snapshot of a record and all its associated records:
86
-
87
- ```ruby
88
- post = Post.find(1)
89
- post.snapshot(history_user_id: current_user.id)
90
- ```
91
-
92
- This will:
93
-
94
- 1. Create a history record for the post
95
- 2. Create history records for all associated records (comments, author, etc.)
96
- 3. Link these history records together with a shared `snapshot_id`
97
-
98
- You can retrieve the latest snapshot using:
99
-
100
- ```ruby
101
- post = Post.find(1)
102
- snapshot = post.latest_snapshot
103
-
104
- # Access associated records from the snapshot
105
- snapshot.comments # Returns CommentHistory records
106
- snapshot.author # Returns AuthorHistory record
107
- ```
108
-
109
- Snapshots are immutable - you cannot modify history records that are part of a snapshot. This guarantees that your historical data remains unchanged, which is crucial for both auditing and machine learning applications.
110
-
111
- ### Snapshot-Only Mode
112
-
113
- If you want to only track snapshots and not record every individual change, you can configure Historiographer to operate in snapshot-only mode:
114
-
115
- ```ruby
116
- Historiographer::Configuration.mode = :snapshot_only
117
- ```
118
-
119
- In this mode:
120
-
121
- - Regular updates/changes will not create history records
122
- - Only explicit calls to `snapshot` will create history records
123
- - Each snapshot still captures the complete state of the record and its associations
124
-
125
- This can be useful when:
126
-
127
- - You only care about specific points in time rather than every change
128
- - You want to reduce the number of history records created
129
- - You need to capture the state of complex object graphs at specific moments
130
- - You're versioning training data for machine learning models
131
- - You need to maintain immutable audit trails at specific checkpoints
132
-
133
- # Getting Started
134
-
135
- Whenever you include the `Historiographer` gem in your ActiveRecord model, it allows you to insert, update, or delete data as you normally would.
136
-
137
- ```ruby
138
- class Post < ActiveRecord::Base
139
- include Historiographer
140
- end
141
- ```
142
-
143
- ### History Modes
144
-
145
- Historiographer supports two modes of operation:
146
-
147
- 1. **:histories mode** (default) - Records history for every change to a record
148
- 2. **:snapshot_only mode** - Only records history when explicitly taking snapshots
149
-
150
- You can configure the mode globally:
151
-
152
- ```ruby
153
- # In an initializer
154
- Historiographer::Configuration.mode = :histories # Default mode
155
- # or
156
- Historiographer::Configuration.mode = :snapshot_only
157
- ```
158
-
159
- Or per model using `historiographer_mode`:
160
-
161
- ```ruby
162
- class Post < ActiveRecord::Base
163
- include Historiographer
164
- historiographer_mode :snapshot_only # Only record history when .snapshot is called
165
- end
166
-
167
- class Comment < ActiveRecord::Base
168
- include Historiographer
169
- historiographer_mode :histories # Record history for every change (default)
170
- end
171
- ```
172
-
173
- ## Create A Migration
174
-
175
- You need a separate table to store histories for each model.
176
-
177
- So if you have a Posts model:
178
-
179
- ```ruby
180
- class CreatePosts < ActiveRecord::Migration
181
- def change
182
- create_table :posts do |t|
183
- t.string :title, null: false
184
- t.boolean :enabled
185
- end
186
- add_index :posts, :enabled
187
- end
188
- end
189
- ```
190
-
191
- You should create a model named _posts_histories_:
192
-
193
- ```ruby
194
- require "historiographer/postgres_migration"
195
- class CreatePostHistories < ActiveRecord::Migration
196
- def change
197
- create_table :post_histories do |t|
198
- t.histories
199
- end
200
- end
201
- end
202
- ```
203
-
204
- The `t.histories` method will automatically create a table with the following columns:
205
-
206
- - `id` (because every model has a primary key)
207
- - `post_id` (because this is the foreign key)
208
- - `title` (because it was on the original model)
209
- - `enabled` (because it was on the original model)
210
- - `history_started_at` (to denote when this history became the canonical version)
211
- - `history_ended_at` (to denote when this history was no longer the canonical version, if it has stopped being the canonical version)
212
- - `history_user_id` (to denote the user that made this change, if one is known)
213
-
214
- Additionally it will add indices on:
215
-
216
- - The same columns that had indices on the original model (e.g. `enabled`)
217
- - `history_started_at`, `history_ended_at`, and `history_user_id`
218
-
219
- ## Models
220
-
221
- The primary model should include `Historiographer`:
222
-
223
- ```ruby
224
- class Post < ActiveRecord::Base
225
- include Historiographer
226
- end
227
- ```
228
-
229
- You should also make a `PostHistory` class if you're going to query `PostHistory` from Rails:
230
-
231
- ```ruby
232
- class PostHistory < ActiveRecord::Base
233
- end
234
- ```
235
-
236
- The `Posts` class will acquire a `histories` method, and the `PostHistory` model will gain a `post` method:
237
-
238
- ```ruby
239
- p = Post.first
240
- p.histories.first.class
241
-
242
- # => "PostHistory"
243
-
244
- p.histories.first.post == p
245
- # => true
246
- ```
247
-
248
- ## Creating, Updating, and Destroying Data:
249
-
250
- You can just use normal ActiveRecord methods, and all will record histories:
251
-
252
- ```ruby
253
- Post.create(title: "My Great Title", history_user_id: current_user.id)
254
- Post.find_by(title: "My Great Title").update(title: "A New Title", history_user_id: current_user.id)
255
- Post.update_all(title: "They're all the same!", history_user_id: current_user.id)
256
- Post.last.destroy!(history_user_id: current_user.id)
257
- Post.destroy_all(history_user_id: current_user.id)
258
- ```
259
-
260
- The `histories` classes have a `current` method, which only finds current history records. These records will also be the same as the data in the primary table.
261
-
262
- ```ruby
263
- p = Post.first
264
- p.current_history
265
-
266
- PostHistory.current
267
- ```
268
-
269
- ### What to do when generated index names are too long
270
-
271
- Sometimes the generated index names are too long. Just like with standard Rails migrations, you can override the name of the index to fix this problem. To do so, use the `index_names` argument to override individual index names:
272
-
273
- ```ruby
274
- require "historiographer/postgres_migration"
275
- class CreatePostHistories < ActiveRecord::Migration
276
- def change
277
- create_table :post_histories do |t|
278
- t.histories index_names: {
279
- title: "my_index_name",
280
- [:compound, :index] => "my_compound_index_name"
281
- }
282
- end
283
- end
284
- end
285
- ```
286
-
287
- == Mysql Install
288
-
289
- For contributors on OSX, you may have difficulty installing mysql:
290
-
291
- ```
292
- gem install mysql2 -v '0.4.10' --source 'https://rubygems.org/' -- --with-ldflags=-L/usr/local/opt/openssl/lib --with-cppflags=-I/usr/local/opt/openssl/include
293
- ```
294
-
295
- == Copyright
296
-
297
- Copyright (c) 2016-2020 brettshollenberger. See LICENSE.txt for
298
- further details.
@@ -1,54 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'rubygems'
4
- require 'bundler'
5
- require 'pry'
6
- begin
7
- Bundler.setup(:default, :development)
8
- rescue Bundler::BundlerError => e
9
- $stderr.puts e.message
10
- $stderr.puts "Run `bundle install` to install missing gems"
11
- exit e.status_code
12
- end
13
- require 'rake'
14
- require 'jeweler'
15
-
16
- Jeweler::Tasks.new do |gem|
17
- # gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
18
- gem.name = "historiographer"
19
- gem.homepage = "http://github.com/brettshollenberger/historiographer"
20
- gem.license = "MIT"
21
- gem.summary = %Q{Create histories of your ActiveRecord tables}
22
- gem.description = %Q{Creates separate tables for each history table}
23
- gem.email = "brett.shollenberger@gmail.com"
24
- gem.authors = ["brettshollenberger"]
25
- end
26
- Jeweler::RubygemsDotOrgTasks.new
27
-
28
- require 'rake/testtask'
29
- Rake::TestTask.new(:test) do |test|
30
- test.libs << 'lib' << 'spec'
31
- test.pattern = 'rspec/**/*_spec.rb'
32
- test.verbose = true
33
- end
34
-
35
- desc "Code coverage detail"
36
- task :simplecov do
37
- ENV['COVERAGE'] = "true"
38
- Rake::Task['test'].execute
39
- end
40
-
41
- task :default => :test
42
-
43
- require 'rdoc/task'
44
- Rake::RDocTask.new do |rdoc|
45
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
46
-
47
- rdoc.rdoc_dir = 'rdoc'
48
- rdoc.title = "historiographer #{version}"
49
- rdoc.rdoc_files.include('README*')
50
- rdoc.rdoc_files.include('lib/**/*.rb')
51
- end
52
-
53
- require 'standalone_migrations'
54
- StandaloneMigrations::Tasks.load_tasks
@@ -1,65 +0,0 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
- # -*- encoding: utf-8 -*-
5
- # stub: historiographer 4.0.0 ruby lib
6
-
7
- Gem::Specification.new do |s|
8
- s.name = "historiographer".freeze
9
- s.version = "4.1.0"
10
-
11
- s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
- s.require_paths = ["lib".freeze]
13
- s.authors = ["brettshollenberger".freeze]
14
- s.date = "2023-08-22"
15
- s.description = "Creates separate tables for each history table".freeze
16
- s.email = "brett.shollenberger@gmail.com".freeze
17
- s.extra_rdoc_files = [
18
- "LICENSE.txt",
19
- "README.md"
20
- ]
21
- s.files = Dir[File.expand_path("**/*")]
22
- s.homepage = "http://github.com/brettshollenberger/historiographer".freeze
23
- s.licenses = ["MIT".freeze]
24
- s.rubygems_version = "3.2.22".freeze
25
- s.summary = "Create histories of your ActiveRecord tables".freeze
26
-
27
- if s.respond_to? :specification_version then
28
- s.specification_version = 4
29
- end
30
-
31
- if s.respond_to? :add_runtime_dependency then
32
- s.add_runtime_dependency(%q<activerecord>.freeze, [">= 6"])
33
- s.add_runtime_dependency(%q<activerecord-import>.freeze, [">= 0"])
34
- s.add_runtime_dependency(%q<activesupport>.freeze, [">= 0"])
35
- s.add_runtime_dependency(%q<rails>.freeze, [">= 6"])
36
- s.add_runtime_dependency(%q<rollbar>.freeze, [">= 0"])
37
- s.add_development_dependency(%q<mysql2>.freeze, ["= 0.5"])
38
- s.add_development_dependency(%q<paranoia>.freeze, [">= 0"])
39
- s.add_development_dependency(%q<pg>.freeze, [">= 0"])
40
- s.add_development_dependency(%q<pry>.freeze, [">= 0"])
41
- s.add_development_dependency(%q<standalone_migrations>.freeze, [">= 0"])
42
- s.add_development_dependency(%q<timecop>.freeze, [">= 0"])
43
- s.add_development_dependency(%q<bundler>.freeze, ["~> 1.0"])
44
- s.add_development_dependency(%q<jeweler>.freeze, [">= 0"])
45
- s.add_development_dependency(%q<rdoc>.freeze, ["~> 3.12"])
46
- s.add_development_dependency(%q<simplecov>.freeze, [">= 0"])
47
- else
48
- s.add_dependency(%q<activerecord>.freeze, [">= 6"])
49
- s.add_dependency(%q<activerecord-import>.freeze, [">= 0"])
50
- s.add_dependency(%q<activesupport>.freeze, [">= 0"])
51
- s.add_dependency(%q<rails>.freeze, [">= 6"])
52
- s.add_dependency(%q<rollbar>.freeze, [">= 0"])
53
- s.add_dependency(%q<mysql2>.freeze, ["= 0.5"])
54
- s.add_dependency(%q<paranoia>.freeze, [">= 0"])
55
- s.add_dependency(%q<pg>.freeze, [">= 0"])
56
- s.add_dependency(%q<pry>.freeze, [">= 0"])
57
- s.add_dependency(%q<standalone_migrations>.freeze, [">= 0"])
58
- s.add_dependency(%q<timecop>.freeze, [">= 0"])
59
- s.add_dependency(%q<bundler>.freeze, ["~> 1.0"])
60
- s.add_dependency(%q<jeweler>.freeze, [">= 0"])
61
- s.add_dependency(%q<rdoc>.freeze, ["~> 3.12"])
62
- s.add_dependency(%q<simplecov>.freeze, [">= 0"])
63
- end
64
- end
65
-
@@ -1,18 +0,0 @@
1
- require "yaml"
2
-
3
- Bundler.require(:default, :development, :test)
4
-
5
- Dir.glob(File.expand_path("lib/**/*.rb")).each do |file|
6
- require file
7
- end
8
-
9
- database_config = YAML.load(File.open(File.expand_path("spec/db/database.yml")).read)
10
-
11
- env = ENV["HISTORIOGRAPHER_ENV"] || "development"
12
-
13
- db_env_config = database_config[env]
14
-
15
- if defined?(ActiveRecord::Base)
16
- # new settings as specified here: https://devcenter.heroku.com/articles/concurrency-and-database-connections
17
- ActiveRecord::Base.establish_connection(db_env_config)
18
- end
@@ -1,3 +0,0 @@
1
- module Historiographer
2
- VERSION = "4.1.0"
3
- end
@@ -1,27 +0,0 @@
1
- development:
2
- adapter: postgresql
3
- encoding: unicode
4
- database: historiographer_development
5
- pool: 5
6
-
7
- test:
8
- adapter: postgresql
9
- encoding: unicode
10
- database: historiographer_test
11
- pool: 5
12
-
13
- # mysql_default: &mysql_default
14
- # adapter: mysql2
15
- # encoding: utf8
16
- # username: root
17
- # password:
18
- # host: 127.0.0.1
19
- # port: 3306
20
-
21
- # development:
22
- # <<: *mysql_default
23
- # database: historiographer_development
24
-
25
- # test:
26
- # <<: *mysql_default
27
- # database: historiographer_test
@@ -1,19 +0,0 @@
1
- class CreatePosts < ActiveRecord::Migration[5.1]
2
- def change
3
- create_table :posts do |t|
4
- t.string :title, null: false
5
- t.text :body, null: false
6
- t.integer :author_id, null: false
7
- t.boolean :enabled, default: false
8
- t.datetime :live_at
9
- t.datetime :deleted_at
10
-
11
- t.timestamps
12
- end
13
-
14
- add_index :posts, :author_id
15
- add_index :posts, :enabled
16
- add_index :posts, :live_at
17
- add_index :posts, :deleted_at
18
- end
19
- end
@@ -1,10 +0,0 @@
1
- require "historiographer/postgres_migration"
2
- require "historiographer/mysql_migration"
3
-
4
- class CreatePostHistories < ActiveRecord::Migration[5.1]
5
- def change
6
- create_table :post_histories do |t|
7
- t.histories
8
- end
9
- end
10
- end
@@ -1,13 +0,0 @@
1
- class CreateAuthors < ActiveRecord::Migration[5.1]
2
- def change
3
- create_table :authors do |t|
4
- t.string :full_name, null: false
5
- t.text :bio
6
- t.datetime :deleted_at
7
-
8
- t.timestamps
9
- end
10
-
11
- add_index :authors, :deleted_at
12
- end
13
- end
@@ -1,10 +0,0 @@
1
- require "historiographer/postgres_migration"
2
- require "historiographer/mysql_migration"
3
-
4
- class CreateAuthorHistories < ActiveRecord::Migration[5.1]
5
- def change
6
- create_table :author_histories do |t|
7
- t.histories
8
- end
9
- end
10
- end
@@ -1,9 +0,0 @@
1
- require "historiographer/postgres_migration"
2
-
3
- class CreateUsers < ActiveRecord::Migration[5.1]
4
- def change
5
- create_table :users do |t|
6
- t.string :name
7
- end
8
- end
9
- end
@@ -1,19 +0,0 @@
1
- class CreateSafePosts < ActiveRecord::Migration[5.1]
2
- def change
3
- create_table :safe_posts do |t|
4
- t.string :title, null: false
5
- t.text :body, null: false
6
- t.integer :author_id, null: false
7
- t.boolean :enabled, default: false
8
- t.datetime :live_at
9
- t.datetime :deleted_at
10
-
11
- t.timestamps
12
- end
13
-
14
- add_index :safe_posts, :author_id
15
- add_index :safe_posts, :enabled
16
- add_index :safe_posts, :live_at
17
- add_index :safe_posts, :deleted_at
18
- end
19
- end
@@ -1,9 +0,0 @@
1
- require "historiographer/postgres_migration"
2
-
3
- class CreateSafePostHistories < ActiveRecord::Migration[5.1]
4
- def change
5
- create_table :safe_post_histories do |t|
6
- t.histories
7
- end
8
- end
9
- end
@@ -1,10 +0,0 @@
1
- class CreateThingWithCompoundIndex < ActiveRecord::Migration[5.2]
2
- def change
3
- create_table :thing_with_compound_indices do |t|
4
- t.string :key
5
- t.string :value
6
-
7
- t.index [:key, :value], name: "idx_key_value"
8
- end
9
- end
10
- end
@@ -1,11 +0,0 @@
1
- require "historiographer/postgres_migration"
2
- class CreateThingWithCompoundIndexHistory < ActiveRecord::Migration[5.2]
3
- def change
4
- create_table :thing_with_compound_index_histories do |t|
5
- t.histories index_names: {
6
- [:key, :value] => "idx_history_k_v",
7
- :thing_with_compound_index_id => "idx_k_v_histories"
8
- }
9
- end
10
- end
11
- end
@@ -1,7 +0,0 @@
1
- class CreateThingWithoutHistory < ActiveRecord::Migration[5.2]
2
- def change
3
- create_table :thing_without_histories do |t|
4
- t.string :name
5
- end
6
- end
7
- end
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class CreateSilentPosts < ActiveRecord::Migration[5.1]
4
- def change
5
- create_table :silent_posts do |t|
6
- t.string :title, null: false
7
- t.text :body, null: false
8
- t.integer :author_id, null: false
9
- t.boolean :enabled, default: false
10
- t.datetime :live_at
11
- t.datetime :deleted_at
12
-
13
- t.timestamps
14
- end
15
-
16
- add_index :silent_posts, :author_id
17
- add_index :silent_posts, :enabled
18
- add_index :silent_posts, :live_at
19
- add_index :silent_posts, :deleted_at
20
- end
21
- end
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'historiographer/postgres_migration'
4
-
5
- class CreateSilentPostHistories < ActiveRecord::Migration[5.1]
6
- def change
7
- create_table :silent_post_histories, &:histories
8
- end
9
- end
@@ -1,13 +0,0 @@
1
- class CreateComments < ActiveRecord::Migration[7.1]
2
- def change
3
- create_table :comments do |t|
4
- t.bigint :post_id
5
- t.bigint :author_id
6
- t.text :body
7
- t.timestamps
8
-
9
- t.index :post_id
10
- t.index :author_id
11
- end
12
- end
13
- end
@@ -1,9 +0,0 @@
1
- require 'historiographer/postgres_migration'
2
-
3
- class CreateCommentHistories < ActiveRecord::Migration[7.1]
4
- def change
5
- create_table :comment_histories do |t|
6
- t.histories
7
- end
8
- end
9
- end