Module: Dagable::MigrationHelpers
- Defined in:
- lib/dagable/migration_helpers.rb
Overview
Schema helpers for creating the two supporting tables that every dagable model requires. Include this module in your migration class.
Usage
class CreateCategoryDag < ActiveRecord::Migration[8.1]
include Dagable::MigrationHelpers
def change
create_dagable_tables(:categories)
end
end
This creates:
-
categories_edgeswithparent_idandchild_idcolumns, a unique composite index, and foreign keys back to the source table -
categories_ancestrieswithpredecessor_id,successor_id, anddepthcolumns, a unique composite index, individual indexes on each foreign key, and foreign keys back to the source table
Instance Method Summary collapse
-
#create_dagable_tables(source_table_name) ⇒ Object
Creates the edge and ancestry tables for the given
source_table_name.
Instance Method Details
#create_dagable_tables(source_table_name) ⇒ Object
Creates the edge and ancestry tables for the given source_table_name.
28 29 30 31 |
# File 'lib/dagable/migration_helpers.rb', line 28 def create_dagable_tables(source_table_name) create_dagable_edges_table(source_table_name) create_dagable_ancestries_table(source_table_name) end |