Skip to content

Instantly share code, notes, and snippets.

@noahpryor
Last active November 8, 2018 21:04
Show Gist options
  • Save noahpryor/537c98937a1b523f6a044c7ac13d117d to your computer and use it in GitHub Desktop.
Save noahpryor/537c98937a1b523f6a044c7ac13d117d to your computer and use it in GitHub Desktop.
check for integer columns in a rails schema
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