class Object
Public Class Methods
down()
click to toggle source
# File lib/generators/doeskeyvalue/templates/create_key_value_index.rb, line 36 def self.down drop_table :<%=table_name%> end
up()
click to toggle source
# File lib/generators/doeskeyvalue/templates/create_key_value_index.rb, line 11 def self.up create_table :<%=table_name-%> do |t| # The object is linked by class type and id: t.string :obj_type t.integer :obj_id # The key is identified by name and data type: t.string :key_name t.string :key_type # The value is stored in various possible formats: t.string :value_string t.integer :value_integer t.decimal :value_decimal t.boolean :value_boolean t.datetime :value_datetime # Traditional record-keeping for the index: t.timestamps end # Index is important here: add_index :<%=table_name-%>, [:obj_type, :key_name] end