Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mysql2::Error: Table 'myapp_development.action_text_rich_texts' doesn't exist #146

Open
timokleemann opened this issue Aug 25, 2023 · 1 comment · May be fixed by #150
Open

Mysql2::Error: Table 'myapp_development.action_text_rich_texts' doesn't exist #146

timokleemann opened this issue Aug 25, 2023 · 1 comment · May be fixed by #150

Comments

@timokleemann
Copy link

I would love to use this gem but when I run rake db:find_indexes in my Rails 7 application I am getting:

Mysql2::Error: Table 'myapp_development.action_text_rich_texts' doesn't exist

@Jellyfishboy
Copy link

@timokleemann Run rails g migration CreateActionTextTables

Then add this to the migration:

  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

fightingtheboss added a commit to fightingtheboss/lol_dba that referenced this issue Mar 7, 2024
The `LolDba::IndexFinder` was iterating over all subclasses of `ActiveRecord::Base`, including abstract classes that don't have backing tables in the DB (namely ActionText and ActionMailbox).

This change simply omits abstract classes from the search for missing indices.

Resolves plentz#146
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants