A RuboCop extension for Active Record Oracle enhanced adapter.
Just install the rubocop-oracle
gem
gem install rubocop-oracle
or if you use bundler put this in your Gemfile
gem 'rubocop-oracle'
This gem contains Oracle/OnlineIndex
cop to check if indexing is possible without stopping Rails application' service using Oracle.
The cop supports safe migration for your production environment.
This cop checks for uses options: online
option on add_index
.
The ONLINE
option is required if you want to run with OLTP when indexing migration in Oracle.
# bad
add_index :table_name, :column_name
# good
add_index :table_name, :column_name, options: :online
By specifying MigratedSchemaVersion
option, migration files that have been migrated can be ignored.
# .rubocop.yml
Oracle/OnlineIndex:
MigratedSchemaVersion: '202104130150' # Migration files lower than or equal to '202104130150' will be ignored.
This prevents detection of migration files that have already been applied to the production environment.
You need to tell RuboCop to load the Oracle extension. There are three ways to do this:
Put this into your .rubocop.yml
.
require: rubocop-oracle
Alternatively, use the following array notation when specifying multiple extensions.
require:
- rubocop-other-extension
- rubocop-oracle
Now you can run rubocop
and it will automatically load the RuboCop Oracle
cops together with the standard cops.
rubocop --require rubocop-oracle
RuboCop::RakeTask.new do |task|
task.requires << 'rubocop-oracle'
end
Bug reports and pull requests are welcome on GitHub at https://github.com/koic/rubocop-oracle.
The gem is available as open source under the terms of the MIT License.