diff options
Diffstat (limited to 'db/post_migrate')
4 files changed, 80 insertions, 0 deletions
diff --git a/db/post_migrate/20170206040400_remove_inactive_default_email_services.rb b/db/post_migrate/20170206040400_remove_inactive_default_email_services.rb new file mode 100644 index 00000000000..a8e63e8bc7d --- /dev/null +++ b/db/post_migrate/20170206040400_remove_inactive_default_email_services.rb @@ -0,0 +1,41 @@ +class RemoveInactiveDefaultEmailServices < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + Gitlab::Database.with_connection_pool(2) do |pool| + threads = [] + + threads << Thread.new do + pool.with_connection do |connection| + connection.execute <<-SQL.strip_heredoc + DELETE FROM services + WHERE type = 'BuildsEmailService' + AND active IS FALSE + AND properties = '{"notify_only_broken_builds":true}'; + SQL + end + end + + threads << Thread.new do + pool.with_connection do |connection| + connection.execute <<-SQL.strip_heredoc + DELETE FROM services + WHERE type = 'PipelinesEmailService' + AND active IS FALSE + AND properties = '{"notify_only_broken_pipelines":true}'; + SQL + end + end + + threads.each(&:join) + end + end + + def down + # Nothing can be done to restore the records + end +end diff --git a/db/post_migrate/20170211073944_disable_invalid_service_templates.rb b/db/post_migrate/20170211073944_disable_invalid_service_templates.rb new file mode 100644 index 00000000000..84954b1ef64 --- /dev/null +++ b/db/post_migrate/20170211073944_disable_invalid_service_templates.rb @@ -0,0 +1,15 @@ +class DisableInvalidServiceTemplates < ActiveRecord::Migration + DOWNTIME = false + + unless defined?(Service) + class Service < ActiveRecord::Base + self.inheritance_column = nil + end + end + + def up + Service.where(template: true, active: true).each do |template| + template.update(active: false) unless template.valid? + end + end +end diff --git a/db/post_migrate/20170214111112_delete_deprecated_gitlab_ci_service.rb b/db/post_migrate/20170214111112_delete_deprecated_gitlab_ci_service.rb new file mode 100644 index 00000000000..09a827d22b0 --- /dev/null +++ b/db/post_migrate/20170214111112_delete_deprecated_gitlab_ci_service.rb @@ -0,0 +1,15 @@ +class DeleteDeprecatedGitlabCiService < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def up + disable_statement_timeout + + execute("DELETE FROM services WHERE type = 'GitlabCiService';") + end + + def down + # noop + end +end diff --git a/db/post_migrate/20170215200045_remove_theme_id_from_users.rb b/db/post_migrate/20170215200045_remove_theme_id_from_users.rb new file mode 100644 index 00000000000..c51646fbe52 --- /dev/null +++ b/db/post_migrate/20170215200045_remove_theme_id_from_users.rb @@ -0,0 +1,9 @@ +class RemoveThemeIdFromUsers < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def change + remove_column :users, :theme_id, :integer + end +end |