diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-06-14 12:41:18 +0200 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-06-14 12:41:18 +0200 |
commit | 7d9e8b04c025278e26904e061e8b0a005cd81ab0 (patch) | |
tree | 82cf4b183228718d99fd8542104047450f5378b3 /db/migrate | |
parent | 672aec4a2da36d9ee755156be4a907f4b8d96347 (diff) | |
parent | 066020fcd015ca92397b794342a49a46dd02582c (diff) | |
download | gitlab-ce-7d9e8b04c025278e26904e061e8b0a005cd81ab0.tar.gz |
Merge remote-tracking branch 'origin/master' into environments-and-deployments
Diffstat (limited to 'db/migrate')
4 files changed, 45 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/20160610194713_remove_deprecated_issues_tracker_columns_from_projects.rb b/db/migrate/20160610194713_remove_deprecated_issues_tracker_columns_from_projects.rb new file mode 100644 index 00000000000..477b2106dea --- /dev/null +++ b/db/migrate/20160610194713_remove_deprecated_issues_tracker_columns_from_projects.rb @@ -0,0 +1,6 @@ +class RemoveDeprecatedIssuesTrackerColumnsFromProjects < ActiveRecord::Migration + def change + remove_column :projects, :issues_tracker, :string, default: 'gitlab', null: false + remove_column :projects, :issues_tracker_id, :string + 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 |