meta_notification 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b1e5320b07b4e14b03044f446238d5fc5496520d
4
- data.tar.gz: bd873cc6e09c422f5cb187eab56b2eda6e11e1fd
3
+ metadata.gz: 8fb5e04a46b4432cbeea71d776128cd0fd984665
4
+ data.tar.gz: bb152517635df8dd99395bc2eaa13d7f9dff0096
5
5
  SHA512:
6
- metadata.gz: 693aa5806baa8ecb94ae9d7c63e16df7130fac5852a41a9d842c3c8c278d608a943fc0fdb25dce9a0503a4da1e07210f81cab08f4ea846b2a95d6ba54608abd4
7
- data.tar.gz: 399674d90a233a5553259606aa9d80114b9dbd1524de351bbf72d63ec48955f9ccdffe1f7d4371b8440793b7535b8b9931a3037b43dbf3dd38a1f553d1188f66
6
+ metadata.gz: af1c48d7e73c22ac1a257eb873572ad42e3d4d17cb5e7abf19b16f978d567287426ab6cb7f5e6dd4993527168c526a63d4394a31e36d7db7fc0f376f587bc2e9
7
+ data.tar.gz: e5648b1fec230466146184af05262ee0608b8e292f0cf5f29aceffb85c3f143e0f5c1a0724e1055d873fadf007e63270f5ba9af8ce5032967a2821fb7340fa08
@@ -1,75 +1,85 @@
1
1
  require_dependency 'meta_notification/application_controller'
2
- require "meta_notification_authority"
2
+ require 'meta_notification_authority'
3
3
 
4
4
  module MetaNotification
5
- module Api
6
- module V1
7
- class UserNotificationsController < ApplicationController
8
- before_action :init_authorizer
5
+ module Api
6
+ module V1
7
+ class UserNotificationsController < ApplicationController
8
+ before_action :init_authorizer
9
9
 
10
- before_action :set_user_notification, only: [:update, :show]
11
- before_action :set_notification_type_ids_for_filter, only: [:notifications, :mark_all_read]
10
+ before_action :set_user_notification, only: [:update, :show]
11
+ before_action :set_notification_type_ids_for_filter, only: [:notifications, :mark_all_read, :mark_all_read]
12
12
 
13
- def show
14
- end
13
+ def show
14
+ end
15
15
 
16
- def update
17
- if @user_notifications_authorizer.updatable_by?(current_user, @user_notification)
18
- @user_notification.update(user_notification_params)
19
- render :json => {marked: true}, status: 200 and return
20
- end
21
- render :json => "You are not authorize to complete this action.", status: 422
22
- end
16
+ def update
17
+ if @user_notifications_authorizer.updatable_by?(current_user, @user_notification)
18
+ @user_notification.update(user_notification_params)
19
+ render(json: { marked: true }, status: 200) && return
20
+ end
21
+ render json: 'You are not authorize to complete this action.', status: 422
22
+ end
23
+
24
+ def notifications
25
+ if MnAuthorizers::UserNotificationAuthorizer.readable_by?(current_user, params[:user_id])
26
+ mobile_or_in_app = (params[:platform] == 'mobile') ? 'mobile'.to_sym : 'in_app'.to_sym
27
+ @notifications = MetaNotification::Notification.select(:id, 'mn_notifications.*', 'mn_user_notifications.id as mn_user_notification_id', 'mn_user_notifications.user_id', mobile_or_in_app, 'mn_user_notifications.is_read', 'mn_notification_types.name', 'mn_notification_types.icon', 'mn_notification_types.label', 'mn_notifications.created_by_id', 'mn_notifications.created_at')
28
+ .joins('JOIN mn_user_notifications on mn_user_notifications.notification_id = mn_notifications.id')
29
+ .joins('JOIN mn_notification_types on mn_notification_types.id = mn_user_notifications.notification_type_id')
30
+ .where('mn_user_notifications.user_id' => params[:user_id], 'mn_user_notifications.notification_type_id' => @notification_type_in_ids)
31
+ .where.not('mn_user_notifications.notification_type_id' => @notification_type_not_in_ids)
32
+ @unread_count = @notifications.select { |n| n.is_read == 0 }.length
33
+ @notifications = @notifications.where('mn_user_notifications.is_read' => (params[:is_fetch_unread].try(:to_bool).present? ? false : [true, false]))
34
+ @notifications = @notifications.where('mn_notifications.resource_type' => params[:resource_type], 'mn_notifications.resource_id' => params[:resource_id]) if params[:resource_id].present? && params[:resource_type].present?
35
+ @notifications = @notifications.order('mn_notifications.created_at DESC')
36
+ @notifications = @notifications.page(params[:current_page]) if params[:current_page].present?
23
37
 
