diff options
author | Felipe Artur <felipefac@gmail.com> | 2016-06-06 12:50:54 -0300 |
---|---|---|
committer | Felipe Artur <felipefac@gmail.com> | 2016-06-10 10:58:13 -0300 |
commit | 8f6d43e0fea3ce62ec2e8e211755e557f19c51fd (patch) | |
tree | 72930d029dd905d7630ec07dd65acb0ac4b0739c /db | |
parent | f29fd65cdde1d769fc89f0cc57ea989765b5068f (diff) | |
download | gitlab-ce-8f6d43e0fea3ce62ec2e8e211755e557f19c51fd.tar.gz |
Remove notification level from user model
Diffstat (limited to 'db')
-rw-r--r-- | db/migrate/20160606192159_remove_notification_setting_not_null_constraints.rb | 7 | ||||
-rw-r--r-- | db/migrate/20160607201627_migrate_users_notification_level.rb | 24 |
2 files changed, 31 insertions, 0 deletions
diff --git a/db/migrate/20160606192159_remove_notification_setting_not_null_constraints.rb b/db/migrate/20160606192159_remove_notification_setting_not_null_constraints.rb new file mode 100644 index 00000000000..c20ac9acdc2 --- /dev/null +++ b/db/migrate/20160606192159_remove_notification_setting_not_null_constraints.rb @@ -0,0 +1,7 @@ +class RemoveNotificationSettingNotNullConstraints < ActiveRecord::Migration + def up + change_column :notification_settings, :source_type, :string, null: true + change_column :notification_settings, :source_id, :integer, null: true + change_column :users, :notification_level, :integer, null: true + end +end diff --git a/db/migrate/20160607201627_migrate_users_notification_level.rb b/db/migrate/20160607201627_migrate_users_notification_level.rb new file mode 100644 index 00000000000..7417d66fef7 --- /dev/null +++ b/db/migrate/20160607201627_migrate_users_notification_level.rb @@ -0,0 +1,24 @@ +class MigrateUsersNotificationLevel < ActiveRecord::Migration + # Migrates only users which changes theier default notification level :participating + # creating a new record on notification settins table + + def up + changed_users = exec_query(%Q{ + SELECT id, notification_level + FROM users + WHERE notification_level != 1 + }) + + changed_users.each do |row| + uid = row['id'] + u_notification_level = row['notification_level'] + + execute(%Q{ + INSERT INTO notification_settings + (user_id, level, created_at, updated_at) + VALUES + (#{uid}, #{u_notification_level}, now(), now()) + }) + end + end +end |