Sha256: dd1ae59ddba41f34bbb84e3ff270a8090bcf7c07d8012908e2baa823bf69437e

Contents?: true

Size: 790 Bytes

Versions: 2

Compression:

Stored size: 790 Bytes

Contents

# frozen_string_literal: true

module Thredded
  class BaseMigration < ActiveRecord::Migration[5.1]
    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 /mysql|maria/i.match?(connection.adapter_name)
      # 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

2 entries across 2 versions & 1 rubygems

Version Path
thredded-1.1.0 lib/thredded/base_migration.rb
thredded-1.0.1 lib/thredded/base_migration.rb