diff --git a/crates/api_models/src/admin.rs b/crates/api_models/src/admin.rs index a1b13c5ff315..6162ceffcb30 100644 --- a/crates/api_models/src/admin.rs +++ b/crates/api_models/src/admin.rs @@ -265,7 +265,7 @@ pub struct MerchantAccountResponse { pub intent_fulfillment_time: Option, /// The organization id merchant is associated with - pub organization_id: Option, + pub organization_id: String, /// A boolean value to indicate if the merchant has recon service is enabled or not, by default value is false pub is_recon_enabled: bool, diff --git a/crates/diesel_models/src/merchant_account.rs b/crates/diesel_models/src/merchant_account.rs index 2b63d4bf9b2b..dd68f3755f11 100644 --- a/crates/diesel_models/src/merchant_account.rs +++ b/crates/diesel_models/src/merchant_account.rs @@ -36,7 +36,7 @@ pub struct MerchantAccount { pub modified_at: time::PrimitiveDateTime, pub frm_routing_algorithm: Option, pub payout_routing_algorithm: Option, - pub organization_id: Option, + pub organization_id: String, pub is_recon_enabled: bool, pub default_profile: Option, pub recon_status: storage_enums::ReconStatus, @@ -65,7 +65,7 @@ pub struct MerchantAccountNew { pub modified_at: time::PrimitiveDateTime, pub frm_routing_algorithm: Option, pub payout_routing_algorithm: Option, - pub organization_id: Option, + pub organization_id: String, pub is_recon_enabled: bool, pub default_profile: Option, pub recon_status: storage_enums::ReconStatus, diff --git a/crates/diesel_models/src/schema.rs b/crates/diesel_models/src/schema.rs index d8a888046b99..0da819f2a70c 100644 --- a/crates/diesel_models/src/schema.rs +++ b/crates/diesel_models/src/schema.rs @@ -437,7 +437,7 @@ diesel::table! { frm_routing_algorithm -> Nullable, payout_routing_algorithm -> Nullable, #[max_length = 32] - organization_id -> Nullable, + organization_id -> Varchar, is_recon_enabled -> Bool, #[max_length = 64] default_profile -> Nullable, diff --git a/crates/router/src/core/admin.rs b/crates/router/src/core/admin.rs index c7009bf4cc98..ec229bd8a564 100644 --- a/crates/router/src/core/admin.rs +++ b/crates/router/src/core/admin.rs @@ -31,6 +31,8 @@ use crate::{ utils::{self, OptionExt}, }; +const DEFAULT_ORG_ID: &str = "org_abcdefghijklmn"; + #[inline] pub fn create_merchant_publishable_key() -> String { format!( @@ -164,7 +166,7 @@ pub async fn create_merchant_account( intent_fulfillment_time: req.intent_fulfillment_time.map(i64::from), payout_routing_algorithm: req.payout_routing_algorithm, id: None, - organization_id: req.organization_id, + organization_id: req.organization_id.unwrap_or(DEFAULT_ORG_ID.to_string()), is_recon_enabled: false, default_profile: None, recon_status: diesel_models::enums::ReconStatus::NotRequested, diff --git a/crates/router/src/types/domain/merchant_account.rs b/crates/router/src/types/domain/merchant_account.rs index 30950f8c9c99..c32942a847da 100644 --- a/crates/router/src/types/domain/merchant_account.rs +++ b/crates/router/src/types/domain/merchant_account.rs @@ -40,7 +40,7 @@ pub struct MerchantAccount { pub modified_at: time::PrimitiveDateTime, pub intent_fulfillment_time: Option, pub payout_routing_algorithm: Option, - pub organization_id: Option, + pub organization_id: String, pub is_recon_enabled: bool, pub default_profile: Option, pub recon_status: diesel_models::enums::ReconStatus, diff --git a/migrations/2023-10-05-085859_make_org_id_mandatory_in_ma/down.sql b/migrations/2023-10-05-085859_make_org_id_mandatory_in_ma/down.sql new file mode 100644 index 000000000000..eb6a02e3dac0 --- /dev/null +++ b/migrations/2023-10-05-085859_make_org_id_mandatory_in_ma/down.sql @@ -0,0 +1,3 @@ +-- This file should undo anything in `up.sql` +ALTER TABLE merchant_account +ALTER COLUMN organization_id DROP NOT NULL; diff --git a/migrations/2023-10-05-085859_make_org_id_mandatory_in_ma/up.sql b/migrations/2023-10-05-085859_make_org_id_mandatory_in_ma/up.sql new file mode 100644 index 000000000000..eb6b24e16aeb --- /dev/null +++ b/migrations/2023-10-05-085859_make_org_id_mandatory_in_ma/up.sql @@ -0,0 +1,8 @@ +-- Your SQL goes here +UPDATE merchant_account +SET organization_id = 'org_abcdefghijklmn' +WHERE organization_id IS NULL; + +ALTER TABLE merchant_account +ALTER COLUMN organization_id +SET NOT NULL; diff --git a/openapi/openapi_spec.json b/openapi/openapi_spec.json index 13ddad32af58..56632a68c39b 100644 --- a/openapi/openapi_spec.json +++ b/openapi/openapi_spec.json @@ -6113,6 +6113,7 @@ "enable_payment_response_hash", "redirect_to_merchant_with_http_post", "primary_business_details", + "organization_id", "is_recon_enabled", "recon_status" ], @@ -6241,8 +6242,7 @@ }, "organization_id": { "type": "string", - "description": "The organization id merchant is associated with", - "nullable": true + "description": "The organization id merchant is associated with" }, "is_recon_enabled": { "type": "boolean",