Class: CreateLookupTables

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

Instance Method Summary collapse

Instance Method Details

#downObject



38
39
40
41
42
# File 'lib/lumix/schema/004_create_lookup_tables.rb', line 38

def down
  drop_table :tokens
  drop_table :words
  drop_table :tags
end

#upObject



3
4
5
6
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/lumix/schema/004_create_lookup_tables.rb', line 3

def up
  create_table :tags do
    primary_key :id
    String :tag

    index :tag, :unique => true
  end

  create_table :words do
    primary_key :id
    String :word

    index :word, :unique => true
  end

  create_table :tokens do
    primary_key :id
    Integer :text_id, :references => :texts

    Integer :position
    Integer :tag_id, :references => :tags
    Integer :word_id, :references => :words

    Integer :src_begin
    Integer :src_end
    Integer :tagged_begin
    Integer :tagged_end

    index [:text_id, :position], :unique => true
    index :word_id
    index :tag_id
  end

end