Class: CreateActiveRecallTables

Inherits:
Object
  • Object
show all
Defined in:
lib/generators/active_recall/templates/create_active_recall_tables.rb

Class Method Summary collapse

Class Method Details

.downObject



22
23
24
25
# File 'lib/generators/active_recall/templates/create_active_recall_tables.rb', line 22

def self.down
  drop_table :active_recall_decks
  drop_table :active_recall_items
end

.upObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/generators/active_recall/templates/create_active_recall_tables.rb', line 4

def self.up
  create_table :active_recall_decks do |t|
    t.references :user, polymorphic: true
    t.timestamps
  end
  add_index :active_recall_decks, %i[user_id user_type]

  create_table :active_recall_items do |t|
    t.references :deck
    t.references :source, polymorphic: true
    t.integer :box, default: 0
    t.timestamp :last_reviewed
    t.timestamp :next_review
    t.timestamps
  end
  add_index :active_recall_items, %i[source_id source_type]
end