diff --git a/db/migrate/20240517192053_add_advanced_token_scope.rb b/db/migrate/20240517192053_add_advanced_token_scope.rb
new file mode 100644
index 0000000000000000000000000000000000000000..fb34cdcaea94f4fab13ed75f382952ed694ebff5
--- /dev/null
+++ b/db/migrate/20240517192053_add_advanced_token_scope.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class AddAdvancedTokenScope < Gitlab::Database::Migration[2.2]
+  disable_ddl_transaction!
+
+  milestone '17.1'
+
+  def up
+    with_lock_retries do
+      add_column :personal_access_tokens, :advanced_scopes, :text, if_not_exists: true
+    end
+
+    add_text_limit :personal_access_tokens, :advanced_scopes, 4096
+  end
+
+  def down
+    with_lock_retries do
+      remove_column :personal_access_tokens, :advanced_scopes, if_exists: true
+    end
+  end
+end
diff --git a/db/schema_migrations/20240517192053 b/db/schema_migrations/20240517192053
new file mode 100644
index 0000000000000000000000000000000000000000..76fd64e2c0b90aad74205406a307126e2d363810
--- /dev/null
+++ b/db/schema_migrations/20240517192053
@@ -0,0 +1 @@
+520aba73d923a667f37068c1d39cb0f8cc2b5b84c4653ebf50248961e65d6566
\ No newline at end of file
diff --git a/db/structure.sql b/db/structure.sql
index 8709e2a2143aeb54d985ea74e0b931dba9456bc5..bbdd935afda6725cb7a91c594f936064f92784f1 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -13690,7 +13690,9 @@ CREATE TABLE personal_access_tokens (
     expire_notification_delivered boolean DEFAULT false NOT NULL,
     last_used_at timestamp with time zone,
     after_expiry_notification_delivered boolean DEFAULT false NOT NULL,
-    previous_personal_access_token_id bigint
+    previous_personal_access_token_id bigint,
+    advanced_scopes text,
+    CONSTRAINT check_aa95773861 CHECK ((char_length(advanced_scopes) <= 4096))
 );
 
 CREATE SEQUENCE personal_access_tokens_id_seq