diff --git a/db/post_migrate/20240208094017_add_partitioning_constraint_for_ci_stages.rb b/db/post_migrate/20240208094017_add_partitioning_constraint_for_ci_stages.rb
new file mode 100644
index 0000000000000000000000000000000000000000..4b6d9c814a56dd630b938a0365225a1f2d03502f
--- /dev/null
+++ b/db/post_migrate/20240208094017_add_partitioning_constraint_for_ci_stages.rb
@@ -0,0 +1,31 @@
+# frozen_string_literal: true
+
+class AddPartitioningConstraintForCiStages < Gitlab::Database::Migration[2.2]
+  include Gitlab::Database::PartitioningMigrationHelpers::TableManagementHelpers
+
+  milestone '16.10'
+  disable_ddl_transaction!
+  TABLE_NAME = :ci_stages
+  PARENT_TABLE_NAME = :p_ci_stages
+  FIRST_PARTITION = [100, 101]
+  PARTITION_COLUMN = :partition_id
+
+  def up
+    prepare_constraint_for_list_partitioning(
+      table_name: TABLE_NAME,
+      partitioning_column: PARTITION_COLUMN,
+      parent_table_name: PARENT_TABLE_NAME,
+      initial_partitioning_value: FIRST_PARTITION,
+      async: true
+    )
+  end
+
+  def down
+    revert_preparing_constraint_for_list_partitioning(
+      table_name: TABLE_NAME,
+      partitioning_column: PARTITION_COLUMN,
+      parent_table_name: PARENT_TABLE_NAME,
+      initial_partitioning_value: FIRST_PARTITION
+    )
+  end
+end
diff --git a/db/schema_migrations/20240208094017 b/db/schema_migrations/20240208094017
new file mode 100644
index 0000000000000000000000000000000000000000..4ac88a47c6560bab257ffbb03c5530dba073de20
--- /dev/null
+++ b/db/schema_migrations/20240208094017
@@ -0,0 +1 @@
+74cf13414b035b623dd44401794ac00e0377b1340110a9719f4f9e73cf6a21b4
\ No newline at end of file
diff --git a/db/structure.sql b/db/structure.sql
index 7e1fc524fd1e403a8009d98a38ace5d1d187ed54..e268699be56395bbcca2a8cb619a786643f066e5 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -30367,6 +30367,9 @@ ALTER TABLE ONLY pages_domain_acme_orders
 ALTER TABLE ONLY pages_domains
     ADD CONSTRAINT pages_domains_pkey PRIMARY KEY (id);
 
+ALTER TABLE ci_stages
+    ADD CONSTRAINT partitioning_constraint CHECK ((partition_id = ANY (ARRAY[(100)::bigint, (101)::bigint]))) NOT VALID;
+
 ALTER TABLE ONLY path_locks
     ADD CONSTRAINT path_locks_pkey PRIMARY KEY (id);
 
diff --git a/spec/models/ci/build_runner_session_spec.rb b/spec/models/ci/build_runner_session_spec.rb
index dac7edbe6cc5450c0998cc0588d5ee66f2542c08..198eb9364970ca87ce416f59619c92090390a005 100644
--- a/spec/models/ci/build_runner_session_spec.rb
+++ b/spec/models/ci/build_runner_session_spec.rb
@@ -183,11 +183,11 @@
     let(:build_runner_session) { create(:ci_build_runner_session, build: new_build) }
 
     before do
-      stub_current_partition_id
+      stub_current_partition_id(ci_testing_partition_id_for_check_constraints)
     end
 
     it 'assigns the same partition id as the one that build has' do
-      expect(build_runner_session.partition_id).to eq(ci_testing_partition_id)
+      expect(build_runner_session.partition_id).to eq(ci_testing_partition_id_for_check_constraints)
     end
   end
 end
diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb
index 8741d347c361821c627158ede940fe6fdd175ed3..67d163a34044a910f3403503d78d463f6f31b365 100644
--- a/spec/models/ci/build_spec.rb
+++ b/spec/models/ci/build_spec.rb
@@ -5601,14 +5601,14 @@ def run_job_without_exception
     let(:ci_build) { create(:ci_build, pipeline: new_pipeline) }
 
     before do
-      stub_current_partition_id
+      stub_current_partition_id(ci_testing_partition_id_for_check_constraints)
     end
 
     it 'includes partition_id in the token prefix' do
       prefix = ci_build.token.match(/^glcbt-([\h]+)_/)
       partition_prefix = prefix[1].to_i(16)
 
-      expect(partition_prefix).to eq(ci_testing_partition_id)
+      expect(partition_prefix).to eq(ci_testing_partition_id_for_check_constraints)
     end
   end
 
