Commit graph

18 commits

Author SHA1 Message Date
Sean McGivern
d8be981466 Prevent update_column_in_batches on large tables
add_column_with_default is implemented in terms of update_column_in_batches, but
update_column_in_batches can be used independently. Neither of these should be
used on the specified large tables, because they will cause issues on large
instances like GitLab.com.

This also ignores the cop for all existing migrations, renaming
AddColumnWithDefaultToLargeTable where appropriate.
2017-11-17 16:56:50 +00:00
Sean McGivern
a560291f14 Also warn on timestamp in datetime migration cop
The types `timestamp` and `datetime` are aliases:
https://github.com/rails/rails/blob/v4.2.10/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb#L362-L364
2017-10-10 10:36:10 +01:00
Michael Kozono
9beef18487 Add SaferBooleanColumn cop 2017-08-14 07:57:57 -07:00
Shinya Maeda
953aa380eb ini 2017-08-01 14:16:10 +09:00
Robert Speicher
02139f5a77 Update the large table list in AddColumnWithDefaultToLargeTable cop
- ci_builds -- 33 million rows, 55 GB
- merge_request_diff_files -- 5 million rows, 9 GB (and growing rapidly)
- merge_request_diffs -- 5 million rows, 190 GB
2017-07-26 12:40:59 -04:00
Yorick Peterse
a004f9ec8c
Added cop to blacklist the use of hash indexes
These indexes are not recorded in the WAL (at least until PostgreSQL
10) and this isn't worth the minor performance improvement over btree
indexes.
2017-07-14 13:19:00 +02:00
blackst0ne
bc00806a4e Add database helpers 'add_timestamps_with_timezone' and 'timestamps_with_timezone' 2017-06-13 22:44:13 +11:00
Rémy Coutable
187e6c8d7c New Migration/UpdateColumnInBatches cop
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-05-29 11:28:23 +02:00
Robert Speicher
b9fa17d87b Add AddColumnWithDefaultToLargeTable cop 2017-04-28 15:55:55 -05:00
Robert Speicher
9c27c90b4a Rename AddColumnWithDefault to ReversibleAddColumnWithDefault
We're going to add another cop that deals with another aspect of
`add_column_with_default`, so we need to separate them.
2017-04-28 15:55:53 -05:00
Robert Speicher
bbdaf982e6 Refactor the AddColumnWithDefault cop to use node matchers 2017-04-28 15:55:53 -05:00
blackst0ne
9997c58fc0 Add remove_concurrent_index to database helper 2017-04-06 09:53:57 +11:00
Douwe Maan
5d9762b3b5 Add cop to ensure reversibility of add_concurrent_index 2017-03-07 10:09:01 -06:00
Douwe Maan
b7d8df503c Enable Style/MutableConstant 2017-02-23 09:31:56 -06:00
Yorick Peterse
766060bcdf
Enforce use of add_concurrent_foreign_key
This adds a Rubocop rule to enforce the use of
add_concurrent_foreign_key instead of the regular add_foreign_key
method. This cop has been disabled for existing migrations so we don't
need to change those.
2017-02-10 21:51:09 +01:00
Douwe Maan
b0afed1aac Explicitly require rubocop migration_helpers 2017-02-08 16:47:48 -06:00
Douwe Maan
abc9548f8a Add cop that checks if add_column_with_default is used with up/down methods 2017-02-08 16:47:48 -06:00
Yorick Peterse
c740445ad3
Added RuboCop cops for checking DB migrations
There are currently two cops for this:

* Migration/AddIndex: checks if indexes are added concurrently
* Migration/ColumnWithDefault: checks if columns with default values are
  added in a concurrent manner

Both cops are fairly simple and make no attempt at correcting the code
as this is quite hard to do (e.g. modifications may need to be applied
in various places in the same file). They however should provide enough
to catch people ignoring the comments in generated migrations telling
them to use add_concurrent_index or add_column_with_default.
2016-06-29 14:14:02 +02:00