Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2016-03-28 15:27:30 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2016-03-30 11:44:20 +0300
commit73c5a3410596165244bfa3d2f657c313ec1c558c (patch)
tree6d2caec92dfe7c7e50bf42a108632410e3bd7a3f /db
parent31b0e53015e38e51d9c02cca85c9279600b1bf85 (diff)
Migrate notification setting from members table
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20160328115649_migrate_new_notification_setting.rb13
-rw-r--r--db/migrate/20160328121138_add_notification_setting_index.rb6
-rw-r--r--db/schema.rb5
3 files changed, 23 insertions, 1 deletions
diff --git a/db/migrate/20160328115649_migrate_new_notification_setting.rb b/db/migrate/20160328115649_migrate_new_notification_setting.rb
new file mode 100644
index 00000000000..331c35535f2
--- /dev/null
+++ b/db/migrate/20160328115649_migrate_new_notification_setting.rb
@@ -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
diff --git a/db/migrate/20160328121138_add_notification_setting_index.rb b/db/migrate/20160328121138_add_notification_setting_index.rb
new file mode 100644
index 00000000000..8aebce0244d
--- /dev/null
+++ b/db/migrate/20160328121138_add_notification_setting_index.rb
@@ -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
diff --git a/db/schema.rb b/db/schema.rb
index a9a68e723ab..29639abb6fc 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -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