24
- def notifications
25
- if MnAuthorizers::UserNotificationAuthorizer.readable_by?(current_user, params[:user_id])
26
- mobile_or_in_app = (params[:platform] == 'mobile') ? 'mobile'.to_sym : 'in_app'.to_sym
27
- @notifications = MetaNotification::Notification.select(:id, "mn_notifications.*", "mn_user_notifications.id as mn_user_notification_id","mn_user_notifications.user_id", mobile_or_in_app, "mn_user_notifications.is_read", "mn_notification_types.name", "mn_notification_types.icon", "mn_notification_types.label", "mn_notifications.created_by_id", "mn_notifications.created_at")
28
- .joins('JOIN mn_user_notifications on mn_user_notifications.notification_id = mn_notifications.id')
29
- .joins('JOIN mn_notification_types on mn_notification_types.id = mn_user_notifications.notification_type_id')
30
- .where("mn_user_notifications.user_id" => params[:user_id], "mn_user_notifications.notification_type_id"=> @notification_type_in_ids)
31
- .where.not("mn_user_notifications.notification_type_id"=> @notification_type_not_in_ids)
32
- @unread_count = @notifications.select { |n| n.is_read == 0 }.length
33
- @notifications = @notifications.where("mn_user_notifications.is_read" => ((params[:is_fetch_unread].try(:to_bool).present?) ? false : [true, false]) )
34
- @notifications = @notifications.where("mn_notifications.resource_type"=> params[:resource_type], "mn_notifications.resource_id"=> params[:resource_id]) if params[:resource_id].present? && params[:resource_type].present?
35
- @notifications = @notifications.order("mn_notifications.created_at DESC")
36
- @notifications = @notifications.page(params[:current_page]) if params[:current_page].present?
38
+ @created_by_users = User.where(id: @notifications.map(&:created_by_id).compact.uniq)
39
+ return
40
+ end
41
+ render json: 'You are not authorize to complete this action.', status: 422
42
+ end
37
43
 
38
- @created_by_users = User.where(id: @notifications.map(&:created_by_id).compact.uniq)
39
- return
40
- end
41
- render :json => "You are not authorize to complete this action.", status: 422
42
- end
44
+ def mark_all_read
45
+ @user_notifications = MetaNotification::UserNotification.where(user_id: current_user.id, is_read: false, notification_type_id: @notification_type_in_ids)
46
+ .where.not(notification_type_id: @notification_type_not_in_ids)
47
+ @user_notifications.update_all(is_read: true)
48
+ render(json: { marked: true }, status: 200) && return
49
+ end
43
50
 
44
- def mark_all_read
45
- @user_notifications = MetaNotification::UserNotification.where(user_id: current_user.id, is_read: false, notification_type_id: @notification_type_in_ids)
46
- .where.not(notification_type_id: @notification_type_not_in_ids)
47
- @user_notifications.update_all({is_read: true})
48
- render :json => {marked: true}, status: 200 and return
49
- end
51
+ def destroy
52
+ end
50
53
 
51
- def destroy
52
- end
54
+ def unread_count
55
+ mobile_or_in_app = (params[:platform] == 'mobile') ? 'mobile'.to_sym : 'in_app'.to_sym
56
+ unread_count = MetaNotification::Notification.select(:id, 'mn_notifications.*', 'mn_user_notifications.id as mn_user_notification_id', 'mn_user_notifications.user_id', mobile_or_in_app, 'mn_user_notifications.is_read', 'mn_notification_types.name', 'mn_notification_types.icon', 'mn_notification_types.label', 'mn_notifications.created_by_id', 'mn_notifications.created_at')
57
+ .joins('JOIN mn_user_notifications on mn_user_notifications.notification_id = mn_notifications.id')
58
+ .joins('JOIN mn_notification_types on mn_notification_types.id = mn_user_notifications.notification_type_id')
59
+ .where('mn_user_notifications.user_id' => params[:user_id], 'mn_user_notifications.notification_type_id' => @notification_type_in_ids, 'mn_user_notifications.is_read' => false)
60
+ .where.not('mn_user_notifications.notification_type_id' => @notification_type_not_in_ids).length
61
+ render(json: { unread_count: unread_count }, status: 200) && return
62
+ end
53
63
 
54
- def set_user_notification
55
- @user_notification = UserNotification.find params[:id]
56
- end
64
+ def set_user_notification
65
+ @user_notification = UserNotification.find params[:id]
66
+ end
57
67
 
