Sha256: b6a5dd8a5fe5276ca5562ad64ac58900a1c472ae6d41a70238a9d1b1cf2a4dde
Contents?: true
Size: 1.03 KB
Versions: 4
Compression:
Stored size: 1.03 KB
Contents
# frozen_string_literal: true require "active_record_doctor/detectors/base" module ActiveRecordDoctor module Detectors class ShortPrimaryKeyType < Base # :nodoc: @description = "detect primary keys with short integer types" @config = { ignore_tables: { description: "tables whose primary keys should not be checked", global: true } } private def message(table:, column:) "change the type of #{table}.#{column} to bigint" end def detect each_table(except: config(:ignore_tables)) do |table| column = primary_key(table) next if column.nil? next if !integer?(column) || bigint?(column) problem!(table: table, column: column.name) end end def bigint?(column) if column.respond_to?(:bigint?) column.bigint? else /\Abigint\b/.match?(column.sql_type) end end def integer?(column) column.type == :integer end end end end
Version data entries
4 entries across 4 versions & 1 rubygems