mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-29 09:07:09 +08:00
feat: create additional columns in organization table (#5380)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
@ -13034,13 +13034,23 @@
|
|||||||
"organization_name": {
|
"organization_name": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"nullable": true
|
"nullable": true
|
||||||
|
},
|
||||||
|
"organization_details": {
|
||||||
|
"type": "object",
|
||||||
|
"nullable": true
|
||||||
|
},
|
||||||
|
"metadata": {
|
||||||
|
"type": "object",
|
||||||
|
"nullable": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"OrganizationResponse": {
|
"OrganizationResponse": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
"organization_id"
|
"organization_id",
|
||||||
|
"modified_at",
|
||||||
|
"created_at"
|
||||||
],
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
"organization_id": {
|
"organization_id": {
|
||||||
@ -13052,6 +13062,22 @@
|
|||||||
"organization_name": {
|
"organization_name": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"nullable": true
|
"nullable": true
|
||||||
|
},
|
||||||
|
"organization_details": {
|
||||||
|
"type": "object",
|
||||||
|
"nullable": true
|
||||||
|
},
|
||||||
|
"metadata": {
|
||||||
|
"type": "object",
|
||||||
|
"nullable": true
|
||||||
|
},
|
||||||
|
"modified_at": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "date-time"
|
||||||
|
},
|
||||||
|
"created_at": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "date-time"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
use common_utils::id_type;
|
use common_utils::{id_type, pii};
|
||||||
use utoipa::ToSchema;
|
use utoipa::ToSchema;
|
||||||
pub struct OrganizationNew {
|
pub struct OrganizationNew {
|
||||||
pub org_id: id_type::OrganizationId,
|
pub org_id: id_type::OrganizationId,
|
||||||
@ -22,6 +22,10 @@ pub struct OrganizationId {
|
|||||||
#[derive(Debug, serde::Serialize, serde::Deserialize, Clone, ToSchema)]
|
#[derive(Debug, serde::Serialize, serde::Deserialize, Clone, ToSchema)]
|
||||||
pub struct OrganizationRequest {
|
pub struct OrganizationRequest {
|
||||||
pub organization_name: Option<String>,
|
pub organization_name: Option<String>,
|
||||||
|
#[schema(value_type = Option<Object>)]
|
||||||
|
pub organization_details: Option<pii::SecretSerdeValue>,
|
||||||
|
#[schema(value_type = Option<Object>)]
|
||||||
|
pub metadata: Option<pii::SecretSerdeValue>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, serde::Serialize, Clone, ToSchema)]
|
#[derive(Debug, serde::Serialize, Clone, ToSchema)]
|
||||||
@ -29,4 +33,10 @@ pub struct OrganizationResponse {
|
|||||||
#[schema(value_type = String, max_length = 64, min_length = 1, example = "org_q98uSGAYbjEwqs0mJwnz")]
|
#[schema(value_type = String, max_length = 64, min_length = 1, example = "org_q98uSGAYbjEwqs0mJwnz")]
|
||||||
pub organization_id: id_type::OrganizationId,
|
pub organization_id: id_type::OrganizationId,
|
||||||
pub organization_name: Option<String>,
|
pub organization_name: Option<String>,
|
||||||
|
#[schema(value_type = Option<Object>)]
|
||||||
|
pub organization_details: Option<pii::SecretSerdeValue>,
|
||||||
|
#[schema(value_type = Option<Object>)]
|
||||||
|
pub metadata: Option<pii::SecretSerdeValue>,
|
||||||
|
pub modified_at: time::PrimitiveDateTime,
|
||||||
|
pub created_at: time::PrimitiveDateTime,
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
use common_utils::id_type;
|
use common_utils::{id_type, pii};
|
||||||
use diesel::{AsChangeset, Identifiable, Insertable, Queryable, Selectable};
|
use diesel::{AsChangeset, Identifiable, Insertable, Queryable, Selectable};
|
||||||
|
|
||||||
use crate::schema::organization;
|
use crate::schema::organization;
|
||||||
@ -7,6 +7,10 @@ use crate::schema::organization;
|
|||||||
pub struct Organization {
|
pub struct Organization {
|
||||||
pub org_id: id_type::OrganizationId,
|
pub org_id: id_type::OrganizationId,
|
||||||
pub org_name: Option<String>,
|
pub org_name: Option<String>,
|
||||||
|
pub organization_details: Option<pii::SecretSerdeValue>,
|
||||||
|
pub metadata: Option<pii::SecretSerdeValue>,
|
||||||
|
pub created_at: time::PrimitiveDateTime,
|
||||||
|
pub modified_at: time::PrimitiveDateTime,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Insertable)]
|
#[derive(Clone, Debug, Insertable)]
|
||||||
@ -14,22 +18,42 @@ pub struct Organization {
|
|||||||
pub struct OrganizationNew {
|
pub struct OrganizationNew {
|
||||||
pub org_id: id_type::OrganizationId,
|
pub org_id: id_type::OrganizationId,
|
||||||
pub org_name: Option<String>,
|
pub org_name: Option<String>,
|
||||||
|
pub organization_details: Option<pii::SecretSerdeValue>,
|
||||||
|
pub metadata: Option<pii::SecretSerdeValue>,
|
||||||
|
pub created_at: time::PrimitiveDateTime,
|
||||||
|
pub modified_at: time::PrimitiveDateTime,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, AsChangeset)]
|
#[derive(Clone, Debug, AsChangeset)]
|
||||||
#[diesel(table_name = organization)]
|
#[diesel(table_name = organization)]
|
||||||
pub struct OrganizationUpdateInternal {
|
pub struct OrganizationUpdateInternal {
|
||||||
org_name: Option<String>,
|
org_name: Option<String>,
|
||||||
|
organization_details: Option<pii::SecretSerdeValue>,
|
||||||
|
metadata: Option<pii::SecretSerdeValue>,
|
||||||
|
modified_at: time::PrimitiveDateTime,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum OrganizationUpdate {
|
pub enum OrganizationUpdate {
|
||||||
Update { org_name: Option<String> },
|
Update {
|
||||||
|
org_name: Option<String>,
|
||||||
|
organization_details: Option<pii::SecretSerdeValue>,
|
||||||
|
metadata: Option<pii::SecretSerdeValue>,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<OrganizationUpdate> for OrganizationUpdateInternal {
|
impl From<OrganizationUpdate> for OrganizationUpdateInternal {
|
||||||
fn from(value: OrganizationUpdate) -> Self {
|
fn from(value: OrganizationUpdate) -> Self {
|
||||||
match value {
|
match value {
|
||||||
OrganizationUpdate::Update { org_name } => Self { org_name },
|
OrganizationUpdate::Update {
|
||||||
|
org_name,
|
||||||
|
organization_details,
|
||||||
|
metadata,
|
||||||
|
} => Self {
|
||||||
|
org_name,
|
||||||
|
organization_details,
|
||||||
|
metadata,
|
||||||
|
modified_at: common_utils::date_time::now(),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -733,6 +733,10 @@ diesel::table! {
|
|||||||
#[max_length = 32]
|
#[max_length = 32]
|
||||||
org_id -> Varchar,
|
org_id -> Varchar,
|
||||||
org_name -> Nullable<Text>,
|
org_name -> Nullable<Text>,
|
||||||
|
organization_details -> Nullable<Jsonb>,
|
||||||
|
metadata -> Nullable<Jsonb>,
|
||||||
|
created_at -> Timestamp,
|
||||||
|
modified_at -> Timestamp,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -732,6 +732,10 @@ diesel::table! {
|
|||||||
#[max_length = 32]
|
#[max_length = 32]
|
||||||
org_id -> Varchar,
|
org_id -> Varchar,
|
||||||
org_name -> Nullable<Text>,
|
org_name -> Nullable<Text>,
|
||||||
|
organization_details -> Nullable<Jsonb>,
|
||||||
|
metadata -> Nullable<Jsonb>,
|
||||||
|
created_at -> Timestamp,
|
||||||
|
modified_at -> Timestamp,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -129,6 +129,8 @@ pub async fn update_organization(
|
|||||||
) -> RouterResponse<api::OrganizationResponse> {
|
) -> RouterResponse<api::OrganizationResponse> {
|
||||||
let organization_update = diesel_models::organization::OrganizationUpdate::Update {
|
let organization_update = diesel_models::organization::OrganizationUpdate::Update {
|
||||||
org_name: req.organization_name,
|
org_name: req.organization_name,
|
||||||
|
organization_details: req.organization_details,
|
||||||
|
metadata: req.metadata,
|
||||||
};
|
};
|
||||||
state
|
state
|
||||||
.store
|
.store
|
||||||
|
|||||||
@ -83,6 +83,10 @@ impl OrganizationInterface for super::MockDb {
|
|||||||
let org = storage::Organization {
|
let org = storage::Organization {
|
||||||
org_id: organization.org_id.clone(),
|
org_id: organization.org_id.clone(),
|
||||||
org_name: organization.org_name,
|
org_name: organization.org_name,
|
||||||
|
organization_details: organization.organization_details,
|
||||||
|
metadata: organization.metadata,
|
||||||
|
created_at: common_utils::date_time::now(),
|
||||||
|
modified_at: common_utils::date_time::now(),
|
||||||
};
|
};
|
||||||
organizations.push(org.clone());
|
organizations.push(org.clone());
|
||||||
Ok(org)
|
Ok(org)
|
||||||
@ -118,8 +122,14 @@ impl OrganizationInterface for super::MockDb {
|
|||||||
.iter_mut()
|
.iter_mut()
|
||||||
.find(|org| org.org_id == *org_id)
|
.find(|org| org.org_id == *org_id)
|
||||||
.map(|org| match &update {
|
.map(|org| match &update {
|
||||||
storage::OrganizationUpdate::Update { org_name } => storage::Organization {
|
storage::OrganizationUpdate::Update {
|
||||||
|
org_name,
|
||||||
|
organization_details,
|
||||||
|
metadata,
|
||||||
|
} => storage::Organization {
|
||||||
org_name: org_name.clone(),
|
org_name: org_name.clone(),
|
||||||
|
organization_details: organization_details.clone(),
|
||||||
|
metadata: metadata.clone(),
|
||||||
..org.to_owned()
|
..org.to_owned()
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@ -32,6 +32,10 @@ impl ForeignFrom<diesel_models::organization::Organization> for OrganizationResp
|
|||||||
Self {
|
Self {
|
||||||
organization_id: org.org_id,
|
organization_id: org.org_id,
|
||||||
organization_name: org.org_name,
|
organization_name: org.org_name,
|
||||||
|
organization_details: org.organization_details,
|
||||||
|
metadata: org.metadata,
|
||||||
|
modified_at: org.modified_at,
|
||||||
|
created_at: org.created_at,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -304,6 +304,10 @@ impl From<UserMerchantCreateRequestWithToken> for NewUserOrganization {
|
|||||||
Self(diesel_org::OrganizationNew {
|
Self(diesel_org::OrganizationNew {
|
||||||
org_id: value.2.org_id,
|
org_id: value.2.org_id,
|
||||||
org_name: Some(value.1.company_name),
|
org_name: Some(value.1.company_name),
|
||||||
|
organization_details: None,
|
||||||
|
metadata: None,
|
||||||
|
created_at: common_utils::date_time::now(),
|
||||||
|
modified_at: common_utils::date_time::now(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1281,6 +1281,10 @@ impl ForeignFrom<api_models::organization::OrganizationNew>
|
|||||||
Self {
|
Self {
|
||||||
org_id: item.org_id,
|
org_id: item.org_id,
|
||||||
org_name: item.org_name,
|
org_name: item.org_name,
|
||||||
|
organization_details: None,
|
||||||
|
metadata: None,
|
||||||
|
created_at: common_utils::date_time::now(),
|
||||||
|
modified_at: common_utils::date_time::now(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1293,6 +1297,10 @@ impl ForeignFrom<api_models::organization::OrganizationRequest>
|
|||||||
Self {
|
Self {
|
||||||
org_id: org_new.org_id,
|
org_id: org_new.org_id,
|
||||||
org_name: item.organization_name,
|
org_name: item.organization_name,
|
||||||
|
organization_details: item.organization_details,
|
||||||
|
metadata: item.metadata,
|
||||||
|
created_at: common_utils::date_time::now(),
|
||||||
|
modified_at: common_utils::date_time::now(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,6 @@
|
|||||||
|
-- This file should undo anything in `up.sql`
|
||||||
|
ALTER TABLE organization
|
||||||
|
DROP COLUMN organization_details,
|
||||||
|
DROP COLUMN metadata,
|
||||||
|
DROP created_at,
|
||||||
|
DROP modified_at;
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
-- Your SQL goes here
|
||||||
|
ALTER TABLE organization
|
||||||
|
ADD COLUMN organization_details jsonb,
|
||||||
|
ADD COLUMN metadata jsonb,
|
||||||
|
ADD created_at TIMESTAMP NOT NULL DEFAULT now()::TIMESTAMP,
|
||||||
|
ADD modified_at TIMESTAMP NOT NULL DEFAULT now()::TIMESTAMP;
|
||||||
Reference in New Issue
Block a user