58
- def set_notification_type_ids_for_filter
59
- @notification_type_not_in_ids = (params[:notification_type_not_in].present?) ? MetaNotification::NotificationType.where(name: params[:notification_type_not_in]).pluck(:id) : nil
60
- @notification_type_in_ids = (params[:notification_type_in].present?) ? MetaNotification::NotificationType.where(name: params[:notification_type_in]).pluck(:id) : MetaNotification::NotificationType.all.pluck(:id)
61
- end
68
+ def set_notification_type_ids_for_filter
69
+ @notification_type_not_in_ids = params[:notification_type_not_in].present? ? MetaNotification::NotificationType.where(name: params[:notification_type_not_in]).pluck(:id) : nil
70
+ @notification_type_in_ids = params[:notification_type_in].present? ? MetaNotification::NotificationType.where(name: params[:notification_type_in]).pluck(:id) : MetaNotification::NotificationType.all.pluck(:id)
71
+ end
62
72
 
63
- def user_notification_params
64
- params.permit(:is_read)
65
- end
73
+ def user_notification_params
74
+ params.permit(:is_read)
75
+ end
66
76
 
67
- def init_authorizer
68
- @user_notifications_authorizer = MnAuthorizers::UserNotificationAuthorizer.new
69
- end
77
+ def init_authorizer
78
+ @user_notifications_authorizer = MnAuthorizers::UserNotificationAuthorizer.new
79
+ end
70
80
 
71
- private :set_user_notification, :user_notification_params, :init_authorizer, :set_notification_type_ids_for_filter
72
- end
73
- end
74
- end
81
+ private :set_user_notification, :user_notification_params, :init_authorizer, :set_notification_type_ids_for_filter
82
+ end
83
+ end
84
+ end
75
85
  end
@@ -1,4 +1,4 @@
1
1
  module MetaNotification
2
- class ApplicationController < ActionController::Base
2
+ class ApplicationController < ::ApplicationController
3
3
  end
4
4
  end