diff --git a/spec/models/ci/build_trace_metadata_spec.rb b/spec/models/ci/build_trace_metadata_spec.rb
index 866d94b4cbed7b1d1930c4ffc5b0c0b6a9b63caf..667f519ecf50ea61367687f1a68e50a3645b04fd 100644
--- a/spec/models/ci/build_trace_metadata_spec.rb
+++ b/spec/models/ci/build_trace_metadata_spec.rb
@@ -169,11 +169,11 @@
     let(:metadata) { create(:ci_build_trace_metadata, build: new_build) }
 
     before do
-      stub_current_partition_id
+      stub_current_partition_id(ci_testing_partition_id_for_check_constraints)
     end
 
     it 'assigns the same partition id as the one that build has' do
-      expect(metadata.partition_id).to eq(ci_testing_partition_id)
+      expect(metadata.partition_id).to eq(ci_testing_partition_id_for_check_constraints)
     end
   end
 end
diff --git a/spec/models/ci/job_variable_spec.rb b/spec/models/ci/job_variable_spec.rb
index a56e6b6be43ad70064ec19075ce22dee303536bc..8b1191a3930882d1b8093987cbcc715cd7dcf2e9 100644
--- a/spec/models/ci/job_variable_spec.rb
+++ b/spec/models/ci/job_variable_spec.rb
@@ -49,15 +49,15 @@
       let(:job_variable_2) { build(:ci_job_variable, job: ci_build) }
 
       before do
-        stub_current_partition_id
+        stub_current_partition_id(ci_testing_partition_id_for_check_constraints)
       end
 
       it 'creates job variables successfully', :aggregate_failures do
         described_class.bulk_insert!([job_variable, job_variable_2])
 
         expect(described_class.count).to eq(2)
-        expect(described_class.first.partition_id).to eq(ci_testing_partition_id)
-        expect(described_class.last.partition_id).to eq(ci_testing_partition_id)
+        expect(described_class.first.partition_id).to eq(ci_testing_partition_id_for_check_constraints)
+        expect(described_class.last.partition_id).to eq(ci_testing_partition_id_for_check_constraints)
       end
     end
   end
diff --git a/spec/models/ci/pending_build_spec.rb b/spec/models/ci/pending_build_spec.rb
index 331522070df17c4c39bffed6449d8f75da8eb71c..076aad34a9429217b53ec9e325e6d5b266e4f534 100644
--- a/spec/models/ci/pending_build_spec.rb
+++ b/spec/models/ci/pending_build_spec.rb
@@ -2,7 +2,7 @@
 
 require 'spec_helper'
 
-RSpec.describe Ci::PendingBuild do
+RSpec.describe Ci::PendingBuild, feature_category: :continuous_integration do
   let_it_be(:project) { create(:project) }
   let_it_be(:pipeline) { create(:ci_pipeline, project: project) }
 
@@ -200,21 +200,20 @@
     include Ci::PartitioningHelpers
 
     before do
-      stub_current_partition_id
+      stub_current_partition_id(ci_testing_partition_id_for_check_constraints)
     end
 
     let(:new_pipeline ) { create(:ci_pipeline, project: pipeline.project) }
     let(:new_build) { create(:ci_build, pipeline: new_pipeline) }
 
     it 'assigns the same partition id as the one that build has', :aggregate_failures do
-      expect(new_build.partition_id).to eq ci_testing_partition_id
-      expect(new_build.partition_id).not_to eq pipeline.partition_id
+      expect(new_build.partition_id).to eq ci_testing_partition_id_for_check_constraints
 
       described_class.upsert_from_build!(build)
       described_class.upsert_from_build!(new_build)
 
       expect(build.reload.queuing_entry.partition_id).to eq pipeline.partition_id
-      expect(new_build.reload.queuing_entry.partition_id).to eq ci_testing_partition_id
+      expect(new_build.reload.queuing_entry.partition_id).to eq ci_testing_partition_id_for_check_constraints
     end
   end
 
diff --git a/spec/models/ci/resource_group_spec.rb b/spec/models/ci/resource_group_spec.rb
index 9e98cc884de20f061796ce517d325db5140519e5..e2aaeb2a18e2c473e4f3f5217150d7d9b0a93378 100644
--- a/spec/models/ci/resource_group_spec.rb
+++ b/spec/models/ci/resource_group_spec.rb
@@ -2,7 +2,7 @@
 
 require 'spec_helper'
 
-RSpec.describe Ci::ResourceGroup do
+RSpec.describe Ci::ResourceGroup, feature_category: :continuous_delivery do
   let_it_be(:group) { create(:group) }
 
   it_behaves_like 'cleanup by a loose foreign key' do
@@ -37,7 +37,7 @@
     include Ci::PartitioningHelpers
 
     before do
-      stub_current_partition_id
+      stub_current_partition_id(ci_testing_partition_id_for_check_constraints)
     end
 
     subject { resource_group.assign_resource_to(build) }
@@ -78,7 +78,7 @@
     include Ci::PartitioningHelpers
 
     before do
