diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-04-13 15:47:18 +0200 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-04-13 15:47:18 +0200 |
commit | 4af0968c43d517a3d702658749b5117ba4b9e11a (patch) | |
tree | d62a15cbcae8e1d1af00208c28fd1b09d01140f1 /db | |
parent | 872bbb9fe2a5fbb5195aa448b615191baae960d7 (diff) | |
parent | f026e53c4df5b0b3bb7435c05d3c8662afe45881 (diff) | |
download | gitlab-ce-4af0968c43d517a3d702658749b5117ba4b9e11a.tar.gz |
Merge remote-tracking branch 'origin/master' into ci-commit-as-pipeline
Diffstat (limited to 'db')
-rw-r--r-- | db/migrate/20160328112808_create_notification_settings.rb | 11 | ||||
-rw-r--r-- | db/migrate/20160328115649_migrate_new_notification_setting.rb | 17 | ||||
-rw-r--r-- | db/migrate/20160328121138_add_notification_setting_index.rb | 6 | ||||
-rw-r--r-- | db/schema.rb | 12 |
4 files changed, 46 insertions, 0 deletions
diff --git a/db/migrate/20160328112808_create_notification_settings.rb b/db/migrate/20160328112808_create_notification_settings.rb new file mode 100644 index 00000000000..4755da8b806 --- /dev/null +++ b/db/migrate/20160328112808_create_notification_settings.rb @@ -0,0 +1,11 @@ +class CreateNotificationSettings < ActiveRecord::Migration + def change + create_table :notification_settings do |t| + t.references :user, null: false + t.references :source, polymorphic: true, null: false + t.integer :level, default: 0, null: false + + t.timestamps null: false + end + end +end 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..0a110869027 --- /dev/null +++ b/db/migrate/20160328115649_migrate_new_notification_setting.rb @@ -0,0 +1,17 @@ +# This migration will create one row of NotificationSetting for each Member row +# It can take long time on big instances. +# +# This migration can be done online but with following effects: +# - during migration some users will receive notifications based on their global settings (project/group settings will be ignored) +# - its possible to get duplicate records for notification settings since we don't create uniq index yet +# +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 WHERE user_id IS NOT NULL" + end + + def down + execute "DELETE FROM notification_settings" + 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 e000e35fca8..90e238fcfe3 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -647,6 +647,18 @@ ActiveRecord::Schema.define(version: 20160412175417) do add_index "notes", ["project_id"], name: "index_notes_on_project_id", using: :btree add_index "notes", ["updated_at"], name: "index_notes_on_updated_at", using: :btree + create_table "notification_settings", force: :cascade do |t| + t.integer "user_id", null: false + t.integer "source_id", null: false + t.string "source_type", null: false + t.integer "level", default: 0, null: false + t.datetime "created_at", null: false + 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 |