@@ -1,3 +1,3 @@
1
1
  module MetaNotification
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -1,41 +1,148 @@
1
-  (5.1ms) CREATE TABLE `schema_migrations` (`version` varchar(255) NOT NULL) ENGINE=InnoDB
2
-  (13.5ms) CREATE UNIQUE INDEX `unique_schema_migrations` ON `schema_migrations` (`version`)
3
- ActiveRecord::SchemaMigration Load (0.2ms) SELECT `schema_migrations`.* FROM `schema_migrations`
4
- Migrating to CreateMetaNotificationNotificationTypes (20160615074820)
5
-  (7.4ms) CREATE TABLE `mn_notification_types` (`id` int(11) auto_increment PRIMARY KEY, `name` varchar(255) NOT NULL, `display_name` varchar(255), `created_by_id` int(11) NOT NULL, `updated_by_id` int(11) NOT NULL, `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL) ENGINE=InnoDB
1
+  (163.6ms) CREATE TABLE `schema_migrations` (`version` varchar(255) NOT NULL) ENGINE=InnoDB
2
+  (290.6ms) CREATE UNIQUE INDEX `unique_schema_migrations` ON `schema_migrations` (`version`)
3
+ ActiveRecord::SchemaMigration Load (0.3ms) SELECT `schema_migrations`.* FROM `schema_migrations`
4
+ Migrating to CreateMetaNotificationNotificationTypes (20160620071720)
5
+  (84.8ms) CREATE TABLE `mn_notification_types` (`id` int(11) auto_increment PRIMARY KEY, `name` varchar(255) NOT NULL, `display_name` varchar(255), `created_by_id` int(11) NOT NULL, `updated_by_id` int(11) NOT NULL, `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL) ENGINE=InnoDB
6
+  (0.2ms) BEGIN
7
+ SQL (1.4ms) INSERT INTO `schema_migrations` (`version`) VALUES ('20160620071720')
8
+  (89.7ms) COMMIT
9
+ Migrating to CreateMetaNotificationNotificationTemplates (20160620071721)
10
+  (82.3ms) CREATE TABLE `mn_notification_templates` (`id` int(11) auto_increment PRIMARY KEY, `notification_type_id` int(11) NOT NULL, `in_app` varchar(255), `mobile` varchar(255), `push` varchar(255), `email` text, `sms` varchar(255), `email_subject` varchar(255), `resource_id` int(11), `resource_type` varchar(255), `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL) ENGINE=InnoDB
11
+  (174.0ms) CREATE UNIQUE INDEX `unique_type_resource_index` ON `mn_notification_templates` (`notification_type_id`, `resource_type`, `resource_id`) 
12
+  (159.0ms) CREATE INDEX `resource_index` ON `mn_notification_templates` (`resource_type`, `resource_id`)
6
13
   (0.1ms) BEGIN
7
- SQL (0.1ms) INSERT INTO `schema_migrations` (`version`) VALUES ('20160615074820')
8
-  (1.5ms) COMMIT
9
- Migrating to CreateMetaNotificationNotificationTemplates (20160618094218)
10
-  (3.6ms) CREATE TABLE `mn_notification_templates` (`id` int(11) auto_increment PRIMARY KEY, `notification_type_id` int(11) NOT NULL, `in_app` varchar(255), `mobile` varchar(255), `push` varchar(255), `email` text, `sms` varchar(255), `email_subject` varchar(255), `resource_id` int(11), `resource_type` varchar(255), `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL) ENGINE=InnoDB
11
-  (5.4ms) CREATE TABLE `schema_migrations` (`version` varchar(255) NOT NULL) ENGINE=InnoDB
12
-  (15.9ms) CREATE UNIQUE INDEX `unique_schema_migrations` ON `schema_migrations` (`version`)
13
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT `schema_migrations`.* FROM `schema_migrations`
14
+ SQL (0.2ms) INSERT INTO `schema_migrations` (`version`) VALUES ('20160620071721')
15
+  (106.3ms) COMMIT
16
+ Migrating to CreateMetaNotificationNotifications (20160620071722)
17
+  (89.4ms) CREATE TABLE `mn_notifications` (`id` int(11) auto_increment PRIMARY KEY, `notification_template_id` int(11) NOT NULL, `in_app` text NOT NULL, `mobile` text NOT NULL, `resource_type` varchar(255), `resource_id` int(11), `created_by_id` int(11) NOT NULL, `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL, INDEX `index_mn_notifications_on_notification_template_id` (`notification_template_id`) , INDEX `index_mn_notifications_on_created_by_id` (`created_by_id`) ) ENGINE=InnoDB
18
+  (0.3ms) BEGIN
19
+ SQL (0.5ms) INSERT INTO `schema_migrations` (`version`) VALUES ('20160620071722')
20
+  (46.5ms) COMMIT
21
+ Migrating to CreateMetaNotificationUserNotifications (20160620071723)
22
+  (81.0ms) CREATE TABLE `mn_user_notifications` (`id` int(11) auto_increment PRIMARY KEY, `user_id` int(11) NOT NULL, `notification_id` int(11) NOT NULL, `is_read` tinyint(1) NOT NULL, `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL, INDEX `index_mn_user_notifications_on_user_id` (`user_id`) , INDEX `index_mn_user_notifications_on_notification_id` (`notification_id`) ) ENGINE=InnoDB
23
+  (0.1ms) BEGIN
24
+ SQL (0.2ms) INSERT INTO `schema_migrations` (`version`) VALUES ('20160620071723')
25
+  (48.3ms) COMMIT
26
+ Migrating to CreateMetaNotificationNotificationSettings (20160620071724)
27
+  (89.4ms) CREATE TABLE `mn_notification_settings` (`id` int(11) auto_increment PRIMARY KEY, `notification_type_id` int(11) NOT NULL, `is_mute` tinyint(1) DEFAULT 0 NOT NULL, `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL) ENGINE=InnoDB
28
+  (0.1ms) BEGIN
29
+ SQL (0.5ms) INSERT INTO `schema_migrations` (`version`) VALUES ('20160620071724')
30
+  (46.9ms) COMMIT
31
+ Migrating to CreateMetaNotificationUserNotificationSettings (20160620071725)
32
+  (81.6ms) CREATE TABLE `mn_user_notification_settings` (`id` int(11) auto_increment PRIMARY KEY, `user_id` int(11) NOT NULL, `notification_type_id` int(11) NOT NULL, `is_mute` tinyint(1) DEFAULT 0 NOT NULL, `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL, INDEX `index_mn_user_notification_settings_on_notification_type_id` (`notification_type_id`) ) ENGINE=InnoDB
33
+  (165.9ms) CREATE UNIQUE INDEX `unique_user_notification_type_index` ON `mn_user_notification_settings` (`user_id`, `notification_type_id`) 
34
+  (0.2ms) BEGIN
35
+ SQL (0.3ms) INSERT INTO `schema_migrations` (`version`) VALUES ('20160620071725')
36
+  (55.8ms) COMMIT
37
+ ActiveRecord::SchemaMigration Load (0.3ms) SELECT `schema_migrations`.* FROM `schema_migrations`
38
+  (0.3ms) SELECT fk.referenced_table_name as 'to_table'
39
+ ,fk.referenced_column_name as 'primary_key'
40
+ ,fk.column_name as 'column'
41
+ ,fk.constraint_name as 'name'
42
+ FROM information_schema.key_column_usage fk
43
+ WHERE fk.referenced_column_name is not null
44
+ AND fk.table_schema = 'dummy_development'
45
+ AND fk.table_name = 'mn_notification_settings'
46
+
47
+  (0.1ms) SHOW CREATE TABLE `mn_notification_settings`
48
+  (0.3ms) SELECT fk.referenced_table_name as 'to_table'
49
+ ,fk.referenced_column_name as 'primary_key'
50
+ ,fk.column_name as 'column'
51
+ ,fk.constraint_name as 'name'
52
+ FROM information_schema.key_column_usage fk
53
+ WHERE fk.referenced_column_name is not null
54
+ AND fk.table_schema = 'dummy_development'
55
+ AND fk.table_name = 'mn_notification_templates'
56
+
57
+  (0.2ms) SHOW CREATE TABLE `mn_notification_templates`
58
+  (0.3ms) SELECT fk.referenced_table_name as 'to_table'
59
+ ,fk.referenced_column_name as 'primary_key'
60
+ ,fk.column_name as 'column'
61
+ ,fk.constraint_name as 'name'
62
+ FROM information_schema.key_column_usage fk
63
+ WHERE fk.referenced_column_name is not null
64
+ AND fk.table_schema = 'dummy_development'
65
+ AND fk.table_name = 'mn_notification_types'
66
+
67
+  (0.1ms) SHOW CREATE TABLE `mn_notification_types`
68
+  (0.3ms) SELECT fk.referenced_table_name as 'to_table'
69
+ ,fk.referenced_column_name as 'primary_key'
70
+ ,fk.column_name as 'column'
71
+ ,fk.constraint_name as 'name'
72
+ FROM information_schema.key_column_usage fk
73
+ WHERE fk.referenced_column_name is not null
74
+ AND fk.table_schema = 'dummy_development'
75
+ AND fk.table_name = 'mn_notifications'
76
+
77
+  (0.1ms) SHOW CREATE TABLE `mn_notifications`
78
+  (0.3ms) SELECT fk.referenced_table_name as 'to_table'
79
+ ,fk.referenced_column_name as 'primary_key'
80
+ ,fk.column_name as 'column'
81
+ ,fk.constraint_name as 'name'
82
+ FROM information_schema.key_column_usage fk
83
+ WHERE fk.referenced_column_name is not null
84
+ AND fk.table_schema = 'dummy_development'
85
+ AND fk.table_name = 'mn_user_notification_settings'
86
+
87
+  (0.1ms) SHOW CREATE TABLE `mn_user_notification_settings`
88
+  (0.2ms) SELECT fk.referenced_table_name as 'to_table'
89
+ ,fk.referenced_column_name as 'primary_key'
90
+ ,fk.column_name as 'column'
91
+ ,fk.constraint_name as 'name'
92
+ FROM information_schema.key_column_usage fk
93
+ WHERE fk.referenced_column_name is not null
94
+ AND fk.table_schema = 'dummy_development'
95
+ AND fk.table_name = 'mn_user_notifications'
96
+
97
+  (0.1ms) SHOW CREATE TABLE `mn_user_notifications`
98
+  (93.6ms) CREATE TABLE `schema_migrations` (`version` varchar(255) NOT NULL) ENGINE=InnoDB
99
+  (199.2ms) CREATE UNIQUE INDEX `unique_schema_migrations` ON `schema_migrations` (`version`)
100
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT `schema_migrations`.* FROM `schema_migrations`
14
101
  Migrating to CreateMetaNotificationNotificationTypes (20160615074820)
