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
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
chore(users): change entity_type column of roles to non-optional (#6435)
Riddhiagrawal00162067e406a01
diff --git a/crates/diesel_models/src/role.rs b/crates/diesel_models/src/role.rsindex 3fb64e645d..8199bd3979 100644--- a/crates/diesel_models/src/role.rs+++ b/crates/diesel_models/src/role.rs@@ -18,7 +18,7 @@ pub struct Role {pub created_by: String,pub last_modified_at: PrimitiveDateTime,pub last_modified_by: String,- pub entity_type: Option<enums::EntityType>,+ pub entity_type: enums::EntityType,}#[derive(router_derive::Setter, Clone, Debug, Insertable, router_derive::DebugAsDisplay)]@@ -35,7 +35,7 @@ pub struct RoleNew {pub created_by: String,pub last_modified_at: PrimitiveDateTime,pub last_modified_by: String,- pub entity_type: Option<enums::EntityType>,+ pub entity_type: enums::EntityType,}#[derive(Clone, Debug, AsChangeset, router_derive::DebugAsDisplay)]diff --git a/crates/diesel_models/src/schema.rs b/crates/diesel_models/src/schema.rsindex 8d2dfc47b6..e2ab676b2d 100644--- a/crates/diesel_models/src/schema.rs+++ b/crates/diesel_models/src/schema.rs@@ -1235,7 +1235,7 @@ diesel::table! {#[max_length = 64]last_modified_by -> Varchar,#[max_length = 64]- entity_type -> Nullable<Varchar>,+ entity_type -> Varchar,}}diff --git a/crates/diesel_models/src/schema_v2.rs b/crates/diesel_models/src/schema_v2.rsindex b5e895cde7..5651bf95dd 100644--- a/crates/diesel_models/src/schema_v2.rs+++ b/crates/diesel_models/src/schema_v2.rs@@ -1181,7 +1181,7 @@ diesel::table! {#[max_length = 64]last_modified_by -> Varchar,#[max_length = 64]- entity_type -> Nullable<Varchar>,+ entity_type -> Varchar,}}diff --git a/crates/router/src/core/user_role/role.rs b/crates/router/src/core/user_role/role.rsindex 1d37f7ac8d..0250415d4f 100644--- a/crates/router/src/core/user_role/role.rs+++ b/crates/router/src/core/user_role/role.rs@@ -92,7 +92,7 @@ pub async fn create_role(org_id: user_from_token.org_id,groups: req.groups,scope: req.role_scope,- entity_type: Some(EntityType::Merchant),+ entity_type: EntityType::Merchant,created_by: user_from_token.user_id.clone(),last_modified_by: user_from_token.user_id,created_at: now,diff --git a/crates/router/src/db/role.rs b/crates/router/src/db/role.rsindex ce009d38a9..d13508356e 100644--- a/crates/router/src/db/role.rs+++ b/crates/router/src/db/role.rs@@ -354,7 +354,7 @@ impl RoleInterface for MockDb {None => true,};- matches_merchant && role.org_id == *org_id && role.entity_type == entity_type+ matches_merchant && role.org_id == *org_id && Some(role.entity_type) == entity_type}).take(limit_usize).cloned()diff --git a/crates/router/src/services/authorization/roles.rs b/crates/router/src/services/authorization/roles.rsindex 63d547bfa6..bf66eb9246 100644--- a/crates/router/src/services/authorization/roles.rs+++ b/crates/router/src/services/authorization/roles.rs@@ -119,7 +119,7 @@ impl From<diesel_models::role::Role> for RoleInfo {role_name: role.role_name,groups: role.groups.into_iter().map(Into::into).collect(),scope: role.scope,- entity_type: role.entity_type.unwrap_or(EntityType::Merchant),+ entity_type: role.entity_type,is_invitable: true,is_deletable: true,is_updatable: true,diff --git a/migrations/2024-10-24-123318_update-entity-type-column-in-roles/down.sql b/migrations/2024-10-24-123318_update-entity-type-column-in-roles/down.sqlnew file mode 100644index 0000000000..60dfa892e6--- /dev/null+++ b/migrations/2024-10-24-123318_update-entity-type-column-in-roles/down.sql@@ -0,0 +1,4 @@+-- This file should undo anything in `up.sql`+ALTER TABLE roles ALTER COLUMN entity_type DROP DEFAULT;++ALTER TABLE roles ALTER COLUMN entity_type DROP NOT NULL;\ No newline at end of filediff --git a/migrations/2024-10-24-123318_update-entity-type-column-in-roles/up.sql b/migrations/2024-10-24-123318_update-entity-type-column-in-roles/up.sqlnew file mode 100644index 0000000000..564a026184--- /dev/null+++ b/migrations/2024-10-24-123318_update-entity-type-column-in-roles/up.sql@@ -0,0 +1,6 @@+-- Your SQL goes here+UPDATE roles SET entity_type = 'merchant' WHERE entity_type IS NULL;++ALTER TABLE roles ALTER COLUMN entity_type SET DEFAULT 'merchant';++ALTER TABLE roles ALTER COLUMN entity_type SET NOT NULL;\ No newline at end of file