Class: CreateSimpleNotifications

Inherits:
Object
  • Object
show all
Defined in:
lib/generators/simple_notifications/install/templates/migration.rb

Instance Method Summary collapse

Instance Method Details

#changeObject



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/generators/simple_notifications/install/templates/migration.rb', line 2

def change
  create_table(:simple_notifications) do |t|
    t.references :sender, polymorphic: true
    t.references :entity, polymorphic: true
    t.string :action
    t.string :message

    t.timestamps
  end

  create_table(:deliveries) do |t|
    t.references :simple_notification
    t.references :receiver, polymorphic: true
    t.boolean :is_delivered, default: false
    t.boolean :is_read, default: false

    t.timestamps
  end

  add_index(:simple_notifications, [:sender_id, :sender_type])
  add_index(:simple_notifications, [:entity_id, :entity_type])
  add_index(:deliveries, [:receiver_id, :receiver_type])
  add_index(:deliveries, :is_delivered)
  add_index(:deliveries, :is_read)
end