15
-  (3.8ms) CREATE TABLE `mn_notification_types` (`id` int(11) auto_increment PRIMARY KEY, `name` varchar(255) NOT NULL, `display_name` varchar(255), `created_by_id` int(11) NOT NULL, `updated_by_id` int(11) NOT NULL, `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL) ENGINE=InnoDB
102
+  (85.4ms) CREATE TABLE `mn_notification_types` (`id` int(11) auto_increment PRIMARY KEY, `name` varchar(255) NOT NULL, `display_name` varchar(255), `created_by_id` int(11) NOT NULL, `updated_by_id` int(11) NOT NULL, `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL) ENGINE=InnoDB
16
103
   (0.1ms) BEGIN
17
104
  SQL (0.2ms) INSERT INTO `schema_migrations` (`version`) VALUES ('20160615074820')
18
-  (1.7ms) COMMIT
105
+  (52.2ms) COMMIT
19
106
  Migrating to CreateMetaNotificationNotificationTemplates (20160618094218)
20
-  (3.7ms) CREATE TABLE `mn_notification_templates` (`id` int(11) auto_increment PRIMARY KEY, `notification_type_id` int(11) NOT NULL, `in_app` varchar(255), `mobile` varchar(255), `push` varchar(255), `email` text, `sms` varchar(255), `email_subject` varchar(255), `resource_id` int(11), `resource_type` varchar(255), `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL) ENGINE=InnoDB
21
-  (13.7ms) CREATE UNIQUE INDEX `unique_type_resource_index` ON `mn_notification_templates` (`notification_type_id`, `resource_type`, `resource_id`) 
22
-  (3.6ms) CREATE TABLE `schema_migrations` (`version` varchar(255) NOT NULL) ENGINE=InnoDB
23
-  (12.5ms) CREATE UNIQUE INDEX `unique_schema_migrations` ON `schema_migrations` (`version`)
24
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT `schema_migrations`.* FROM `schema_migrations`
25
- Migrating to CreateMetaNotificationNotificationTypes (20160615074820)
26
-  (4.0ms) CREATE TABLE `mn_notification_types` (`id` int(11) auto_increment PRIMARY KEY, `name` varchar(255) NOT NULL, `display_name` varchar(255), `created_by_id` int(11) NOT NULL, `updated_by_id` int(11) NOT NULL, `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL) ENGINE=InnoDB
107
+  (82.0ms) CREATE TABLE `mn_notification_templates` (`id` int(11) auto_increment PRIMARY KEY, `notification_type_id` int(11) NOT NULL, `in_app` varchar(255), `mobile` varchar(255), `push` varchar(255), `email` text, `sms` varchar(255), `email_subject` varchar(255), `resource_id` int(11), `resource_type` varchar(255), `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL) ENGINE=InnoDB
108
+  (157.2ms) CREATE UNIQUE INDEX `unique_type_resource_index` ON `mn_notification_templates` (`notification_type_id`, `resource_type`, `resource_id`) 
109
+  (167.0ms) CREATE INDEX `resource_index` ON `mn_notification_templates` (`resource_type`, `resource_id`)
27
110
   (0.1ms) BEGIN
28
- SQL (0.1ms) INSERT INTO `schema_migrations` (`version`) VALUES ('20160615074820')
29
-  (1.7ms) COMMIT
30
- Migrating to CreateMetaNotificationNotificationTemplates (20160618094218)
31
-  (3.6ms) CREATE TABLE `mn_notification_templates` (`id` int(11) auto_increment PRIMARY KEY, `notification_type_id` int(11) NOT NULL, `in_app` varchar(255), `mobile` varchar(255), `push` varchar(255), `email` text, `sms` varchar(255), `email_subject` varchar(255), `resource_id` int(11), `resource_type` varchar(255), `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL) ENGINE=InnoDB
32
-  (10.4ms) CREATE UNIQUE INDEX `unique_type_resource_index` ON `mn_notification_templates` (`notification_type_id`, `resource_type`, `resource_id`) 
33
-  (10.9ms) CREATE INDEX `resource_index` ON `mn_notification_templates` (`resource_type`, `resource_id`)
111
+ SQL (0.3ms) INSERT INTO `schema_migrations` (`version`) VALUES ('20160618094218')
112
+  (47.9ms) COMMIT
113
+ Migrating to CreateMetaNotificationNotifications (20160619133533)
114
+  (81.1ms) CREATE TABLE `mn_notifications` (`id` int(11) auto_increment PRIMARY KEY, `notification_template_id` int(11) NOT NULL, `in_app` text NOT NULL, `mobile` text NOT NULL, `resource_type` varchar(255), `resource_id` int(11), `created_by_id` int(11) NOT NULL, `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL, INDEX `index_mn_notifications_on_notification_template_id` (`notification_template_id`) , INDEX `index_mn_notifications_on_created_by_id` (`created_by_id`) ) ENGINE=InnoDB
34
115
   (0.1ms) BEGIN
35
- SQL (0.2ms) INSERT INTO `schema_migrations` (`version`) VALUES ('20160618094218')
36
-  (1.9ms) COMMIT
37
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT `schema_migrations`.* FROM `schema_migrations`
38
-  (0.2ms) SELECT fk.referenced_table_name as 'to_table'
116
+ SQL (0.2ms) INSERT INTO `schema_migrations` (`version`) VALUES ('20160619133533')
117
+  (48.2ms) COMMIT
118
+ Migrating to CreateMetaNotificationUserNotifications (20160620015754)
119
+  (80.5ms) CREATE TABLE `mn_user_notifications` (`id` int(11) auto_increment PRIMARY KEY, `user_id` int(11) NOT NULL, `notification_id` int(11) NOT NULL, `notification_type_id` int(11) NOT NULL, `is_read` tinyint(1) NOT NULL, `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL, INDEX `index_mn_user_notifications_on_user_id` (`user_id`) , INDEX `index_mn_user_notifications_on_notification_id` (`notification_id`) , INDEX `index_mn_user_notifications_on_notification_type_id` (`notification_type_id`) ) ENGINE=InnoDB
120
+  (0.2ms) BEGIN
121
+ SQL (0.3ms) INSERT INTO `schema_migrations` (`version`) VALUES ('20160620015754')
122
+  (47.9ms) COMMIT
123
+ Migrating to CreateMetaNotificationNotificationSettings (20160620020944)
124
+  (82.1ms) CREATE TABLE `mn_notification_settings` (`id` int(11) auto_increment PRIMARY KEY, `notification_type_id` int(11) NOT NULL, `is_mute` tinyint(1) DEFAULT 0 NOT NULL, `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL) ENGINE=InnoDB
125
+  (0.1ms) BEGIN
126
+ SQL (0.3ms) INSERT INTO `schema_migrations` (`version`) VALUES ('20160620020944')
127
+  (48.2ms) COMMIT
128
+ Migrating to CreateMetaNotificationUserNotificationSettings (20160620052742)
129
+  (81.7ms) CREATE TABLE `mn_user_notification_settings` (`id` int(11) auto_increment PRIMARY KEY, `user_id` int(11) NOT NULL, `notification_type_id` int(11) NOT NULL, `is_mute` tinyint(1) DEFAULT 0 NOT NULL, `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL, INDEX `index_mn_user_notification_settings_on_notification_type_id` (`notification_type_id`) ) ENGINE=InnoDB
130
+  (140.9ms) CREATE UNIQUE INDEX `unique_user_notification_type_index` ON `mn_user_notification_settings` (`user_id`, `notification_type_id`) 
131
+  (0.1ms) BEGIN
132
+ SQL (0.2ms) INSERT INTO `schema_migrations` (`version`) VALUES ('20160620052742')
133
+  (48.4ms) COMMIT
134
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT `schema_migrations`.* FROM `schema_migrations`
135
+  (0.4ms) SELECT fk.referenced_table_name as 'to_table'
136
+ ,fk.referenced_column_name as 'primary_key'
137
+ ,fk.column_name as 'column'
138
+ ,fk.constraint_name as 'name'
139
+ FROM information_schema.key_column_usage fk
140
+ WHERE fk.referenced_column_name is not null
141
+ AND fk.table_schema = 'dummy_development'
142
+ AND fk.table_name = 'mn_notification_settings'
143
+
144
+  (0.2ms) SHOW CREATE TABLE `mn_notification_settings`
145
+  (0.3ms) SELECT fk.referenced_table_name as 'to_table'
39
146
  ,fk.referenced_column_name as 'primary_key'
