mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-02 12:06:56 +08:00
chore(users): change entity_type column of roles to non-optional (#6435)
This commit is contained in:
@ -18,7 +18,7 @@ pub struct Role {
|
|||||||
pub created_by: String,
|
pub created_by: String,
|
||||||
pub last_modified_at: PrimitiveDateTime,
|
pub last_modified_at: PrimitiveDateTime,
|
||||||
pub last_modified_by: String,
|
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)]
|
#[derive(router_derive::Setter, Clone, Debug, Insertable, router_derive::DebugAsDisplay)]
|
||||||
@ -35,7 +35,7 @@ pub struct RoleNew {
|
|||||||
pub created_by: String,
|
pub created_by: String,
|
||||||
pub last_modified_at: PrimitiveDateTime,
|
pub last_modified_at: PrimitiveDateTime,
|
||||||
pub last_modified_by: String,
|
pub last_modified_by: String,
|
||||||
pub entity_type: Option<enums::EntityType>,
|
pub entity_type: enums::EntityType,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, AsChangeset, router_derive::DebugAsDisplay)]
|
#[derive(Clone, Debug, AsChangeset, router_derive::DebugAsDisplay)]
|
||||||
|
|||||||
@ -1235,7 +1235,7 @@ diesel::table! {
|
|||||||
#[max_length = 64]
|
#[max_length = 64]
|
||||||
last_modified_by -> Varchar,
|
last_modified_by -> Varchar,
|
||||||
#[max_length = 64]
|
#[max_length = 64]
|
||||||
entity_type -> Nullable<Varchar>,
|
entity_type -> Varchar,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1181,7 +1181,7 @@ diesel::table! {
|
|||||||
#[max_length = 64]
|
#[max_length = 64]
|
||||||
last_modified_by -> Varchar,
|
last_modified_by -> Varchar,
|
||||||
#[max_length = 64]
|
#[max_length = 64]
|
||||||
entity_type -> Nullable<Varchar>,
|
entity_type -> Varchar,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -92,7 +92,7 @@ pub async fn create_role(
|
|||||||
org_id: user_from_token.org_id,
|
org_id: user_from_token.org_id,
|
||||||
groups: req.groups,
|
groups: req.groups,
|
||||||
scope: req.role_scope,
|
scope: req.role_scope,
|
||||||
entity_type: Some(EntityType::Merchant),
|
entity_type: EntityType::Merchant,
|
||||||
created_by: user_from_token.user_id.clone(),
|
created_by: user_from_token.user_id.clone(),
|
||||||
last_modified_by: user_from_token.user_id,
|
last_modified_by: user_from_token.user_id,
|
||||||
created_at: now,
|
created_at: now,
|
||||||
|
|||||||
@ -354,7 +354,7 @@ impl RoleInterface for MockDb {
|
|||||||
None => true,
|
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)
|
.take(limit_usize)
|
||||||
.cloned()
|
.cloned()
|
||||||
|
|||||||
@ -119,7 +119,7 @@ impl From<diesel_models::role::Role> for RoleInfo {
|
|||||||
role_name: role.role_name,
|
role_name: role.role_name,
|
||||||
groups: role.groups.into_iter().map(Into::into).collect(),
|
groups: role.groups.into_iter().map(Into::into).collect(),
|
||||||
scope: role.scope,
|
scope: role.scope,
|
||||||
entity_type: role.entity_type.unwrap_or(EntityType::Merchant),
|
entity_type: role.entity_type,
|
||||||
is_invitable: true,
|
is_invitable: true,
|
||||||
is_deletable: true,
|
is_deletable: true,
|
||||||
is_updatable: true,
|
is_updatable: true,
|
||||||
|
|||||||
@ -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;
|
||||||
@ -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;
|
||||||
Reference in New Issue
Block a user