Skip to content

Commit b861061

Browse files
committed
Make Rails/CreateTableWithTimestamps respect active_storage_variant_records table
This PR makes `Rails/CreateTableWithTimestamps` respect `active_storage_variant_records` table of `db/migrate/*_create_active_storage_tables.active_storage.rb` auto-generated by `bin/rails active_storage:install` even if `created_at` is not specified. It suppresses the following offense. ```console % bin/rails -v Rails 6.1.4.1 % bin/rails active_storage:install Copied migration 20210929095151_create_active_storage_tables.active_storage.rb from active_storage % bundle exec rubocop --only Rails/CreateTableWithTimestamps Inspecting 1 file C Offenses: db/migrate/20210929095151_create_active_storage_tables.active_storage.rb:28:5: C: Rails/CreateTableWithTimestamps: Add timestamps when creating a new table. create_table :active_storage_variant_records do |t| ... ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1 file inspected, 1 offense detected ``` As far as I've heard from Rails committers, `active_storage_variant_records` table hasn't timestamp columns, probably as a result of discussions in the Rails community. If you want to consider the need, please discuss it with https://discuss.rubyonrails.org and give us feedback.
1 parent 7579e81 commit b861061

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* [#570](https://github.com/rubocop/rubocop-rails/pull/570): Make `Rails/CreateTableWithTimestamps` respect `active_storage_variant_records` table of `db/migrate/*_create_active_storage_tables.active_storage.rb` auto-generated by `bin/rails active_storage:install` even if `created_at` is not specified. ([@koic][])

config/default.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,10 @@ Rails/CreateTableWithTimestamps:
201201
VersionAdded: '0.52'
202202
Include:
203203
- db/migrate/*.rb
204+
Exclude:
205+
# Respect the `active_storage_variant_records` table of `*_create_active_storage_tables.active_storage.rb`
206+
# auto-generated by `bin/rails active_storage:install` even if `created_at` is not specified.
207+
- db/migrate/*_create_active_storage_tables.active_storage.rb
204208

205209
Rails/Date:
206210
Description: >-

docs/modules/ROOT/pages/cops_rails.adoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -923,6 +923,10 @@ end
923923
| Include
924924
| `db/migrate/*.rb`
925925
| Array
926+
927+
| Exclude
928+
| `db/migrate/*_create_active_storage_tables.active_storage.rb`
929+
| Array
926930
|===
927931

928932
== Rails/Date

0 commit comments

Comments
 (0)