Sha256: 95922a2f044e8b8176e11f76dfe14448179c20cca88eaf009088a314f98a116b
Contents?: true
Size: 761 Bytes
Versions: 2
Compression:
Stored size: 761 Bytes
Contents
class CreateTags < ActiveRecord::Migration def change create_table :tags do |t| t.string :name t.integer :parent_id t.timestamps end create_table :tags_hierarchies, :id => false do |t| t.integer :ancestor_id, :null => false # ID of the parent/grandparent/great-grandparent/... tag t.integer :descendant_id, :null => false # ID of the target tag t.integer :generations, :null => false # Number of generations between the ancestor and the descendant. Parent/child = 1, for example. end # For "all progeny of..." selects: add_index :tags_hierarchies, [:ancestor_id, :descendant_id], :unique => true # For "all ancestors of..." selects add_index :tags_hierarchies, :descendant_id end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
closure_tree-1.0.0.beta2 | test/dummy/db/migrate/20110522004834_create_tags.rb |
closure_tree-1.0.0.beta1 | test/dummy/db/migrate/20110522004834_create_tags.rb |