Class: Categories

Inherits:
Sequel::Migration
  • Object
show all
Defined in:
lib/lumix/schema/002_categories.rb

Instance Method Summary collapse

Instance Method Details

#downObject



21
22
23
24
25
26
# File 'lib/lumix/schema/002_categories.rb', line 21

def down
  alter_table :texts do
    drop_column :category_id
  end
  drop_table :categories
end

#upObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/lumix/schema/002_categories.rb', line 3

def up
  create_table :categories do
    primary_key :id
    Integer :parent_id, :references => :categories
    String :name
    String :key

    index [:parent_id, :id]
  end

  alter_table :texts do
    add_column :category_id, Integer, :references => :categories

    add_index [:category_id, :id]
  end

end