-      stub_current_partition_id
+      stub_current_partition_id(ci_testing_partition_id_for_check_constraints)
     end
 
     subject { resource_group.release_resource_from(build) }
diff --git a/spec/models/ci/running_build_spec.rb b/spec/models/ci/running_build_spec.rb
index 7f254bd235ce7aaf32cc847b9920f6cd9b5e3f0c..0a81eaf9ac0625b368ec1331eea45a14b4959040 100644
--- a/spec/models/ci/running_build_spec.rb
+++ b/spec/models/ci/running_build_spec.rb
@@ -54,21 +54,20 @@
     include Ci::PartitioningHelpers
 
     before do
-      stub_current_partition_id
+      stub_current_partition_id(ci_testing_partition_id_for_check_constraints)
     end
 
     let(:new_pipeline ) { create(:ci_pipeline, project: pipeline.project) }
     let(:new_build) { create(:ci_build, :running, pipeline: new_pipeline, runner: runner) }
 
     it 'assigns the same partition id as the one that build has', :aggregate_failures do
-      expect(new_build.partition_id).to eq ci_testing_partition_id
-      expect(new_build.partition_id).not_to eq pipeline.partition_id
+      expect(new_build.partition_id).to eq ci_testing_partition_id_for_check_constraints
 
       described_class.upsert_shared_runner_build!(build)
       described_class.upsert_shared_runner_build!(new_build)
 
       expect(build.reload.runtime_metadata.partition_id).to eq pipeline.partition_id
-      expect(new_build.reload.runtime_metadata.partition_id).to eq ci_testing_partition_id
+      expect(new_build.reload.runtime_metadata.partition_id).to eq ci_testing_partition_id_for_check_constraints
     end
   end
 
diff --git a/spec/models/ci/sources/pipeline_spec.rb b/spec/models/ci/sources/pipeline_spec.rb
index 036708ed61ee9e1304785e7ea36304a7c49ea36a..6bc848fadb8cac211497c888bdccddc208e6bd82 100644
--- a/spec/models/ci/sources/pipeline_spec.rb
+++ b/spec/models/ci/sources/pipeline_spec.rb
@@ -44,12 +44,12 @@
     let(:source_pipeline) { create(:ci_sources_pipeline, pipeline: new_pipeline) }
 
     before do
-      stub_current_partition_id
+      stub_current_partition_id(ci_testing_partition_id_for_check_constraints)
     end
 
     it 'assigns partition_id and source_partition_id from pipeline and source_job', :aggregate_failures do
-      expect(source_pipeline.partition_id).to eq(ci_testing_partition_id)
-      expect(source_pipeline.source_partition_id).to eq(ci_testing_partition_id)
+      expect(source_pipeline.partition_id).to eq(ci_testing_partition_id_for_check_constraints)
+      expect(source_pipeline.source_partition_id).to eq(ci_testing_partition_id_for_check_constraints)
     end
   end
 end
diff --git a/spec/requests/api/commit_statuses_spec.rb b/spec/requests/api/commit_statuses_spec.rb
index 9247d9366b2a6bd3ec61dbf649f180f232353420..c49e544c17520a0063b8b2978681f086d6f5808b 100644
--- a/spec/requests/api/commit_statuses_spec.rb
+++ b/spec/requests/api/commit_statuses_spec.rb
@@ -543,11 +543,12 @@ def create_status(commit, opts = {})
       end
 
       context 'with partitions', :ci_partitionable do
-        let(:current_partition_id) { ci_testing_partition_id }
+        include Ci::PartitioningHelpers
+
+        let(:current_partition_id) { ci_testing_partition_id_for_check_constraints }
 
         before do
-          allow(Ci::Pipeline)
-            .to receive(:current_partition_value) { current_partition_id }
+          stub_current_partition_id(ci_testing_partition_id_for_check_constraints)
         end
 
         it 'creates records in the current partition' do
diff --git a/spec/services/ci/create_commit_status_service_spec.rb b/spec/services/ci/create_commit_status_service_spec.rb
index ec200e24c8fb945d25191f7b0694bebce3b79391..3c7346e3e2e7a25585be013a9b1486eae1fb5c37 100644
--- a/spec/services/ci/create_commit_status_service_spec.rb
+++ b/spec/services/ci/create_commit_status_service_spec.rb
@@ -404,12 +404,13 @@
   end
 
   context 'with partitions', :ci_partitionable do
-    let(:current_partition_id) { ci_testing_partition_id }
+    include Ci::PartitioningHelpers
+
+    let(:current_partition_id) { ci_testing_partition_id_for_check_constraints }
     let(:params) { { state: 'running' } }
 
     before do
-      allow(Ci::Pipeline)
-        .to receive(:current_partition_value) { current_partition_id }
+      stub_current_partition_id(ci_testing_partition_id_for_check_constraints)
     end
 
     it 'creates records in the current partition' do