mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-29 00:49:42 +08:00
refactor(users): rename user_roles and dashboard_metadata columns (#3135)
Co-authored-by: Apoorv Dixit <apoorv.dixit@juspay.in>
This commit is contained in:
@ -4,7 +4,8 @@ pub mod diesel_exports {
|
||||
DbAttemptStatus as AttemptStatus, DbAuthenticationType as AuthenticationType,
|
||||
DbCaptureMethod as CaptureMethod, DbCaptureStatus as CaptureStatus,
|
||||
DbConnectorStatus as ConnectorStatus, DbConnectorType as ConnectorType,
|
||||
DbCountryAlpha2 as CountryAlpha2, DbCurrency as Currency, DbDisputeStage as DisputeStage,
|
||||
DbCountryAlpha2 as CountryAlpha2, DbCurrency as Currency,
|
||||
DbDashboardMetadata as DashboardMetadata, DbDisputeStage as DisputeStage,
|
||||
DbDisputeStatus as DisputeStatus, DbEventClass as EventClass,
|
||||
DbEventObjectType as EventObjectType, DbEventType as EventType,
|
||||
DbFraudCheckStatus as FraudCheckStatus, DbFraudCheckType as FraudCheckType,
|
||||
@ -16,7 +17,7 @@ pub mod diesel_exports {
|
||||
DbProcessTrackerStatus as ProcessTrackerStatus, DbReconStatus as ReconStatus,
|
||||
DbRefundStatus as RefundStatus, DbRefundType as RefundType,
|
||||
DbRequestIncrementalAuthorization as RequestIncrementalAuthorization,
|
||||
DbRoutingAlgorithmKind as RoutingAlgorithmKind,
|
||||
DbRoutingAlgorithmKind as RoutingAlgorithmKind, DbUserStatus as UserStatus,
|
||||
};
|
||||
}
|
||||
pub use common_enums::*;
|
||||
@ -418,7 +419,7 @@ pub enum FraudCheckLastStep {
|
||||
strum::EnumString,
|
||||
frunk::LabelledGeneric,
|
||||
)]
|
||||
#[diesel_enum(storage_type = "text")]
|
||||
#[diesel_enum(storage_type = "db_enum")]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[strum(serialize_all = "snake_case")]
|
||||
pub enum UserStatus {
|
||||
@ -439,7 +440,7 @@ pub enum UserStatus {
|
||||
strum::EnumString,
|
||||
frunk::LabelledGeneric,
|
||||
)]
|
||||
#[router_derive::diesel_enum(storage_type = "text")]
|
||||
#[router_derive::diesel_enum(storage_type = "db_enum")]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[strum(serialize_all = "snake_case")]
|
||||
pub enum DashboardMetadata {
|
||||
|
||||
@ -195,8 +195,7 @@ diesel::table! {
|
||||
merchant_id -> Varchar,
|
||||
#[max_length = 64]
|
||||
org_id -> Varchar,
|
||||
#[max_length = 64]
|
||||
data_key -> Varchar,
|
||||
data_key -> DashboardMetadata,
|
||||
data_value -> Json,
|
||||
#[max_length = 64]
|
||||
created_by -> Varchar,
|
||||
@ -978,14 +977,13 @@ diesel::table! {
|
||||
role_id -> Varchar,
|
||||
#[max_length = 64]
|
||||
org_id -> Varchar,
|
||||
#[max_length = 64]
|
||||
status -> Varchar,
|
||||
status -> UserStatus,
|
||||
#[max_length = 64]
|
||||
created_by -> Varchar,
|
||||
#[max_length = 64]
|
||||
last_modified_by -> Varchar,
|
||||
created_at -> Timestamp,
|
||||
last_modified_at -> Timestamp,
|
||||
last_modified -> Timestamp,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -15,7 +15,7 @@ pub struct UserRole {
|
||||
pub created_by: String,
|
||||
pub last_modified_by: String,
|
||||
pub created_at: PrimitiveDateTime,
|
||||
pub last_modified_at: PrimitiveDateTime,
|
||||
pub last_modified: PrimitiveDateTime,
|
||||
}
|
||||
|
||||
#[derive(router_derive::Setter, Clone, Debug, Insertable, router_derive::DebugAsDisplay)]
|
||||
@ -29,7 +29,7 @@ pub struct UserRoleNew {
|
||||
pub created_by: String,
|
||||
pub last_modified_by: String,
|
||||
pub created_at: PrimitiveDateTime,
|
||||
pub last_modified_at: PrimitiveDateTime,
|
||||
pub last_modified: PrimitiveDateTime,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, AsChangeset, router_derive::DebugAsDisplay)]
|
||||
@ -38,7 +38,7 @@ pub struct UserRoleUpdateInternal {
|
||||
role_id: Option<String>,
|
||||
status: Option<enums::UserStatus>,
|
||||
last_modified_by: Option<String>,
|
||||
last_modified_at: PrimitiveDateTime,
|
||||
last_modified: PrimitiveDateTime,
|
||||
}
|
||||
|
||||
pub enum UserRoleUpdate {
|
||||
@ -54,7 +54,7 @@ pub enum UserRoleUpdate {
|
||||
|
||||
impl From<UserRoleUpdate> for UserRoleUpdateInternal {
|
||||
fn from(value: UserRoleUpdate) -> Self {
|
||||
let last_modified_at = common_utils::date_time::now();
|
||||
let last_modified = common_utils::date_time::now();
|
||||
match value {
|
||||
UserRoleUpdate::UpdateRole {
|
||||
role_id,
|
||||
@ -63,14 +63,14 @@ impl From<UserRoleUpdate> for UserRoleUpdateInternal {
|
||||
role_id: Some(role_id),
|
||||
last_modified_by: Some(modified_by),
|
||||
status: None,
|
||||
last_modified_at,
|
||||
last_modified,
|
||||
},
|
||||
UserRoleUpdate::UpdateStatus {
|
||||
status,
|
||||
modified_by,
|
||||
} => Self {
|
||||
status: Some(status),
|
||||
last_modified_at,
|
||||
last_modified,
|
||||
last_modified_by: Some(modified_by),
|
||||
role_id: None,
|
||||
},
|
||||
|
||||
@ -381,7 +381,7 @@ pub async fn invite_user(
|
||||
created_by: user_from_token.user_id.clone(),
|
||||
last_modified_by: user_from_token.user_id,
|
||||
created_at: now,
|
||||
last_modified_at: now,
|
||||
last_modified: now,
|
||||
})
|
||||
.await
|
||||
.map_err(|e| {
|
||||
|
||||
@ -123,7 +123,7 @@ impl UserRoleInterface for MockDb {
|
||||
status: user_role.status,
|
||||
created_by: user_role.created_by,
|
||||
created_at: user_role.created_at,
|
||||
last_modified_at: user_role.last_modified_at,
|
||||
last_modified: user_role.last_modified,
|
||||
last_modified_by: user_role.last_modified_by,
|
||||
org_id: user_role.org_id,
|
||||
};
|
||||
|
||||
@ -140,7 +140,7 @@ pub async fn api_key_update(
|
||||
let (merchant_id, key_id) = path.into_inner();
|
||||
let mut payload = json_payload.into_inner();
|
||||
payload.key_id = key_id;
|
||||
payload.merchant_id = merchant_id;
|
||||
payload.merchant_id = merchant_id.clone();
|
||||
|
||||
api::server_wrap(
|
||||
flow,
|
||||
@ -148,7 +148,14 @@ pub async fn api_key_update(
|
||||
&req,
|
||||
payload,
|
||||
|state, _, payload| api_keys::update_api_key(state, payload),
|
||||
&auth::AdminApiAuth,
|
||||
auth::auth_type(
|
||||
&auth::AdminApiAuth,
|
||||
&auth::JWTAuthMerchantFromRoute {
|
||||
merchant_id,
|
||||
required_permission: Permission::ApiKeyWrite,
|
||||
},
|
||||
req.headers(),
|
||||
),
|
||||
api_locking::LockAction::NotApplicable,
|
||||
)
|
||||
.await
|
||||
|
||||
@ -556,7 +556,7 @@ impl NewUser {
|
||||
user_id,
|
||||
role_id,
|
||||
created_at: now,
|
||||
last_modified_at: now,
|
||||
last_modified: now,
|
||||
org_id: self
|
||||
.get_new_merchant()
|
||||
.get_new_organization()
|
||||
@ -829,7 +829,7 @@ impl TryFrom<UserAndRoleJoined> for user_api::UserDetails {
|
||||
role_id,
|
||||
status,
|
||||
role_name,
|
||||
last_modified_at: user_and_role.1.last_modified_at,
|
||||
last_modified_at: user_and_role.0.last_modified_at,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,4 @@
|
||||
-- This file should undo anything in `up.sql`
|
||||
ALTER TABLE user_roles RENAME COLUMN last_modified TO last_modified_at;
|
||||
ALTER TABLE user_roles ALTER COLUMN status TYPE VARCHAR(64) USING (status::text);
|
||||
DROP TYPE IF EXISTS "UserStatus";
|
||||
@ -0,0 +1,4 @@
|
||||
-- Your SQL goes here
|
||||
ALTER TABLE user_roles RENAME COLUMN last_modified_at TO last_modified;
|
||||
CREATE TYPE "UserStatus" AS ENUM ('active', 'invitation_sent');
|
||||
ALTER TABLE user_roles ALTER COLUMN status TYPE "UserStatus" USING (status::"UserStatus");
|
||||
@ -0,0 +1,3 @@
|
||||
-- This file should undo anything in `up.sql`
|
||||
ALTER TABLE dashboard_metadata ALTER COLUMN data_key TYPE VARCHAR(64);
|
||||
DROP TYPE IF EXISTS "DashboardMetadata";
|
||||
@ -0,0 +1,25 @@
|
||||
-- Your SQL goes here
|
||||
CREATE TYPE "DashboardMetadata" AS ENUM (
|
||||
'production_agreement',
|
||||
'setup_processor',
|
||||
'configure_endpoint',
|
||||
'setup_complete',
|
||||
'first_processor_connected',
|
||||
'second_processor_connected',
|
||||
'configured_routing',
|
||||
'test_payment',
|
||||
'integration_method',
|
||||
'stripe_connected',
|
||||
'paypal_connected',
|
||||
'sp_routing_configured',
|
||||
'sp_test_payment',
|
||||
'download_woocom',
|
||||
'configure_woocom',
|
||||
'setup_woocom_webhook',
|
||||
'is_multiple_configuration',
|
||||
'configuration_type',
|
||||
'feedback',
|
||||
'prodintent'
|
||||
);
|
||||
|
||||
ALTER TABLE dashboard_metadata ALTER COLUMN data_key TYPE "DashboardMetadata" USING (data_key::"DashboardMetadata");
|
||||
Reference in New Issue
Block a user