Module: Dbviewer::RelationshipManagement
- Extended by:
- ActiveSupport::Concern
- Included in:
- DatabaseOperations
- Defined in:
- app/controllers/concerns/dbviewer/relationship_management.rb
Instance Method Summary collapse
-
#fetch_mini_erd_for_table(table_name) ⇒ Object
Get mini ERD data for a specific table and its relationships.
-
#fetch_table_relationships(tables) ⇒ Object
Fetch relationships between tables for ERD visualization.
Instance Method Details
#fetch_mini_erd_for_table(table_name) ⇒ Object
Get mini ERD data for a specific table and its relationships
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/controllers/concerns/dbviewer/relationship_management.rb', line 11 def fetch_mini_erd_for_table(table_name) outgoing_data = collect_outgoing_relationships(table_name) incoming_data = collect_incoming_relationships(table_name) initial_tables = [ { name: table_name } ] all_relationships = outgoing_data[:relationships] + incoming_data[:relationships] all_tables = (initial_tables + outgoing_data[:tables] + incoming_data[:tables]).uniq { |t| t[:name] } { tables: all_tables, relationships: all_relationships, timestamp: Time.now.to_i } end |
#fetch_table_relationships(tables) ⇒ Object
Fetch relationships between tables for ERD visualization
6 7 8 |
# File 'app/controllers/concerns/dbviewer/relationship_management.rb', line 6 def fetch_table_relationships(tables) tables.flat_map { |table| (table[:name]) } end |