Sha256: d1ed6e7cec840d3ee27b4c967858b30a14f343ac9888b920ad3d858594bfd8d5

Contents?: true

Size: 914 Bytes

Versions: 22

Compression:

Stored size: 914 Bytes

Contents

class CreateActionTextTables < ActiveRecord::Migration[6.0]
  def change
    # Use Active Record's configured type for primary and foreign keys
    primary_key_type, foreign_key_type = primary_and_foreign_key_types

    create_table :action_text_rich_texts, id: primary_key_type do |t|
      t.string     :name, null: false
      t.text       :body, size: :long
      t.references :record, null: false, polymorphic: true, index: false, type: foreign_key_type

      t.timestamps

      t.index [ :record_type, :record_id, :name ], name: "index_action_text_rich_texts_uniqueness", unique: true
    end
  end

  private
    def primary_and_foreign_key_types
      config = Rails.configuration.generators
      setting = config.options[config.orm][:primary_key_type]
      primary_key_type = setting || :primary_key
      foreign_key_type = setting || :bigint
      [ primary_key_type, foreign_key_type ]
    end
end

Version data entries

22 entries across 22 versions & 2 rubygems

Version Path
actiontext-8.0.2 db/migrate/20180528164100_create_action_text_tables.rb
actiontext-8.0.1 db/migrate/20180528164100_create_action_text_tables.rb
actiontext-8.0.0.1 db/migrate/20180528164100_create_action_text_tables.rb
actiontext-7.2.2.1 db/migrate/20180528164100_create_action_text_tables.rb
actiontext-8.0.0 db/migrate/20180528164100_create_action_text_tables.rb
actiontext-7.2.2 db/migrate/20180528164100_create_action_text_tables.rb
actiontext-8.0.0.rc2 db/migrate/20180528164100_create_action_text_tables.rb
actiontext-7.2.1.2 db/migrate/20180528164100_create_action_text_tables.rb
actiontext-8.0.0.rc1 db/migrate/20180528164100_create_action_text_tables.rb
actiontext-7.2.1.1 db/migrate/20180528164100_create_action_text_tables.rb
actiontext-8.0.0.beta1 db/migrate/20180528164100_create_action_text_tables.rb
omg-actiontext-8.0.0.alpha9 db/migrate/20180528164100_create_action_text_tables.rb
omg-actiontext-8.0.0.alpha8 db/migrate/20180528164100_create_action_text_tables.rb
omg-actiontext-8.0.0.alpha7 db/migrate/20180528164100_create_action_text_tables.rb
omg-actiontext-8.0.0.alpha4 db/migrate/20180528164100_create_action_text_tables.rb
omg-actiontext-8.0.0.alpha3 db/migrate/20180528164100_create_action_text_tables.rb
actiontext-7.2.1 db/migrate/20180528164100_create_action_text_tables.rb
actiontext-7.2.0 db/migrate/20180528164100_create_action_text_tables.rb
actiontext-7.2.0.rc1 db/migrate/20180528164100_create_action_text_tables.rb
actiontext-7.2.0.beta3 db/migrate/20180528164100_create_action_text_tables.rb