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
80f8074d
Commit
80f8074d
authored
Dec 10, 2015
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate SlackService and HipChat service
parent
d5c91bb9
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
72 additions
and
1 deletion
+72
-1
app/models/project_services/builds_email_service.rb
app/models/project_services/builds_email_service.rb
+2
-0
app/models/project_services/hipchat_service.rb
app/models/project_services/hipchat_service.rb
+2
-0
app/models/project_services/slack_service.rb
app/models/project_services/slack_service.rb
+2
-0
db/migrate/20151209145909_migrate_ci_emails.rb
db/migrate/20151209145909_migrate_ci_emails.rb
+6
-0
db/migrate/20151210125232_migrate_ci_slack_service.rb
db/migrate/20151210125232_migrate_ci_slack_service.rb
+29
-0
db/migrate/20151210125927_migrate_ci_hip_chat_service.rb
db/migrate/20151210125927_migrate_ci_hip_chat_service.rb
+30
-0
db/schema.rb
db/schema.rb
+1
-1
No files found.
app/models/project_services/builds_email_service.rb
View file @
80f8074d
...
...
@@ -24,6 +24,8 @@ class BuildsEmailService < Service
boolean_accessor
:notify_only_broken_builds
validates
:recipients
,
presence:
true
,
if: :activated?
default_value_for
:notify_only_broken_builds
,
true
def
title
'Builds emails'
end
...
...
app/models/project_services/hipchat_service.rb
View file @
80f8074d
...
...
@@ -25,6 +25,8 @@ class HipchatService < Service
boolean_accessor
:notify_only_broken_builds
validates
:token
,
presence:
true
,
if: :activated?
default_value_for
:notify_only_broken_builds
,
true
def
title
'HipChat'
end
...
...
app/models/project_services/slack_service.rb
View file @
80f8074d
...
...
@@ -23,6 +23,8 @@ class SlackService < Service
boolean_accessor
:notify_only_broken_builds
validates
:webhook
,
presence:
true
,
if: :activated?
default_value_for
:notify_only_broken_builds
,
true
def
title
'Slack'
end
...
...
db/migrate/20151209145909_migrate_ci_emails.rb
View file @
80f8074d
...
...
@@ -2,6 +2,9 @@ class MigrateCiEmails < ActiveRecord::Migration
include
Gitlab
::
Database
def
up
# This inserts a new service: BuildsEmailService
# It also "manually" constructs the properties (JSON-encoded)
# Migrating all ci_projects e-mail related columns
execute
(
'INSERT INTO services (project_id, type, created_at, updated_at, active, push_events, issues_events, merge_requests_events, tag_push_events, note_events, build_events, properties) '
\
"SELECT projects.id, 'BuildsEmailService', ci_services.created_at, ci_services.updated_at,
#{
true_value
}
,
#{
false_value
}
,
#{
false_value
}
,
#{
false_value
}
,
#{
false_value
}
,
#{
false_value
}
,
#{
true_value
}
, "
\
...
...
@@ -13,4 +16,7 @@ class MigrateCiEmails < ActiveRecord::Migration
"WHERE ci_services.type = 'Ci::MailService' AND ci_services.active"
)
end
def
down
end
end
db/migrate/20151210125232_migrate_ci_slack_service.rb
0 → 100644
View file @
80f8074d
class
MigrateCiSlackService
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
def
up
properties_query
=
'SELECT properties FROM ci_services '
\
'JOIN ci_projects ON ci_services.project_id=ci_projects.id '
\
'WHERE ci_projects.gitlab_id=services.project_id'
active_query
=
'SELECT 1 FROM ci_services '
\
'JOIN ci_projects ON ci_services.project_id=ci_projects.id '
\
"WHERE ci_projects.gitlab_id=services.project_id AND ci_services.type='Ci::SlackService' AND ci_services.active"
# We update the service since services are always generated for project, even if they are inactive
# Activate service and migrate properties if currently the service is not active
execute
(
"UPDATE services SET properties=(
#{
properties_query
}
), build_events=
#{
true_value
}
, active=
#{
true_value
}
"
\
"WHERE NOT services.active AND services.type='SlackService' AND (
#{
active_query
}
) IS NOT NULL"
)
# Tick only build_events if the service is already active
execute
(
"UPDATE services SET build_events=
#{
true_value
}
"
\
"WHERE services.active AND services.type='SlackService' AND (
#{
active_query
}
) IS NOT NULL"
)
end
def
down
end
end
db/migrate/20151210125927_migrate_ci_hip_chat_service.rb
0 → 100644
View file @
80f8074d
class
MigrateCiHipChatService
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
def
up
# From properties strip `hipchat_` key
properties_query
=
"SELECT REPLACE(properties, '
\"
hipchat_', '
\"
') FROM ci_services "
\
'JOIN ci_projects ON ci_services.project_id=ci_projects.id '
\
'WHERE ci_projects.gitlab_id=services.project_id'
active_query
=
'SELECT 1 FROM ci_services '
\
'JOIN ci_projects ON ci_services.project_id=ci_projects.id '
\
"WHERE ci_projects.gitlab_id=services.project_id AND ci_services.type='Ci::HipchatService' AND ci_services.active"
# We update the service since services are always generated for project, even if they are inactive
# Activate service and migrate properties if currently the service is not active
execute
(
"UPDATE services SET properties=(
#{
properties_query
}
), build_events=
#{
true_value
}
, active=
#{
true_value
}
"
\
"WHERE NOT services.active AND services.type='HipchatService' AND (
#{
active_query
}
) IS NOT NULL"
)
# Tick only build_events if the service is already active
execute
(
"UPDATE services SET build_events=
#{
true_value
}
"
\
"WHERE services.active AND services.type='HipchatService' AND (
#{
active_query
}
) IS NOT NULL"
)
end
def
down
end
end
db/schema.rb
View file @
80f8074d
...
...
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
201512
09145909
)
do
ActiveRecord
::
Schema
.
define
(
version:
201512
10125927
)
do
# These are extensions that must be enabled in order to support this database
enable_extension
"plpgsql"
...
...
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