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/db
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-04-11 21:08:31 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-04-11 21:08:31 +0300
commit1a2f754734eb189e371e25e685413808f69a7f2c (patch)
tree2c97884971f36d9026600897b74364d2e212a109 /db
parentf1ce71c88c407709987dd4a7b40bdb7596b6baa2 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20230323101138_add_award_emoji_work_item_widget.rb57
-rw-r--r--db/post_migrate/20230328100534_truncate_error_tracking_tables.rb20
-rw-r--r--db/schema_migrations/202303231011381
-rw-r--r--db/schema_migrations/202303281005341
4 files changed, 79 insertions, 0 deletions
diff --git a/db/migrate/20230323101138_add_award_emoji_work_item_widget.rb b/db/migrate/20230323101138_add_award_emoji_work_item_widget.rb
new file mode 100644
index 00000000000..6a6b50c81a5
--- /dev/null
+++ b/db/migrate/20230323101138_add_award_emoji_work_item_widget.rb
@@ -0,0 +1,57 @@
+# frozen_string_literal: true
+
+class AddAwardEmojiWorkItemWidget < Gitlab::Database::Migration[2.1]
+ class WorkItemType < MigrationRecord
+ self.table_name = 'work_item_types'
+ end
+
+ class WidgetDefinition < MigrationRecord
+ self.table_name = 'work_item_widget_definitions'
+ end
+
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+ disable_ddl_transaction!
+
+ WIDGET_NAME = 'Award emoji'
+ WIDGET_ENUM_VALUE = 16
+ WORK_ITEM_TYPES = [
+ 'Issue',
+ 'Incident',
+ 'Test Case',
+ 'Requirement',
+ 'Task',
+ 'Objective',
+ 'Key Result'
+ ].freeze
+
+ def up
+ widgets = []
+
+ WORK_ITEM_TYPES.each do |type_name|
+ type = WorkItemType.find_by_name_and_namespace_id(type_name, nil)
+
+ unless type
+ Gitlab::AppLogger.warn("type #{type_name} is missing, not adding widget")
+
+ next
+ end
+
+ widgets << {
+ work_item_type_id: type.id,
+ name: WIDGET_NAME,
+ widget_type: WIDGET_ENUM_VALUE
+ }
+ end
+
+ return if widgets.empty?
+
+ WidgetDefinition.upsert_all(
+ widgets,
+ unique_by: :index_work_item_widget_definitions_on_default_witype_and_name
+ )
+ end
+
+ def down
+ WidgetDefinition.where(name: WIDGET_NAME).delete_all
+ end
+end
diff --git a/db/post_migrate/20230328100534_truncate_error_tracking_tables.rb b/db/post_migrate/20230328100534_truncate_error_tracking_tables.rb
new file mode 100644
index 00000000000..3b263303795
--- /dev/null
+++ b/db/post_migrate/20230328100534_truncate_error_tracking_tables.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+class TruncateErrorTrackingTables < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ # Only truncate tables on Gitlab.com environments.
+ # TRUNCATE is a DDL statement (it drops the table and re-creates it), so we want to run the
+ # migration in DDL mode, but we also don't want to execute it against all schemas because
+ # it's considered a write operation. So, we'll manually check and skip the migration if
+ # it's on not `:gitlab_main`.
+ return unless Gitlab.com? && Gitlab::Database.gitlab_schemas_for_connection(connection).include?(:gitlab_main)
+
+ execute('TRUNCATE table error_tracking_errors CASCADE')
+ end
+
+ def down
+ # noop
+ end
+end
diff --git a/db/schema_migrations/20230323101138 b/db/schema_migrations/20230323101138
new file mode 100644
index 00000000000..2c464eda729
--- /dev/null
+++ b/db/schema_migrations/20230323101138
@@ -0,0 +1 @@
+3d03a0af6421f0b2a0f26b7a7d385dcabb12565cb0b3f6d23454d8588395a59a \ No newline at end of file
diff --git a/db/schema_migrations/20230328100534 b/db/schema_migrations/20230328100534
new file mode 100644
index 00000000000..7bdf4ba65ab
--- /dev/null
+++ b/db/schema_migrations/20230328100534
@@ -0,0 +1 @@
+f74849f237902c24b996b27c552a95b8a3c080f98c03fcefdf8a7c76638396dc \ No newline at end of file