From f75a1bb76a3e5f90956529396d2762abd6bde44f Mon Sep 17 00:00:00 2001
From: Abdul Wadood <awadood@gitlab.com>
Date: Tue, 29 Oct 2024 12:13:49 +0530
Subject: [PATCH] Add `namespace_details.deleted_at` column

We're transitioning from the boolean `namespace_details.pending_delete`
column to the new `deleted_at` timestamp column. This change improves
clarity, as `pending_delete` incorrectly suggests future scheduling
rather than an ongoing process.

The `deleted_at` column will now indicate when the background deletion
process for a group has started. This will also enable us to see when
the group was deleted to help in debugging if the group deletion fails.

Changelog: other
---
 ...20241029063914_add_deleted_at_to_namespace_details.rb | 9 +++++++++
 db/schema_migrations/20241029063914                      | 1 +
 db/structure.sql                                         | 3 ++-
 3 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 db/migrate/20241029063914_add_deleted_at_to_namespace_details.rb
 create mode 100644 db/schema_migrations/20241029063914

diff --git a/db/migrate/20241029063914_add_deleted_at_to_namespace_details.rb b/db/migrate/20241029063914_add_deleted_at_to_namespace_details.rb
new file mode 100644
index 0000000000000..3e64b5ffd3887
--- /dev/null
+++ b/db/migrate/20241029063914_add_deleted_at_to_namespace_details.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddDeletedAtToNamespaceDetails < Gitlab::Database::Migration[2.2]
+  milestone '17.6'
+
+  def change
+    add_column :namespace_details, :deleted_at, :datetime_with_timezone
+  end
+end
diff --git a/db/schema_migrations/20241029063914 b/db/schema_migrations/20241029063914
new file mode 100644
index 0000000000000..bd67f20119513
--- /dev/null
+++ b/db/schema_migrations/20241029063914
@@ -0,0 +1 @@
+ef347416a77ffd7337d9d38ed191a18920e990bc168738a4058826c5113d7d61
\ No newline at end of file
diff --git a/db/structure.sql b/db/structure.sql
index f3aaf7324bcd8..1e41680f9ed8a 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -14474,7 +14474,8 @@ CREATE TABLE namespace_details (
     description text,
     description_html text,
     creator_id bigint,
-    pending_delete boolean DEFAULT false NOT NULL
+    pending_delete boolean DEFAULT false NOT NULL,
+    deleted_at timestamp with time zone
 );
 
 CREATE TABLE namespace_import_users (
-- 
GitLab