diff options
author | Sean McGivern <sean@gitlab.com> | 2016-12-20 11:08:44 +0000 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2016-12-20 11:56:01 +0000 |
commit | 141153a1a0ebe8034aee446e8707b4d75b0cd775 (patch) | |
tree | cfbfd592c65d254ee13a0e8586131eaeaa748f36 | |
parent | 52278412c7350b8087ef4ffc688c79e4593369cc (diff) | |
download | gitlab-ce-allow-slack-service.tar.gz |
Allow SlackService while migratingallow-slack-service
1. Make the existing migration converting SlackService ->
SlackNotificationService a no-op.
2. Allow SlackService as an alternative class name for
SlackNotificationService. This also means that `#to_param` returns
the same thing for both classes, so the UI will work in either case.
3. Create a post-deployment migration to update the existing service
names in batches.
In a future release, we can remove the dummy SlackService class.
4 files changed, 26 insertions, 9 deletions
diff --git a/app/models/project_services/slack_service.rb b/app/models/project_services/slack_service.rb new file mode 100644 index 00000000000..7324bb8c7e0 --- /dev/null +++ b/app/models/project_services/slack_service.rb @@ -0,0 +1,4 @@ +# Remove this in 9.0, this is just to allow a post-deployment migration to +# rename the service. See https://gitlab.com/gitlab-org/gitlab-ce/issues/25855 +class SlackService < SlackNotificationService +end diff --git a/db/migrate/20161213172958_change_slack_service_to_slack_notification_service.rb b/db/migrate/20161213172958_change_slack_service_to_slack_notification_service.rb index a7278d7b5a6..db839bb3000 100644 --- a/db/migrate/20161213172958_change_slack_service_to_slack_notification_service.rb +++ b/db/migrate/20161213172958_change_slack_service_to_slack_notification_service.rb @@ -1,14 +1,10 @@ class ChangeSlackServiceToSlackNotificationService < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers - DOWNTIME = true - DOWNTIME_REASON = 'Rename SlackService to SlackNotificationService' + DOWNTIME = false - def up - execute("UPDATE services SET type = 'SlackNotificationService' WHERE type = 'SlackService'") - end - - def down - execute("UPDATE services SET type = 'SlackService' WHERE type = 'SlackNotificationService'") + # This migration is a no-op, as it existed in an RC but was then moved: + # db/post_migrate/20161220101029_change_slack_service_to_slack_notification_service_in_batches.rb + def change end end diff --git a/db/post_migrate/20161220101029_change_slack_service_to_slack_notification_service_in_batches.rb b/db/post_migrate/20161220101029_change_slack_service_to_slack_notification_service_in_batches.rb new file mode 100644 index 00000000000..fd1405298a2 --- /dev/null +++ b/db/post_migrate/20161220101029_change_slack_service_to_slack_notification_service_in_batches.rb @@ -0,0 +1,17 @@ +class ChangeSlackServiceToSlackNotificationServiceInBatches < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def up + update_column_in_batches(:services, :type, 'SlackNotificationService') do |table, query| + query.where(table[:type].eq('SlackService')) + end + end + + def down + update_column_in_batches(:services, :type, 'SlackService') do |table, query| + query.where(table[:type].eq('SlackNotificationService')) + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 14801b581e6..b17ec20e482 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: 20161213172958) do +ActiveRecord::Schema.define(version: 20161220101029) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" |