Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
ada686ef
Commit
ada686ef
authored
Oct 27, 2020
by
Sean Arnold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add migration to migrate alertservices
parent
2329d705
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
0 deletions
+48
-0
db/migrate/20201027002551_migrate_services_to_http_integrations.rb
...e/20201027002551_migrate_services_to_http_integrations.rb
+47
-0
db/schema_migrations/20201027002551
db/schema_migrations/20201027002551
+1
-0
No files found.
db/migrate/20201027002551_migrate_services_to_http_integrations.rb
0 → 100644
View file @
ada686ef
# frozen_string_literal: true
# See https://docs.gitlab.com/ee/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class
MigrateServicesToHttpIntegrations
<
ActiveRecord
::
Migration
[
6.0
]
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
ALERT_SERVICE_TYPE
=
'AlertsService'
SERVICE_NAMES_IDENTIFIER
=
{
name:
'Legacy Endpoint'
,
identifier:
'legacy'
}
class
HttpIntegration
<
ActiveRecord
::
Base
self
.
table_name
=
'alert_management_http_integrations'
end
# For each Alerts service,
# Create the matching HttpIntegration
def
up
HttpIntegration
.
reset_column_information
sql
=
<<~
SQL
SELECT * FROM services
JOIN alerts_service_data
ON (services.id = alerts_service_data.service_id)
WHERE type = '
#{
ALERT_SERVICE_TYPE
}
'
SQL
select_all
(
sql
).
each
do
|
alerts_service
|
HttpIntegration
.
create!
(
project_id:
alerts_service
[
'project_id'
],
name:
SERVICE_NAMES_IDENTIFIER
[
:name
],
endpoint_identifier:
SERVICE_NAMES_IDENTIFIER
[
:identifier
],
encrypted_token:
alerts_service
[
'encrypted_token'
],
encrypted_token_iv:
alerts_service
[
'encrypted_token_iv'
],
active:
alerts_service
[
'active'
]
)
end
end
def
down
# NO-OP
end
end
db/schema_migrations/20201027002551
0 → 100644
View file @
ada686ef
34e357b739235d627e543e1bc7202e0cf26f5b1ca8021bb25357e29e883f785b
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment