voormedia / rails-erd

Generate Entity-Relationship Diagrams for Rails applications
http://voormedia.github.io/rails-erd/
MIT License
4k stars 367 forks source link

Warnings on Rails internal tables that have not been created #389

Closed scarroll32 closed 2 years ago

scarroll32 commented 2 years ago

Warning messages are seen for internal Rails models that have not had tables generated.

Steps to reproduce under Rails 7.0.3 and ruby 3.0.3p157.

Setup a Rails 7 app

rails new rails7.0.3ruby3.0.3 -d postgresql
cd rails7.0.3ruby3.0.3
rails g scaffold Post title:string body:text
rails g model Comment post:references comment:string author:string
bin/rails db:create
rails db:migrate

Add the rails-erd gem

gem 'rails-erd', group: :development

bundle

Run the rake task

❯ bundle exec erd
Loading application in 'rails7.0.3ruby3.0.3'...
Generating entity-relationship diagram for 12 models...
Warning: Ignoring invalid model ActionMailbox::InboundEmail (table action_mailbox_inbound_emails does not exist)
Warning: Ignoring invalid model ActiveStorage::Attachment (table active_storage_attachments does not exist)
Warning: Ignoring invalid model ActiveStorage::Blob (table active_storage_blobs does not exist)
Warning: Ignoring invalid model ActiveStorage::VariantRecord (table active_storage_variant_records does not exist)
Warning: Ignoring invalid model ActionText::RichText (table action_text_rich_texts does not exist)
Warning: Ignoring invalid model ActionText::EncryptedRichText (table action_text_rich_texts does not exist)
Diagram saved to 'erd.pdf'.
Screenshot 2022-06-13 at 23 10 05

Database tables

psql -d rails7_0_3ruby3_0_3_development
psql (14.2)
Type "help" for help.

rails7_0_3ruby3_0_3_development=# \dt
               List of relations
 Schema |         Name         | Type  | Owner
--------+----------------------+-------+-------
 public | ar_internal_metadata | table | sean
 public | comments             | table | sean
 public | posts                | table | sean
 public | schema_migrations    | table | sean
(4 rows)
scarroll32 commented 2 years ago

This issue has been also encountered in the RailsAdmin gem https://github.com/railsadminteam/rails_admin/issues/3157

scarroll32 commented 2 years ago

Creating the tables predictably removes the warnings

❯ rails active_storage:install
Copied migration 20220613211050_create_active_storage_tables.active_storage.rb from active_storage

~/src/erd/rails7.0.3ruby3.0.3 main*
❯ rails db:migrate
== 20220613211050 CreateActiveStorageTables: migrating ========================
-- create_table(:active_storage_blobs, {:id=>:primary_key})
   -> 0.0108s
-- create_table(:active_storage_attachments, {:id=>:primary_key})
   -> 0.0086s
-- create_table(:active_storage_variant_records, {:id=>:primary_key})
   -> 0.0042s
== 20220613211050 CreateActiveStorageTables: migrated (0.0237s) ===============

~/src/erd/rails7.0.3ruby3.0.3 main*
❯ bundle exec erd
Loading application in 'rails7.0.3ruby3.0.3'...
Generating entity-relationship diagram for 12 models...
Warning: Ignoring invalid model ActionMailbox::InboundEmail (table action_mailbox_inbound_emails does not exist)
Warning: Ignoring invalid model ActionText::RichText (table action_text_rich_texts does not exist)
Warning: Ignoring invalid model ActionText::EncryptedRichText (table action_text_rich_texts does not exist)
Diagram saved to 'erd.pdf'.
Screenshot 2022-06-13 at 23 11 57