-
-
Save mulder/730441 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :oracle do | |
desc "Check column names against the oracle reserved words" | |
task :check_column_names => [:environment] do |t| | |
if ActiveRecord::Base.connection.adapter_name =~ /oracle/i | |
found = [] | |
ActiveRecord::Base.connection.tables.each do |table_name| | |
model = table_name.singularize.classify.constantize rescue nil | |
model.columns.each do |column| | |
if ActiveRecord::ConnectionAdapters::OracleEnhancedReservedWords::RESERVED_WORDS[column.name.to_s.upcase] | |
found << "Table: #{table_name}, Column: #{column.name}" | |
end | |
end if model | |
end | |
unless found.empty? | |
puts "Reserved words found:" | |
found.each{|f| puts " - #{f}"} | |
end | |
else | |
puts "You must be using an oracle adapter to run this task" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment