Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-10-24 21:10:18 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-10-24 21:10:18 +0300
commit84cacdae74db0de90cf88ceef2191f399e9659b2 (patch)
tree679f359bde918dd341b70937a9cf5e115851ff89 /lib
parentcb9b55e662d4164d913ef7031adc135d3ea4d9f0 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/database/migration_helpers/v2.rb11
-rw-r--r--lib/gitlab/usage_data.rb11
-rw-r--r--lib/gitlab/usage_data_counters.rb16
3 files changed, 9 insertions, 29 deletions
diff --git a/lib/gitlab/database/migration_helpers/v2.rb b/lib/gitlab/database/migration_helpers/v2.rb
index dd426962033..b5b8b58681c 100644
--- a/lib/gitlab/database/migration_helpers/v2.rb
+++ b/lib/gitlab/database/migration_helpers/v2.rb
@@ -205,8 +205,8 @@ module Gitlab
raise "Column #{old_column} does not exist on #{table}"
end
- if column.default
- raise "#{calling_operation} does not currently support columns with default values"
+ if column.default_function
+ raise "#{calling_operation} does not currently support columns with default functions"
end
unless column_exists?(table, batch_column_name)
@@ -269,17 +269,20 @@ module Gitlab
def create_insert_trigger(trigger_name, quoted_table, quoted_old_column, quoted_new_column)
function_name = function_name_for_trigger(trigger_name)
+ column = columns(quoted_table.delete('"').to_sym).find { |column| column.name == quoted_old_column.delete('"') }
+ quoted_default_value = connection.quote(column.default)
+
execute(<<~SQL)
CREATE OR REPLACE FUNCTION #{function_name}()
RETURNS trigger
LANGUAGE plpgsql
AS $$
BEGIN
- IF NEW.#{quoted_old_column} IS NULL AND NEW.#{quoted_new_column} IS NOT NULL THEN
+ IF NEW.#{quoted_old_column} IS NOT DISTINCT FROM #{quoted_default_value} AND NEW.#{quoted_new_column} IS DISTINCT FROM #{quoted_default_value} THEN
NEW.#{quoted_old_column} = NEW.#{quoted_new_column};
END IF;
- IF NEW.#{quoted_new_column} IS NULL AND NEW.#{quoted_old_column} IS NOT NULL THEN
+ IF NEW.#{quoted_new_column} IS NOT DISTINCT FROM #{quoted_default_value} AND NEW.#{quoted_old_column} IS DISTINCT FROM #{quoted_default_value} THEN
NEW.#{quoted_new_column} = NEW.#{quoted_old_column};
END IF;
diff --git a/lib/gitlab/usage_data.rb b/lib/gitlab/usage_data.rb
index 87ccb9a31da..37c85b413f8 100644
--- a/lib/gitlab/usage_data.rb
+++ b/lib/gitlab/usage_data.rb
@@ -157,7 +157,6 @@ module Gitlab
}.merge(
runners_usage,
integrations_usage,
- usage_counters,
user_preferences_usage,
container_expiration_policies_usage,
service_desk_counts,
@@ -261,16 +260,6 @@ module Gitlab
}
end
- # @return [Hash<Symbol, Integer>]
- def usage_counters
- usage_data_counters.map { |counter| redis_usage_data(counter) }.reduce({}, :merge)
- end
-
- # @return [Array<#totals>] An array of objects that respond to `#totals`
- def usage_data_counters
- Gitlab::UsageDataCounters.unmigrated_counters
- end
-
def components_usage_data
{
git: { version: alt_usage_data(fallback: { major: -1 }) { Gitlab::Git.version } },
diff --git a/lib/gitlab/usage_data_counters.rb b/lib/gitlab/usage_data_counters.rb
index 37c6e1af7c0..c2961de0eb9 100644
--- a/lib/gitlab/usage_data_counters.rb
+++ b/lib/gitlab/usage_data_counters.rb
@@ -2,9 +2,7 @@
module Gitlab
module UsageDataCounters
- COUNTERS = [].freeze
-
- COUNTERS_MIGRATED_TO_INSTRUMENTATION_CLASSES = [
+ COUNTERS = [
PackageEventCounter,
MergeRequestCounter,
DesignsCounter,
@@ -26,12 +24,8 @@ module Gitlab
UnknownEvent = Class.new(UsageDataCounterError)
class << self
- def unmigrated_counters
- self::COUNTERS
- end
-
def counters
- unmigrated_counters + migrated_counters
+ COUNTERS
end
def count(event_name)
@@ -43,12 +37,6 @@ module Gitlab
raise UnknownEvent, "Cannot find counter for event #{event_name}"
end
-
- private
-
- def migrated_counters
- COUNTERS_MIGRATED_TO_INSTRUMENTATION_CLASSES
- end
end
end
end