Last active
November 8, 2018 21:04
-
-
Save noahpryor/537c98937a1b523f6a044c7ac13d117d to your computer and use it in GitHub Desktop.
check for integer columns in a rails schema
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
desc "Check for integer columns that should be migrated to bigint" | |
task bigint_check: :environment do | |
ActiveRecord::Base.connection.tables.each do |table_name| | |
ActiveRecord::Base.connection.columns(table_name).each do |column| | |
if column.sql_type == "integer" | |
puts "Warning: #{table_name}.#{column.name} is of type integer rather than bigint" | |
end | |
end | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment