Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

feat(blocklist): add profile_id column to blocklist tables (#13623)

Ayush Anandf58fd810a2af
diff --git a/crates/diesel_models/src/batch_blocklist_job.rs b/crates/diesel_models/src/batch_blocklist_job.rs
index 86697e199d..bff5f25968 100644
--- a/crates/diesel_models/src/batch_blocklist_job.rs
+++ b/crates/diesel_models/src/batch_blocklist_job.rs
@@ -6,6 +6,8 @@ use time::PrimitiveDateTime;
use crate::schema::batch_blocklist_jobs;
+// `profile_id` is read-only for now: the column exists and is selected, but
+// nothing writes or filters on it until the profile-scoping change lands.
#[derive(Clone, Debug, Identifiable, Queryable, Selectable, Deserialize, Serialize)]
#[diesel(table_name = batch_blocklist_jobs, primary_key(id), check_for_backend(diesel::pg::Pg))]
pub struct BatchBlocklistJob {
@@ -17,6 +19,7 @@ pub struct BatchBlocklistJob {
pub failed_rows: i32,
pub created_at: PrimitiveDateTime,
pub updated_at: PrimitiveDateTime,
+ pub profile_id: Option<id_type::ProfileId>,
}
#[derive(Clone, Debug, Insertable, Deserialize, Serialize)]
diff --git a/crates/diesel_models/src/blocklist.rs b/crates/diesel_models/src/blocklist.rs
index 153b57e2c4..bff2d0139e 100644
--- a/crates/diesel_models/src/blocklist.rs
+++ b/crates/diesel_models/src/blocklist.rs
@@ -15,6 +15,8 @@ pub struct BlocklistNew {
pub created_by: Option<String>,
}
+// `profile_id` is read-only for now: the column exists and is selected, but
+// nothing writes or filters on it until the profile-scoping change lands.
#[derive(
Clone, Debug, Eq, PartialEq, Identifiable, Queryable, Selectable, Deserialize, Serialize,
)]
@@ -27,4 +29,5 @@ pub struct Blocklist {
pub created_at: time::PrimitiveDateTime,
pub processor_merchant_id: Option<common_utils::id_type::MerchantId>,
pub created_by: Option<String>,
+ pub profile_id: Option<common_utils::id_type::ProfileId>,
}
diff --git a/crates/diesel_models/src/schema.rs b/crates/diesel_models/src/schema.rs
index 8ee7710694..7f58e5192f 100644
--- a/crates/diesel_models/src/schema.rs
+++ b/crates/diesel_models/src/schema.rs
@@ -202,6 +202,8 @@ diesel::table! {
failed_rows -> Int4,
created_at -> Timestamp,
updated_at -> Timestamp,
+ #[max_length = 64]
+ profile_id -> Nullable<Varchar>,
}
}
@@ -221,6 +223,8 @@ diesel::table! {
processor_merchant_id -> Nullable<Varchar>,
#[max_length = 255]
created_by -> Nullable<Varchar>,
+ #[max_length = 64]
+ profile_id -> Nullable<Varchar>,
}
}
diff --git a/crates/diesel_models/src/schema_v2.rs b/crates/diesel_models/src/schema_v2.rs
index b07a491c51..ebe1a7eb46 100644
--- a/crates/diesel_models/src/schema_v2.rs
+++ b/crates/diesel_models/src/schema_v2.rs
@@ -202,6 +202,8 @@ diesel::table! {
failed_rows -> Int4,
created_at -> Timestamp,
updated_at -> Timestamp,
+ #[max_length = 64]
+ profile_id -> Nullable<Varchar>,
}
}
@@ -221,6 +223,8 @@ diesel::table! {
processor_merchant_id -> Nullable<Varchar>,
#[max_length = 255]
created_by -> Nullable<Varchar>,
+ #[max_length = 64]
+ profile_id -> Nullable<Varchar>,
}
}
diff --git a/crates/router/src/db/batch_blocklist_job.rs b/crates/router/src/db/batch_blocklist_job.rs
index 0e70aac549..19921c27f2 100644
--- a/crates/router/src/db/batch_blocklist_job.rs
+++ b/crates/router/src/db/batch_blocklist_job.rs
@@ -126,6 +126,7 @@ impl BatchBlocklistJobInterface for MockDb {
failed_rows: new.failed_rows,
created_at: new.created_at,
updated_at: new.updated_at,
+ profile_id: None,
};
jobs.push(job.clone());
Ok(job)
diff --git a/crates/router/src/db/blocklist.rs b/crates/router/src/db/blocklist.rs
index ceb69563b3..a647724c42 100644
--- a/crates/router/src/db/blocklist.rs
+++ b/crates/router/src/db/blocklist.rs
@@ -279,6 +279,7 @@ impl BlocklistInterface for MockDb {
created_at: entry.created_at,
processor_merchant_id: entry.processor_merchant_id,
created_by: entry.created_by,
+ profile_id: None,
});
inserted += 1;
}
diff --git a/migrations/2026-08-10-090000_add_profile_id_to_blocklist_tables/down.sql b/migrations/2026-08-10-090000_add_profile_id_to_blocklist_tables/down.sql
new file mode 100644
index 0000000000..dae320a98a
--- /dev/null
+++ b/migrations/2026-08-10-090000_add_profile_id_to_blocklist_tables/down.sql
@@ -0,0 +1,5 @@
+-- This file should undo anything in `up.sql`
+
+ALTER TABLE blocklist DROP COLUMN IF EXISTS profile_id;
+
+ALTER TABLE batch_blocklist_jobs DROP COLUMN IF EXISTS profile_id;
diff --git a/migrations/2026-08-10-090000_add_profile_id_to_blocklist_tables/up.sql b/migrations/2026-08-10-090000_add_profile_id_to_blocklist_tables/up.sql
new file mode 100644
index 0000000000..3c4c41bbf9
--- /dev/null
+++ b/migrations/2026-08-10-090000_add_profile_id_to_blocklist_tables/up.sql
@@ -0,0 +1,5 @@
+-- Your SQL goes here
+
+ALTER TABLE blocklist ADD COLUMN IF NOT EXISTS profile_id VARCHAR(64);
+
+ALTER TABLE batch_blocklist_jobs ADD COLUMN IF NOT EXISTS profile_id VARCHAR(64);