Commit 73c5a341 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Migrate notification setting from members table

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 31b0e530
# 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
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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment