Sha256: abb0949dd7d951d513fbc4635150eb417e18a2abb6faa09f36c6052c02ebde53

Contents?: true

Size: 1.05 KB

Versions: 4

Compression:

Stored size: 1.05 KB

Contents

# -*- encoding: utf-8 -*-
# -*- frozen_string_literal: true -*-
# -*- warn_indent: true -*-

# This migration comes from action_text (originally 20180528164100)
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

4 entries across 4 versions & 1 rubygems

Version Path
rails_bootstrap_form-0.9.9 demo/db/migrate/20230621041642_create_action_text_tables.action_text.rb
rails_bootstrap_form-0.9.8 demo/db/migrate/20230621041642_create_action_text_tables.action_text.rb
rails_bootstrap_form-0.9.7 demo/db/migrate/20230621041642_create_action_text_tables.action_text.rb
rails_bootstrap_form-0.9.6 demo/db/migrate/20230621041642_create_action_text_tables.action_text.rb