Sha256: 9eea0408e42e3526250e5fcc0417ecbe03d96252dbeda8ee98c89c1fa4591de2

Contents?: true

Size: 838 Bytes

Versions: 21

Compression:

Stored size: 838 Bytes

Contents

# frozen_string_literal: true

module Thredded
  class BaseMigration < (Thredded.rails_gte_51? ? ActiveRecord::Migration[5.1] : ActiveRecord::Migration)
    protected

    def user_id_type
      Thredded.user_class.columns.find { |c| c.name == Thredded.user_class.primary_key }.sql_type
    end

    def column_type(table, column_name)
      column_name = column_name.to_s
      columns(table).find { |c| c.name == column_name }.sql_type
    end

    # @return [Integer, nil] the maximum number of codepoints that can be indexed for a primary key or index.
    def max_key_length
      return nil unless connection.adapter_name =~ /mysql|maria/i
      # Conservatively assume that innodb_large_prefix is **disabled**.
      # If it were enabled, the maximum key length would instead be 768 utf8mb4 characters.
      191
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
thredded-0.16.16 lib/thredded/base_migration.rb
thredded-0.16.15 lib/thredded/base_migration.rb
thredded-0.16.14 lib/thredded/base_migration.rb
thredded-0.16.13 lib/thredded/base_migration.rb
thredded-0.16.12 lib/thredded/base_migration.rb
thredded-0.16.11 lib/thredded/base_migration.rb
thredded-0.16.10 lib/thredded/base_migration.rb
thredded-0.16.9 lib/thredded/base_migration.rb
thredded-0.16.8 lib/thredded/base_migration.rb
thredded-0.16.7 lib/thredded/base_migration.rb
thredded-0.16.6 lib/thredded/base_migration.rb
thredded-0.16.5 lib/thredded/base_migration.rb
thredded-0.16.4 lib/thredded/base_migration.rb
thredded-0.16.3 lib/thredded/base_migration.rb
thredded-0.16.1 lib/thredded/base_migration.rb
thredded-0.16.0 lib/thredded/base_migration.rb
thredded-0.15.5 lib/thredded/base_migration.rb
thredded-0.15.4 lib/thredded/base_migration.rb
thredded-0.15.3 lib/thredded/base_migration.rb
thredded-0.15.2 lib/thredded/base_migration.rb