paper_trail 4.2.0 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/{CONTRIBUTING.md → .github/CONTRIBUTING.md} +28 -9
- data/.github/ISSUE_TEMPLATE.md +13 -0
- data/.gitignore +2 -1
- data/.rubocop.yml +100 -0
- data/.rubocop_todo.yml +14 -0
- data/.travis.yml +8 -9
- data/Appraisals +41 -0
- data/CHANGELOG.md +49 -9
- data/Gemfile +1 -1
- data/README.md +130 -109
- data/Rakefile +19 -19
- data/doc/bug_report_template.rb +20 -14
- data/gemfiles/ar3.gemfile +10 -53
- data/gemfiles/ar4.gemfile +7 -0
- data/gemfiles/ar5.gemfile +13 -0
- data/lib/generators/paper_trail/install_generator.rb +26 -18
- data/lib/generators/paper_trail/templates/add_object_changes_to_versions.rb +4 -2
- data/lib/generators/paper_trail/templates/add_transaction_id_column_to_versions.rb +2 -0
- data/lib/generators/paper_trail/templates/create_version_associations.rb +9 -4
- data/lib/generators/paper_trail/templates/create_versions.rb +39 -5
- data/lib/paper_trail.rb +169 -146
- data/lib/paper_trail/attributes_serialization.rb +89 -17
- data/lib/paper_trail/cleaner.rb +15 -9
- data/lib/paper_trail/config.rb +28 -11
- data/lib/paper_trail/frameworks/active_record.rb +4 -0
- data/lib/paper_trail/frameworks/active_record/models/paper_trail/version.rb +5 -1
- data/lib/paper_trail/frameworks/active_record/models/paper_trail/version_association.rb +6 -2
- data/lib/paper_trail/frameworks/cucumber.rb +1 -0
- data/lib/paper_trail/frameworks/rails.rb +2 -7
- data/lib/paper_trail/frameworks/rails/controller.rb +29 -9
- data/lib/paper_trail/frameworks/rails/engine.rb +7 -1
- data/lib/paper_trail/frameworks/rspec.rb +5 -5
- data/lib/paper_trail/frameworks/rspec/helpers.rb +3 -1
- data/lib/paper_trail/frameworks/sinatra.rb +6 -4
- data/lib/paper_trail/has_paper_trail.rb +199 -106
- data/lib/paper_trail/record_history.rb +1 -3
- data/lib/paper_trail/reifier.rb +297 -118
- data/lib/paper_trail/serializers/json.rb +3 -3
- data/lib/paper_trail/serializers/yaml.rb +27 -8
- data/lib/paper_trail/version_association_concern.rb +3 -1
- data/lib/paper_trail/version_concern.rb +75 -35
- data/lib/paper_trail/version_number.rb +6 -9
- data/paper_trail.gemspec +44 -51
- data/spec/generators/install_generator_spec.rb +24 -25
- data/spec/generators/paper_trail/templates/create_versions_spec.rb +51 -0
- data/spec/models/animal_spec.rb +12 -12
- data/spec/models/boolit_spec.rb +8 -8
- data/spec/models/callback_modifier_spec.rb +47 -47
- data/spec/models/car_spec.rb +13 -0
- data/spec/models/fluxor_spec.rb +3 -3
- data/spec/models/gadget_spec.rb +19 -19
- data/spec/models/joined_version_spec.rb +3 -3
- data/spec/models/json_version_spec.rb +23 -24
- data/spec/models/kitchen/banana_spec.rb +3 -3
- data/spec/models/not_on_update_spec.rb +7 -4
- data/spec/models/post_with_status_spec.rb +13 -3
- data/spec/models/skipper_spec.rb +10 -10
- data/spec/models/thing_spec.rb +4 -4
- data/spec/models/truck_spec.rb +5 -0
- data/spec/models/vehicle_spec.rb +5 -0
- data/spec/models/version_spec.rb +103 -59
- data/spec/models/widget_spec.rb +82 -52
- data/spec/modules/paper_trail_spec.rb +2 -2
- data/spec/modules/version_concern_spec.rb +11 -12
- data/spec/modules/version_number_spec.rb +2 -4
- data/spec/paper_trail/config_spec.rb +10 -29
- data/spec/paper_trail_spec.rb +16 -14
- data/spec/rails_helper.rb +10 -9
- data/spec/requests/articles_spec.rb +11 -7
- data/spec/spec_helper.rb +41 -22
- data/spec/support/alt_db_init.rb +8 -13
- data/test/custom_json_serializer.rb +3 -3
- data/test/dummy/Rakefile +2 -2
- data/test/dummy/app/controllers/application_controller.rb +21 -8
- data/test/dummy/app/controllers/articles_controller.rb +11 -8
- data/test/dummy/app/controllers/widgets_controller.rb +13 -12
- data/test/dummy/app/models/animal.rb +1 -1
- data/test/dummy/app/models/article.rb +19 -11
- data/test/dummy/app/models/authorship.rb +1 -1
- data/test/dummy/app/models/bar_habtm.rb +4 -0
- data/test/dummy/app/models/book.rb +4 -4
- data/test/dummy/app/models/boolit.rb +1 -1
- data/test/dummy/app/models/callback_modifier.rb +6 -6
- data/test/dummy/app/models/car.rb +3 -0
- data/test/dummy/app/models/chapter.rb +4 -4
- data/test/dummy/app/models/customer.rb +1 -1
- data/test/dummy/app/models/document.rb +2 -2
- data/test/dummy/app/models/editor.rb +1 -1
- data/test/dummy/app/models/foo_habtm.rb +4 -0
- data/test/dummy/app/models/fruit.rb +2 -2
- data/test/dummy/app/models/gadget.rb +1 -1
- data/test/dummy/app/models/kitchen/banana.rb +1 -1
- data/test/dummy/app/models/legacy_widget.rb +2 -2
- data/test/dummy/app/models/line_item.rb +1 -1
- data/test/dummy/app/models/not_on_update.rb +1 -1
- data/test/dummy/app/models/person.rb +6 -6
- data/test/dummy/app/models/post.rb +1 -1
- data/test/dummy/app/models/post_with_status.rb +1 -1
- data/test/dummy/app/models/quotation.rb +1 -1
- data/test/dummy/app/models/section.rb +1 -1
- data/test/dummy/app/models/skipper.rb +2 -2
- data/test/dummy/app/models/song.rb +13 -4
- data/test/dummy/app/models/thing.rb +2 -2
- data/test/dummy/app/models/translation.rb +2 -2
- data/test/dummy/app/models/truck.rb +4 -0
- data/test/dummy/app/models/vehicle.rb +4 -0
- data/test/dummy/app/models/whatchamajigger.rb +1 -1
- data/test/dummy/app/models/widget.rb +7 -6
- data/test/dummy/app/versions/joined_version.rb +4 -3
- data/test/dummy/app/versions/json_version.rb +1 -1
- data/test/dummy/app/versions/kitchen/banana_version.rb +1 -1
- data/test/dummy/app/versions/post_version.rb +2 -2
- data/test/dummy/config.ru +1 -1
- data/test/dummy/config/application.rb +20 -9
- data/test/dummy/config/boot.rb +5 -5
- data/test/dummy/config/environment.rb +1 -1
- data/test/dummy/config/environments/development.rb +4 -3
- data/test/dummy/config/environments/production.rb +3 -2
- data/test/dummy/config/environments/test.rb +15 -5
- data/test/dummy/config/initializers/backtrace_silencers.rb +4 -2
- data/test/dummy/config/initializers/paper_trail.rb +1 -2
- data/test/dummy/config/initializers/secret_token.rb +3 -1
- data/test/dummy/config/initializers/session_store.rb +1 -1
- data/test/dummy/config/routes.rb +2 -2
- data/test/dummy/db/migrate/20110208155312_set_up_test_tables.rb +120 -74
- data/test/dummy/db/schema.rb +29 -6
- data/test/dummy/script/rails +6 -4
- data/test/functional/controller_test.rb +34 -35
- data/test/functional/enabled_for_controller_test.rb +6 -7
- data/test/functional/modular_sinatra_test.rb +43 -38
- data/test/functional/sinatra_test.rb +49 -40
- data/test/functional/thread_safety_test.rb +4 -6
- data/test/paper_trail_test.rb +15 -14
- data/test/test_helper.rb +68 -44
- data/test/time_travel_helper.rb +1 -15
- data/test/unit/associations_test.rb +517 -251
- data/test/unit/cleaner_test.rb +66 -60
- data/test/unit/inheritance_column_test.rb +17 -17
- data/test/unit/model_test.rb +611 -504
- data/test/unit/protected_attrs_test.rb +16 -12
- data/test/unit/serializer_test.rb +44 -43
- data/test/unit/serializers/json_test.rb +17 -18
- data/test/unit/serializers/mixin_json_test.rb +15 -14
- data/test/unit/serializers/mixin_yaml_test.rb +20 -16
- data/test/unit/serializers/yaml_test.rb +12 -13
- data/test/unit/timestamp_test.rb +10 -12
- data/test/unit/version_test.rb +7 -7
- metadata +92 -40
@@ -1,7 +1,9 @@
|
|
1
1
|
# Be sure to restart your server when you modify this file.
|
2
2
|
|
3
|
-
# You can add backtrace silencers for libraries that you're using but don't wish
|
3
|
+
# You can add backtrace silencers for libraries that you're using but don't wish
|
4
|
+
# to see in your backtraces.
|
4
5
|
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
|
5
6
|
|
6
|
-
# You can also remove all the silencers if you're trying to debug a problem that
|
7
|
+
# You can also remove all the silencers if you're trying to debug a problem that
|
8
|
+
# might stem from framework code.
|
7
9
|
# Rails.backtrace_cleaner.remove_silencers!
|
@@ -4,4 +4,6 @@
|
|
4
4
|
# If you change this key, all old signed cookies will become invalid!
|
5
5
|
# Make sure the secret is at least 30 characters and all random,
|
6
6
|
# no regular words or you'll be exposed to dictionary attacks.
|
7
|
-
Dummy::Application.config.secret_token =
|
7
|
+
Dummy::Application.config.secret_token = "99c0312cf416079a8c7ccc63acb1e9f4f" +
|
8
|
+
"17741398ec8022a2f4fb509c57f55b72486573e9816a026f507efbcd452a9e954d45c93c" +
|
9
|
+
"95d5bacd87e664ad6805d3f"
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# Be sure to restart your server when you modify this file.
|
2
2
|
|
3
|
-
Dummy::Application.config.session_store :cookie_store, :
|
3
|
+
Dummy::Application.config.session_store :cookie_store, key: "_dummy_session"
|
4
4
|
|
5
5
|
# Use the database for sessions instead of the cookie-based default,
|
6
6
|
# which shouldn't be used to store highly confidential information
|
data/test/dummy/config/routes.rb
CHANGED
@@ -1,33 +1,49 @@
|
|
1
|
+
# Keep this migration in sync with
|
2
|
+
# `lib/generators/paper_trail/templates/create_versions.rb`
|
3
|
+
# TODO: Is there a way to avoid duplication?
|
1
4
|
class SetUpTestTables < ActiveRecord::Migration
|
2
|
-
|
3
|
-
|
5
|
+
MYSQL_ADAPTERS = [
|
6
|
+
"ActiveRecord::ConnectionAdapters::MysqlAdapter",
|
7
|
+
"ActiveRecord::ConnectionAdapters::Mysql2Adapter"
|
8
|
+
].freeze
|
9
|
+
TEXT_BYTES = 1_073_741_823
|
10
|
+
|
11
|
+
def up
|
12
|
+
# Classes: Vehicle, Car, Truck
|
13
|
+
create_table :vehicles, force: true do |t|
|
14
|
+
t.string :name, null: false
|
15
|
+
t.string :type, null: false
|
16
|
+
t.timestamps null: false
|
17
|
+
end
|
18
|
+
|
19
|
+
create_table :skippers, force: true do |t|
|
4
20
|
t.string :name
|
5
21
|
t.datetime :another_timestamp
|
6
|
-
t.timestamps :
|
22
|
+
t.timestamps null: true
|
7
23
|
end
|
8
24
|
|
9
|
-
create_table :widgets, :
|
25
|
+
create_table :widgets, force: true do |t|
|
10
26
|
t.string :name
|
11
27
|
t.text :a_text
|
12
28
|
t.integer :an_integer
|
13
29
|
t.float :a_float
|
14
|
-
t.decimal :a_decimal, :
|
30
|
+
t.decimal :a_decimal, precision: 6, scale: 4
|
15
31
|
t.datetime :a_datetime
|
16
32
|
t.time :a_time
|
17
33
|
t.date :a_date
|
18
34
|
t.boolean :a_boolean
|
19
35
|
t.string :sacrificial_column
|
20
36
|
t.string :type
|
21
|
-
t.timestamps :
|
37
|
+
t.timestamps null: true
|
22
38
|
end
|
23
39
|
|
24
|
-
create_table :versions,
|
25
|
-
t.string :item_type, :
|
26
|
-
t.integer :item_id, :
|
27
|
-
t.string :event, :
|
40
|
+
create_table :versions, versions_table_options do |t|
|
41
|
+
t.string :item_type, null: false
|
42
|
+
t.integer :item_id, null: false
|
43
|
+
t.string :event, null: false
|
28
44
|
t.string :whodunnit
|
29
|
-
t.text :object
|
30
|
-
t.text :object_changes
|
45
|
+
t.text :object, limit: TEXT_BYTES
|
46
|
+
t.text :object_changes, limit: TEXT_BYTES
|
31
47
|
t.integer :transaction_id
|
32
48
|
t.datetime :created_at
|
33
49
|
|
@@ -46,16 +62,18 @@ class SetUpTestTables < ActiveRecord::Migration
|
|
46
62
|
|
47
63
|
create_table :version_associations do |t|
|
48
64
|
t.integer :version_id
|
49
|
-
t.string :foreign_key_name, :
|
65
|
+
t.string :foreign_key_name, null: false
|
50
66
|
t.integer :foreign_key_id
|
51
67
|
end
|
52
68
|
add_index :version_associations, [:version_id]
|
53
|
-
add_index :version_associations,
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
t.string :
|
69
|
+
add_index :version_associations,
|
70
|
+
[:foreign_key_name, :foreign_key_id],
|
71
|
+
name: "index_version_associations_on_foreign_key"
|
72
|
+
|
73
|
+
create_table :post_versions, force: true do |t|
|
74
|
+
t.string :item_type, null: false
|
75
|
+
t.integer :item_id, null: false
|
76
|
+
t.string :event, null: false
|
59
77
|
t.string :whodunnit
|
60
78
|
t.text :object
|
61
79
|
t.datetime :created_at
|
@@ -66,11 +84,11 @@ class SetUpTestTables < ActiveRecord::Migration
|
|
66
84
|
end
|
67
85
|
add_index :post_versions, [:item_type, :item_id]
|
68
86
|
|
69
|
-
if ENV[
|
70
|
-
create_table :json_versions, :
|
71
|
-
t.string :item_type, :
|
72
|
-
t.integer :item_id, :
|
73
|
-
t.string :event, :
|
87
|
+
if ENV["DB"] == "postgres" && ::ActiveRecord::VERSION::MAJOR >= 4
|
88
|
+
create_table :json_versions, force: true do |t|
|
89
|
+
t.string :item_type, null: false
|
90
|
+
t.integer :item_id, null: false
|
91
|
+
t.string :event, null: false
|
74
92
|
t.string :whodunnit
|
75
93
|
t.json :object
|
76
94
|
t.json :object_changes
|
@@ -79,168 +97,186 @@ class SetUpTestTables < ActiveRecord::Migration
|
|
79
97
|
add_index :json_versions, [:item_type, :item_id]
|
80
98
|
end
|
81
99
|
|
82
|
-
create_table :not_on_updates, :
|
83
|
-
t.timestamps :
|
100
|
+
create_table :not_on_updates, force: true do |t|
|
101
|
+
t.timestamps null: true
|
84
102
|
end
|
85
103
|
|
86
|
-
create_table :bananas, :
|
87
|
-
t.timestamps :
|
104
|
+
create_table :bananas, force: true do |t|
|
105
|
+
t.timestamps null: true
|
88
106
|
end
|
89
107
|
|
90
|
-
create_table :banana_versions, :
|
91
|
-
t.string :item_type, :
|
92
|
-
t.integer :item_id, :
|
93
|
-
t.string :event, :
|
108
|
+
create_table :banana_versions, force: true do |t|
|
109
|
+
t.string :item_type, null: false
|
110
|
+
t.integer :item_id, null: false
|
111
|
+
t.string :event, null: false
|
94
112
|
t.string :whodunnit
|
95
113
|
t.text :object
|
96
114
|
t.datetime :created_at
|
97
115
|
end
|
98
116
|
add_index :banana_versions, [:item_type, :item_id]
|
99
117
|
|
100
|
-
create_table :wotsits, :
|
118
|
+
create_table :wotsits, force: true do |t|
|
101
119
|
t.integer :widget_id
|
102
120
|
t.string :name
|
103
|
-
t.timestamps :
|
121
|
+
t.timestamps null: true
|
104
122
|
end
|
105
123
|
|
106
|
-
create_table :fluxors, :
|
124
|
+
create_table :fluxors, force: true do |t|
|
107
125
|
t.integer :widget_id
|
108
126
|
t.string :name
|
109
127
|
end
|
110
128
|
|
111
|
-
create_table :whatchamajiggers, :
|
129
|
+
create_table :whatchamajiggers, force: true do |t|
|
112
130
|
t.string :owner_type
|
113
131
|
t.integer :owner_id
|
114
132
|
t.string :name
|
115
133
|
end
|
116
134
|
|
117
|
-
create_table :articles, :
|
135
|
+
create_table :articles, force: true do |t|
|
118
136
|
t.string :title
|
119
137
|
t.string :content
|
120
138
|
t.string :abstract
|
121
139
|
t.string :file_upload
|
122
140
|
end
|
123
141
|
|
124
|
-
create_table :books, :
|
142
|
+
create_table :books, force: true do |t|
|
125
143
|
t.string :title
|
126
144
|
end
|
127
145
|
|
128
|
-
create_table :authorships, :
|
146
|
+
create_table :authorships, force: true do |t|
|
129
147
|
t.integer :book_id
|
130
|
-
t.integer :
|
148
|
+
t.integer :author_id
|
131
149
|
end
|
132
150
|
|
133
|
-
create_table :people, :
|
151
|
+
create_table :people, force: true do |t|
|
134
152
|
t.string :name
|
135
153
|
t.string :time_zone
|
136
154
|
end
|
137
155
|
|
138
|
-
create_table :editorships, :
|
156
|
+
create_table :editorships, force: true do |t|
|
139
157
|
t.integer :book_id
|
140
158
|
t.integer :editor_id
|
141
159
|
end
|
142
160
|
|
143
|
-
create_table :editors, :
|
161
|
+
create_table :editors, force: true do |t|
|
144
162
|
t.string :name
|
145
163
|
end
|
146
164
|
|
147
|
-
create_table :songs, :
|
165
|
+
create_table :songs, force: true do |t|
|
148
166
|
t.integer :length
|
149
167
|
end
|
150
168
|
|
151
|
-
create_table :posts, :
|
169
|
+
create_table :posts, force: true do |t|
|
152
170
|
t.string :title
|
153
171
|
t.string :content
|
154
172
|
end
|
155
173
|
|
156
|
-
create_table :post_with_statuses, :
|
174
|
+
create_table :post_with_statuses, force: true do |t|
|
157
175
|
t.integer :status
|
158
176
|
end
|
159
177
|
|
160
|
-
create_table :animals, :
|
178
|
+
create_table :animals, force: true do |t|
|
161
179
|
t.string :name
|
162
|
-
t.string :species
|
180
|
+
t.string :species # single table inheritance column
|
163
181
|
end
|
164
182
|
|
165
|
-
create_table :documents, :
|
183
|
+
create_table :documents, force: true do |t|
|
166
184
|
t.string :name
|
167
185
|
end
|
168
186
|
|
169
|
-
create_table :legacy_widgets, :
|
187
|
+
create_table :legacy_widgets, force: true do |t|
|
170
188
|
t.string :name
|
171
189
|
t.integer :version
|
172
190
|
end
|
173
191
|
|
174
|
-
create_table :things, :
|
192
|
+
create_table :things, force: true do |t|
|
175
193
|
t.string :name
|
176
194
|
end
|
177
195
|
|
178
|
-
create_table :translations, :
|
196
|
+
create_table :translations, force: true do |t|
|
179
197
|
t.string :headline
|
180
198
|
t.string :content
|
181
199
|
t.string :language_code
|
182
200
|
t.string :type
|
183
201
|
end
|
184
202
|
|
185
|
-
create_table :gadgets, :
|
203
|
+
create_table :gadgets, force: true do |t|
|
186
204
|
t.string :name
|
187
205
|
t.string :brand
|
188
|
-
t.timestamps :
|
206
|
+
t.timestamps null: true
|
189
207
|
end
|
190
208
|
|
191
|
-
create_table :customers, :
|
192
|
-
t.string
|
209
|
+
create_table :customers, force: true do |t|
|
210
|
+
t.string :name
|
193
211
|
end
|
194
212
|
|
195
|
-
create_table :orders, :
|
213
|
+
create_table :orders, force: true do |t|
|
196
214
|
t.integer :customer_id
|
197
215
|
t.string :order_date
|
198
216
|
end
|
199
217
|
|
200
|
-
create_table :line_items, :
|
218
|
+
create_table :line_items, force: true do |t|
|
201
219
|
t.integer :order_id
|
202
220
|
t.string :product
|
203
221
|
end
|
204
222
|
|
205
|
-
create_table :fruits, :
|
223
|
+
create_table :fruits, force: true do |t|
|
206
224
|
t.string :name
|
207
225
|
t.string :color
|
208
226
|
end
|
209
227
|
|
210
|
-
create_table :boolits, :
|
228
|
+
create_table :boolits, force: true do |t|
|
211
229
|
t.string :name
|
212
|
-
t.boolean :scoped, :
|
230
|
+
t.boolean :scoped, default: true
|
213
231
|
end
|
214
232
|
|
215
|
-
create_table :callback_modifiers, :
|
233
|
+
create_table :callback_modifiers, force: true do |t|
|
216
234
|
t.string :some_content
|
217
|
-
t.boolean :deleted, :
|
235
|
+
t.boolean :deleted, default: false
|
218
236
|
end
|
219
237
|
|
220
|
-
create_table :chapters, :
|
238
|
+
create_table :chapters, force: true do |t|
|
221
239
|
t.string :name
|
222
240
|
end
|
223
241
|
|
224
|
-
create_table :sections, :
|
242
|
+
create_table :sections, force: true do |t|
|
225
243
|
t.integer :chapter_id
|
226
244
|
t.string :name
|
227
245
|
end
|
228
246
|
|
229
|
-
create_table :paragraphs, :
|
247
|
+
create_table :paragraphs, force: true do |t|
|
230
248
|
t.integer :section_id
|
231
249
|
t.string :name
|
232
250
|
end
|
233
251
|
|
234
|
-
create_table :quotations, :
|
252
|
+
create_table :quotations, force: true do |t|
|
235
253
|
t.integer :chapter_id
|
236
254
|
end
|
237
255
|
|
238
|
-
create_table :citations, :
|
256
|
+
create_table :citations, force: true do |t|
|
239
257
|
t.integer :quotation_id
|
240
258
|
end
|
259
|
+
|
260
|
+
create_table :foo_habtms, force: true do |t|
|
261
|
+
t.string :name
|
262
|
+
end
|
263
|
+
|
264
|
+
create_table :bar_habtms, force: true do |t|
|
265
|
+
t.string :name
|
266
|
+
end
|
267
|
+
|
268
|
+
create_table :bar_habtms_foo_habtms, force: true, id: false do |t|
|
269
|
+
t.integer :foo_habtm_id
|
270
|
+
t.integer :bar_habtm_id
|
271
|
+
end
|
272
|
+
add_index :bar_habtms_foo_habtms, [:foo_habtm_id]
|
273
|
+
add_index :bar_habtms_foo_habtms, [:bar_habtm_id]
|
241
274
|
end
|
242
275
|
|
243
|
-
def
|
276
|
+
def down
|
277
|
+
drop_table :bar_habtms_foo_habtms
|
278
|
+
drop_table :foo_habtms
|
279
|
+
drop_table :bar_habtms
|
244
280
|
drop_table :citations
|
245
281
|
drop_table :quotations
|
246
282
|
drop_table :animals
|
@@ -257,12 +293,12 @@ class SetUpTestTables < ActiveRecord::Migration
|
|
257
293
|
drop_table :whatchamajiggers
|
258
294
|
drop_table :fluxors
|
259
295
|
drop_table :wotsits
|
260
|
-
remove_index :post_versions, :
|
296
|
+
remove_index :post_versions, column: [:item_type, :item_id]
|
261
297
|
drop_table :post_versions
|
262
|
-
remove_index :versions, :
|
298
|
+
remove_index :versions, column: [:item_type, :item_id]
|
263
299
|
drop_table :versions
|
264
300
|
if JsonVersion.table_exists?
|
265
|
-
remove_index :json_versions, :
|
301
|
+
remove_index :json_versions, column: [:item_type, :item_id]
|
266
302
|
drop_table :json_versions
|
267
303
|
end
|
268
304
|
drop_table :widgets
|
@@ -279,9 +315,19 @@ class SetUpTestTables < ActiveRecord::Migration
|
|
279
315
|
drop_table :chapters
|
280
316
|
drop_table :sections
|
281
317
|
drop_table :paragraphs
|
282
|
-
remove_index :version_associations, :
|
283
|
-
remove_index :version_associations, :
|
318
|
+
remove_index :version_associations, column: [:version_id]
|
319
|
+
remove_index :version_associations, name: "index_version_associations_on_foreign_key"
|
284
320
|
drop_table :version_associations
|
285
321
|
drop_table :callback_modifiers
|
286
322
|
end
|
323
|
+
|
324
|
+
private
|
325
|
+
|
326
|
+
def versions_table_options
|
327
|
+
opts = { force: true }
|
328
|
+
if MYSQL_ADAPTERS.include?(connection.class.name)
|
329
|
+
opts[:options] = "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
|
330
|
+
end
|
331
|
+
opts
|
332
|
+
end
|
287
333
|
end
|
data/test/dummy/db/schema.rb
CHANGED
@@ -27,7 +27,7 @@ ActiveRecord::Schema.define(version: 20110208155312) do
|
|
27
27
|
|
28
28
|
create_table "authorships", force: :cascade do |t|
|
29
29
|
t.integer "book_id"
|
30
|
-
t.integer "
|
30
|
+
t.integer "author_id"
|
31
31
|
end
|
32
32
|
|
33
33
|
create_table "banana_versions", force: :cascade do |t|
|
@@ -46,6 +46,18 @@ ActiveRecord::Schema.define(version: 20110208155312) do
|
|
46
46
|
t.datetime "updated_at"
|
47
47
|
end
|
48
48
|
|
49
|
+
create_table "bar_habtms", force: :cascade do |t|
|
50
|
+
t.string "name"
|
51
|
+
end
|
52
|
+
|
53
|
+
create_table "bar_habtms_foo_habtms", id: false, force: :cascade do |t|
|
54
|
+
t.integer "foo_habtm_id"
|
55
|
+
t.integer "bar_habtm_id"
|
56
|
+
end
|
57
|
+
|
58
|
+
add_index "bar_habtms_foo_habtms", ["bar_habtm_id"], name: "index_bar_habtms_foo_habtms_on_bar_habtm_id"
|
59
|
+
add_index "bar_habtms_foo_habtms", ["foo_habtm_id"], name: "index_bar_habtms_foo_habtms_on_foo_habtm_id"
|
60
|
+
|
49
61
|
create_table "books", force: :cascade do |t|
|
50
62
|
t.string "title"
|
51
63
|
end
|
@@ -90,6 +102,10 @@ ActiveRecord::Schema.define(version: 20110208155312) do
|
|
90
102
|
t.string "name"
|
91
103
|
end
|
92
104
|
|
105
|
+
create_table "foo_habtms", force: :cascade do |t|
|
106
|
+
t.string "name"
|
107
|
+
end
|
108
|
+
|
93
109
|
create_table "fruits", force: :cascade do |t|
|
94
110
|
t.string "name"
|
95
111
|
t.string "color"
|
@@ -185,6 +201,13 @@ ActiveRecord::Schema.define(version: 20110208155312) do
|
|
185
201
|
t.string "type"
|
186
202
|
end
|
187
203
|
|
204
|
+
create_table "vehicles", force: :cascade do |t|
|
205
|
+
t.string "name", null: false
|
206
|
+
t.string "type", null: false
|
207
|
+
t.datetime "created_at", null: false
|
208
|
+
t.datetime "updated_at", null: false
|
209
|
+
end
|
210
|
+
|
188
211
|
create_table "version_associations", force: :cascade do |t|
|
189
212
|
t.integer "version_id"
|
190
213
|
t.string "foreign_key_name", null: false
|
@@ -195,12 +218,12 @@ ActiveRecord::Schema.define(version: 20110208155312) do
|
|
195
218
|
add_index "version_associations", ["version_id"], name: "index_version_associations_on_version_id"
|
196
219
|
|
197
220
|
create_table "versions", force: :cascade do |t|
|
198
|
-
t.string "item_type",
|
199
|
-
t.integer "item_id",
|
200
|
-
t.string "event",
|
221
|
+
t.string "item_type", null: false
|
222
|
+
t.integer "item_id", null: false
|
223
|
+
t.string "event", null: false
|
201
224
|
t.string "whodunnit"
|
202
|
-
t.text "object"
|
203
|
-
t.text "object_changes"
|
225
|
+
t.text "object", limit: 1073741823
|
226
|
+
t.text "object_changes", limit: 1073741823
|
204
227
|
t.integer "transaction_id"
|
205
228
|
t.datetime "created_at"
|
206
229
|
t.integer "answer"
|