Class: CreateNotifications
- Inherits:
-
ActiveRecord::Migration
- Object
- ActiveRecord::Migration
- CreateNotifications
- Defined in:
- lib/generators/user_notification/migration/templates/migration.rb
Overview
Migration responsible for creating a table with notifications
Class Method Summary collapse
-
.down ⇒ Object
Drop table.
-
.up ⇒ Object
Create table.
Class Method Details
.down ⇒ Object
Drop table
21 22 23 |
# File 'lib/generators/user_notification/migration/templates/migration.rb', line 21 def self.down drop_table :notifications end |
.up ⇒ Object
Create table
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/generators/user_notification/migration/templates/migration.rb', line 4 def self.up create_table :notifications do |t| t.belongs_to :notifiable, :polymorphic => true t.belongs_to :owner, :polymorphic => true t.string :key t.text :parameters t.belongs_to :recipient, :polymorphic => true t.boolean :read, default: false t. end add_index :notifications, [:notifiable_id, :notifiable_type] add_index :notifications, [:owner_id, :owner_type] add_index :notifications, [:recipient_id, :recipient_type] end |