Class: TagDb::CreateDb
- Inherits:
-
ActiveRecord::Migration
- Object
- ActiveRecord::Migration
- TagDb::CreateDb
- Defined in:
- lib/tagutils/tags/schema.rb
Instance Method Summary collapse
Instance Method Details
#down ⇒ Object
39 40 41 |
# File 'lib/tagutils/tags/schema.rb', line 39 def down raise ActiveRecord::IrreversibleMigration end |
#up ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/tagutils/tags/schema.rb', line 7 def up create_table :tags do |t| t.string :key, null: false t.string :slug, null: false t.string :name # todo: make required? -- note: was title formerly t.integer :grade, null: false, default: 1 # grade/tier e.g. 1/2/3 for now # parent used for hierachy (e.g. lets you use tag stacks/packs etc.) t.references :parent # todo: use only t.datetime :created_at (do we get ar magic? is updated used/needed??) t. end add_index :tags, :key, unique: true create_table :taggings do |t| t.references :tag, null: false t.references :taggable, null: false, polymorphic: true # todo: use only t.datetime :created_at (do we get ar magic? is updated used/needed??) t. end add_index :taggings, :tag_id add_index :taggings, [:taggable_id, :taggable_type] add_index :taggings, [:taggable_id, :taggable_type, :tag_id], unique: true end |