diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-06-13 16:05:30 +0200 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-06-13 16:05:30 +0200 |
commit | f6de5937e302493db2b9bcef7812ed36e1e049e6 (patch) | |
tree | 5cd95c593013e5d386f623e8dc3af82e48fc73a7 /db | |
parent | c534d2e89ed00ff98c83a197674b5ac66a8aca93 (diff) | |
parent | 57ebd3996eb5d8ff85c5899c7a7f351272655562 (diff) | |
download | gitlab-ce-f6de5937e302493db2b9bcef7812ed36e1e049e6.tar.gz |
Merge remote-tracking branch 'origin/master' into artifacts-expire-date
Diffstat (limited to 'db')
3 files changed, 39 insertions, 0 deletions
diff --git a/db/migrate/20160610140403_remove_notification_setting_not_null_constraints.rb b/db/migrate/20160610140403_remove_notification_setting_not_null_constraints.rb new file mode 100644 index 00000000000..259abb08e47 --- /dev/null +++ b/db/migrate/20160610140403_remove_notification_setting_not_null_constraints.rb @@ -0,0 +1,11 @@ +class RemoveNotificationSettingNotNullConstraints < ActiveRecord::Migration + def up + change_column :notification_settings, :source_type, :string, null: true + change_column :notification_settings, :source_id, :integer, null: true + end + + def down + change_column :notification_settings, :source_type, :string, null: false + change_column :notification_settings, :source_id, :integer, null: false + end +end diff --git a/db/migrate/20160610201627_migrate_users_notification_level.rb b/db/migrate/20160610201627_migrate_users_notification_level.rb new file mode 100644 index 00000000000..760b766828e --- /dev/null +++ b/db/migrate/20160610201627_migrate_users_notification_level.rb @@ -0,0 +1,21 @@ +class MigrateUsersNotificationLevel < ActiveRecord::Migration + # Migrates only users who changed their default notification level :participating + # creating a new record on notification settings table + + def up + execute(%Q{ + INSERT INTO notification_settings + (user_id, level, created_at, updated_at) + (SELECT id, notification_level, created_at, updated_at FROM users WHERE notification_level != 1) + }) + end + + # Migrates from notification settings back to user notification_level + # If no value is found the default level of 1 will be used + def down + execute(%Q{ + UPDATE users u SET + notification_level = COALESCE((SELECT level FROM notification_settings WHERE user_id = u.id AND source_type IS NULL), 1) + }) + end +end diff --git a/db/migrate/20160610301627_remove_notification_level_from_users.rb b/db/migrate/20160610301627_remove_notification_level_from_users.rb new file mode 100644 index 00000000000..8afb14df2cf --- /dev/null +++ b/db/migrate/20160610301627_remove_notification_level_from_users.rb @@ -0,0 +1,7 @@ +class RemoveNotificationLevelFromUsers < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + def change + remove_column :users, :notification_level, :integer + end +end |