Class: CreatePreferences

Inherits:
ActiveRecord::Migration
  • Object
show all
Defined in:
lib/generators/user_preferences/templates/migration.rb

Class Method Summary collapse

Class Method Details

.downObject



16
17
18
# File 'lib/generators/user_preferences/templates/migration.rb', line 16

def self.down
  drop_table :preferences
end

.upObject



2
3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/generators/user_preferences/templates/migration.rb', line 2

def self.up
  create_table :preferences do |t|
    t.integer :user_id, null: false
    t.string  :category, null: false
    t.string  :name, null: false
    t.integer :value, null: false
    t.timestamps
  end

  add_index :preferences, :user_id
  add_index :preferences, [:user_id, :category]
  add_index :preferences, [:category, :name, :value]
end