40
147
  ,fk.column_name as 'column'
41
148
  ,fk.constraint_name as 'name'
@@ -43,9 +150,9 @@ FROM information_schema.key_column_usage fk
43
150
  WHERE fk.referenced_column_name is not null
44
151
  AND fk.table_schema = 'dummy_development'
45
152
  AND fk.table_name = 'mn_notification_templates'
46
- 
47
-  (0.1ms) SHOW CREATE TABLE `mn_notification_templates`
48
-  (0.2ms) SELECT fk.referenced_table_name as 'to_table'
153
+
154
+  (0.2ms) SHOW CREATE TABLE `mn_notification_templates`
155
+  (0.3ms) SELECT fk.referenced_table_name as 'to_table'
49
156
  ,fk.referenced_column_name as 'primary_key'
50
157
  ,fk.column_name as 'column'
51
158
  ,fk.constraint_name as 'name'
@@ -53,5 +160,105 @@ FROM information_schema.key_column_usage fk
53
160
  WHERE fk.referenced_column_name is not null
54
161
  AND fk.table_schema = 'dummy_development'
55
162
  AND fk.table_name = 'mn_notification_types'
56
- 
57
-  (0.1ms) SHOW CREATE TABLE `mn_notification_types`
163
+
164
+  (0.2ms) SHOW CREATE TABLE `mn_notification_types`
165
+  (0.3ms) SELECT fk.referenced_table_name as 'to_table'
166
+ ,fk.referenced_column_name as 'primary_key'
167
+ ,fk.column_name as 'column'
168
+ ,fk.constraint_name as 'name'
169
+ FROM information_schema.key_column_usage fk
170
+ WHERE fk.referenced_column_name is not null
171
+ AND fk.table_schema = 'dummy_development'
172
+ AND fk.table_name = 'mn_notifications'
173
+
174
+  (0.2ms) SHOW CREATE TABLE `mn_notifications`
175
+  (0.3ms) SELECT fk.referenced_table_name as 'to_table'
176
+ ,fk.referenced_column_name as 'primary_key'
177
+ ,fk.column_name as 'column'
178
+ ,fk.constraint_name as 'name'
179
+ FROM information_schema.key_column_usage fk
180
+ WHERE fk.referenced_column_name is not null
181
+ AND fk.table_schema = 'dummy_development'
182
+ AND fk.table_name = 'mn_user_notification_settings'
183
+
184
+  (0.2ms) SHOW CREATE TABLE `mn_user_notification_settings`
185
+  (0.3ms) SELECT fk.referenced_table_name as 'to_table'
186
+ ,fk.referenced_column_name as 'primary_key'
187
+ ,fk.column_name as 'column'
188
+ ,fk.constraint_name as 'name'
189
+ FROM information_schema.key_column_usage fk
190
+ WHERE fk.referenced_column_name is not null
191
+ AND fk.table_schema = 'dummy_development'
192
+ AND fk.table_name = 'mn_user_notifications'
193
+
194
+  (0.2ms) SHOW CREATE TABLE `mn_user_notifications`
195
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT `schema_migrations`.* FROM `schema_migrations`
196
+ Migrating to AddAttachmentAttachmentToNotifications (20160727124414)
197
+  (583.4ms) ALTER TABLE `mn_notifications` ADD `attachment_file_name` varchar(255)
198
+  (274.9ms) ALTER TABLE `mn_notifications` ADD `attachment_content_type` varchar(255)
199
+  (266.6ms) ALTER TABLE `mn_notifications` ADD `attachment_file_size` int(11)
200
+  (250.0ms) ALTER TABLE `mn_notifications` ADD `attachment_updated_at` datetime
201
+  (0.1ms) BEGIN
202
+ SQL (24.6ms) INSERT INTO `schema_migrations` (`version`) VALUES ('20160727124414')
203
+  (50.3ms) COMMIT
204
+ ActiveRecord::SchemaMigration Load (21.9ms) SELECT `schema_migrations`.* FROM `schema_migrations`
205
+  (1.6ms) SELECT fk.referenced_table_name as 'to_table'
206
+ ,fk.referenced_column_name as 'primary_key'
207
+ ,fk.column_name as 'column'
208
+ ,fk.constraint_name as 'name'
209
+ FROM information_schema.key_column_usage fk
210
+ WHERE fk.referenced_column_name is not null
211
+ AND fk.table_schema = 'dummy_development'
212
+ AND fk.table_name = 'mn_notification_settings'
213
+
214
+  (0.2ms) SHOW CREATE TABLE `mn_notification_settings`
215
+  (0.3ms) SELECT fk.referenced_table_name as 'to_table'
216
+ ,fk.referenced_column_name as 'primary_key'
217
+ ,fk.column_name as 'column'
218
+ ,fk.constraint_name as 'name'
219
+ FROM information_schema.key_column_usage fk
220
+ WHERE fk.referenced_column_name is not null
221
+ AND fk.table_schema = 'dummy_development'
222
+ AND fk.table_name = 'mn_notification_templates'
223
+
224
+  (0.1ms) SHOW CREATE TABLE `mn_notification_templates`
225
+  (0.2ms) SELECT fk.referenced_table_name as 'to_table'
226
+ ,fk.referenced_column_name as 'primary_key'
227
+ ,fk.column_name as 'column'
228
+ ,fk.constraint_name as 'name'
229
+ FROM information_schema.key_column_usage fk
230
+ WHERE fk.referenced_column_name is not null
231
+ AND fk.table_schema = 'dummy_development'
232
+ AND fk.table_name = 'mn_notification_types'
233
+
234
+  (0.1ms) SHOW CREATE TABLE `mn_notification_types`
235
+  (0.6ms) SELECT fk.referenced_table_name as 'to_table'
236
+ ,fk.referenced_column_name as 'primary_key'
237
+ ,fk.column_name as 'column'
238
+ ,fk.constraint_name as 'name'
239
+ FROM information_schema.key_column_usage fk
240
+ WHERE fk.referenced_column_name is not null
241
+ AND fk.table_schema = 'dummy_development'
242
+ AND fk.table_name = 'mn_notifications'
243
+
244
+  (0.1ms) SHOW CREATE TABLE `mn_notifications`
245
+  (0.2ms) SELECT fk.referenced_table_name as 'to_table'
246
+ ,fk.referenced_column_name as 'primary_key'
247
+ ,fk.column_name as 'column'
248
+ ,fk.constraint_name as 'name'
249
+ FROM information_schema.key_column_usage fk
250
+ WHERE fk.referenced_column_name is not null
251
+ AND fk.table_schema = 'dummy_development'
252
+ AND fk.table_name = 'mn_user_notification_settings'
253
+
254
+  (0.1ms) SHOW CREATE TABLE `mn_user_notification_settings`
255
+  (0.3ms) SELECT fk.referenced_table_name as 'to_table'
256
+ ,fk.referenced_column_name as 'primary_key'
257
+ ,fk.column_name as 'column'
258
+ ,fk.constraint_name as 'name'
259
+ FROM information_schema.key_column_usage fk
260
+ WHERE fk.referenced_column_name is not null
261
+ AND fk.table_schema = 'dummy_development'
262
+ AND fk.table_name = 'mn_user_notifications'
263
+
264
+  (0.1ms) SHOW CREATE TABLE `mn_user_notifications`