Class: CreateNotifications

Inherits:
ActiveRecord::Migration
  • Object
show all
Defined in:
lib/generators/notifykit/templates/db/migrate/create_notifications.rb

Overview

Generated by Notifykit.

Create a notifications table for managing emails and site notifications.

Class Method Summary collapse

Class Method Details

.downObject



50
51
52
# File 'lib/generators/notifykit/templates/db/migrate/create_notifications.rb', line 50

def self.down
  drop_table :notifications
end

.upObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/generators/notifykit/templates/db/migrate/create_notifications.rb', line 5

def self.up
  create_table :notifications do |t|
    t.string :category
    t.boolean :promotional, default: false
    t.boolean :transactional, default: true
    t.boolean :do_not_track, default: false
    t.boolean :deliver_via_site, default: true
    t.boolean :deliver_via_email, default: true
    t.string :kind
    t.string :token
    t.integer :user_id
    t.integer :subject_id
    t.string :subject_type
    t.datetime :read_at
    t.datetime :clicked_at
    t.datetime :ignored_at
    t.datetime :cancelled_at
    t.datetime :unsubscribed_at
    t.datetime :email_sent_at
    t.datetime :email_marked_as_spam_at
    t.datetime :email_returned_at
    t.datetime :email_not_sent_at
    t.string :email_not_sent_reason
    t.string :email
    t.string :email_reply_to
    t.string :email_from
    t.string :email_subject
    t.text :email_urls
    t.text :email_text
    t.text :email_html
    t.integer :click_count, default: 0
    t.integer :read_count, default: 0
    t.text :data
    t.timestamps
  end

  add_index :notifications, :token, unique: true
  add_index :notifications, :created_at
  add_index :notifications, [:id, :created_at, :read_at, :clicked_at, :ignored_at, :cancelled_at], name: 'recent'
  add_index :notifications, :kind
  add_index :notifications, :category
  add_index :notifications, :user_id
  add_index :notifications, [:subject_id, :subject_type], name: 'subject'
end