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
c839197f
Commit
c839197f
authored
Sep 05, 2018
by
Kamil Trzciński
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix multiple prometheus alerts migration
parent
c56edb40
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
5 deletions
+8
-5
db/schema.rb
db/schema.rb
+1
-1
ee/db/migrate/20180831134049_allow_many_prometheus_alerts.rb
ee/db/migrate/20180831134049_allow_many_prometheus_alerts.rb
+7
-4
No files found.
db/schema.rb
View file @
c839197f
...
...
@@ -2271,7 +2271,7 @@ ActiveRecord::Schema.define(version: 20180831164910) do
add_index
"prometheus_alerts"
,
[
"environment_id"
],
name:
"index_prometheus_alerts_on_environment_id"
,
using: :btree
add_index
"prometheus_alerts"
,
[
"project_id"
,
"prometheus_metric_id"
],
name:
"index_prometheus_alerts_on_project_id_and_prometheus_metric_id"
,
unique:
true
,
using: :btree
add_index
"prometheus_alerts"
,
[
"prometheus_metric_id"
],
name:
"index_prometheus_alerts_on_prometheus_metric_id
_non_unique
"
,
using: :btree
add_index
"prometheus_alerts"
,
[
"prometheus_metric_id"
],
name:
"index_prometheus_alerts_on_prometheus_metric_id"
,
using: :btree
create_table
"prometheus_metrics"
,
force: :cascade
do
|
t
|
t
.
integer
"project_id"
...
...
ee/db/migrate/20180831134049_allow_many_prometheus_alerts.rb
View file @
c839197f
...
...
@@ -9,17 +9,17 @@ class AllowManyPrometheusAlerts < ActiveRecord::Migration
# and convert it into project+prometheus_metric unique
def
up
rebuild_foreign_key
do
add_concurrent_index
:prometheus_alerts
,
[
:project_id
,
:prometheus_metric_id
],
unique:
true
add_concurrent_index
:prometheus_alerts
,
:prometheus_metric_id
,
name: :index_prometheus_alerts_on_prometheus_metric_id_non_unique
remove_concurrent_index
:prometheus_alerts
,
:prometheus_metric_id
,
unique:
true
add_concurrent_index
:prometheus_alerts
,
:prometheus_metric_id
add_concurrent_index
:prometheus_alerts
,
[
:project_id
,
:prometheus_metric_id
],
unique:
true
end
end
def
down
rebuild_foreign_key
do
add_concurrent_index
:prometheus_alerts
,
:prometheus_metric_id
,
unique:
true
remove_concurrent_index
:prometheus_alerts
,
[
:project_id
,
:prometheus_metric_id
],
unique:
true
remove_concurrent_index
:prometheus_alerts
,
:prometheus_metric_id
,
name: :index_prometheus_alerts_on_prometheus_metric_id_non_unique
remove_concurrent_index
:prometheus_alerts
,
:prometheus_metric_id
add_concurrent_index
:prometheus_alerts
,
:prometheus_metric_id
,
unique:
true
end
end
...
...
@@ -29,6 +29,7 @@ class AllowManyPrometheusAlerts < ActiveRecord::Migration
def
rebuild_foreign_key
if
Gitlab
::
Database
.
mysql?
remove_foreign_key_without_error
:prometheus_alerts
,
:prometheus_metrics
remove_foreign_key_without_error
:prometheus_alerts
,
:projects
end
yield
...
...
@@ -36,6 +37,8 @@ class AllowManyPrometheusAlerts < ActiveRecord::Migration
if
Gitlab
::
Database
.
mysql?
add_concurrent_foreign_key
:prometheus_alerts
,
:prometheus_metrics
,
column: :prometheus_metric_id
,
on_delete: :cascade
add_concurrent_foreign_key
:prometheus_alerts
,
:projects
,
column: :project_id
,
on_delete: :cascade
end
end
end
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