From 208f99ff6c24a2dd5a69ed5666a1fd224d78c59b Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Mon, 14 Dec 2015 12:03:28 +0100 Subject: Fix MySQL migration of CI emails [ci skip] --- db/migrate/20151209145909_migrate_ci_emails.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'db') diff --git a/db/migrate/20151209145909_migrate_ci_emails.rb b/db/migrate/20151209145909_migrate_ci_emails.rb index 202fac8e3fc..7f330a2cf0a 100644 --- a/db/migrate/20151209145909_migrate_ci_emails.rb +++ b/db/migrate/20151209145909_migrate_ci_emails.rb @@ -25,7 +25,11 @@ class MigrateCiEmails < ActiveRecord::Migration # This function escapes double-quotes and slash def escape_text(name) - "REPLACE(REPLACE(#{name}, '\\', '\\\\'), '\"', '\\\"')" + if Gitlab::Database.postgresql? + "REPLACE(REPLACE(#{name}, '\\', '\\\\'), '\"', '\\\"')" + else + "REPLACE(REPLACE(#{name}, '\\\\', '\\\\\\\\'), '\\\"', '\\\\\\\"')" + end end # This function returns 0 or 1 for column -- cgit v1.2.3 From 927c40ca496dcb1e7daa567ce173de044b1d3377 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Mon, 14 Dec 2015 12:31:23 +0100 Subject: Fix Ci::Project migration not migrating columns that cannot be NULL [ci skip] --- db/migrate/20151210125930_migrate_ci_to_project.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'db') diff --git a/db/migrate/20151210125930_migrate_ci_to_project.rb b/db/migrate/20151210125930_migrate_ci_to_project.rb index d17b2a425f8..7dfe05174ee 100644 --- a/db/migrate/20151210125930_migrate_ci_to_project.rb +++ b/db/migrate/20151210125930_migrate_ci_to_project.rb @@ -27,11 +27,11 @@ class MigrateCiToProject < ActiveRecord::Migration def migrate_project_column(column, new_column = nil) new_column ||= column subquery = "SELECT ci_projects.#{column} FROM ci_projects WHERE projects.id = ci_projects.gitlab_id" - execute("UPDATE projects SET #{new_column}=(#{subquery}) WHERE #{new_column} IS NULL AND (#{subquery}) IS NOT NULL") + execute("UPDATE projects SET #{new_column}=(#{subquery}) WHERE (#{subquery}) IS NOT NULL") end def migrate_ci_service - subquery = "SELECT active FROM services WHERE projects.id = services.project_id AND type='GitlabCiService'" - execute("UPDATE projects SET builds_enabled=(#{subquery}) WHERE builds_enabled IS NULL AND (#{subquery}) IS NOT NULL") + subquery = "SELECT active FROM services WHERE projects.id = services.project_id AND type='GitlabCiService' LIMIT 1" + execute("UPDATE projects SET builds_enabled=(#{subquery}) WHERE (#{subquery}) IS NOT NULL") end end -- cgit v1.2.3