Migrate notification setting from members table
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
parent
31b0e53015
commit
73c5a34105
|
@ -0,0 +1,13 @@
|
|||
# This migration will create one row of NotificationSetting for each Member row
|
||||
# It can take long time on big instances. Its unclear yet if this migration can be done online.
|
||||
# This comment should be updated by @dzaporozhets before 8.7 release. If not - please ask him to do so.
|
||||
class MigrateNewNotificationSetting < ActiveRecord::Migration
|
||||
def up
|
||||
timestamp = Time.now
|
||||
execute "INSERT INTO notification_settings ( user_id, source_id, source_type, level, created_at, updated_at ) SELECT user_id, source_id, source_type, notification_level, '#{timestamp}', '#{timestamp}' FROM members"
|
||||
end
|
||||
|
||||
def down
|
||||
NotificationSetting.delete_all
|
||||
end
|
||||
end
|
|
@ -0,0 +1,6 @@
|
|||
class AddNotificationSettingIndex < ActiveRecord::Migration
|
||||
def change
|
||||
add_index :notification_settings, :user_id
|
||||
add_index :notification_settings, [:source_id, :source_type]
|
||||
end
|
||||
end
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20160328112808) do
|
||||
ActiveRecord::Schema.define(version: 20160328121138) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
@ -647,6 +647,9 @@ ActiveRecord::Schema.define(version: 20160328112808) do
|
|||
t.datetime "updated_at", null: false
|
||||
end
|
||||
|
||||
add_index "notification_settings", ["source_id", "source_type"], name: "index_notification_settings_on_source_id_and_source_type", using: :btree
|
||||
add_index "notification_settings", ["user_id"], name: "index_notification_settings_on_user_id", using: :btree
|
||||
|
||||
create_table "oauth_access_grants", force: :cascade do |t|
|
||||
t.integer "resource_owner_id", null: false
|
||||
t.integer "application_id", null: false
|
||||
|
|
Loading…
Reference in New Issue