mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-02 04:04:43 +08:00
feat(themes): Add theme_name and entity_type in themes table (#6621)
This commit is contained in:
@ -4,11 +4,12 @@ use crate::id_type;
|
|||||||
/// Currently being used for theme related APIs and queries.
|
/// Currently being used for theme related APIs and queries.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum ThemeLineage {
|
pub enum ThemeLineage {
|
||||||
/// Tenant lineage variant
|
// TODO: Add back Tenant variant when we introduce Tenant Variant in EntityType
|
||||||
Tenant {
|
// /// Tenant lineage variant
|
||||||
/// tenant_id: String
|
// Tenant {
|
||||||
tenant_id: String,
|
// /// tenant_id: String
|
||||||
},
|
// tenant_id: String,
|
||||||
|
// },
|
||||||
/// Org lineage variant
|
/// Org lineage variant
|
||||||
Organization {
|
Organization {
|
||||||
/// tenant_id: String
|
/// tenant_id: String
|
||||||
|
|||||||
@ -3,7 +3,7 @@ use diesel::{
|
|||||||
associations::HasTable,
|
associations::HasTable,
|
||||||
pg::Pg,
|
pg::Pg,
|
||||||
sql_types::{Bool, Nullable},
|
sql_types::{Bool, Nullable},
|
||||||
BoolExpressionMethods, ExpressionMethods, NullableExpressionMethods,
|
BoolExpressionMethods, ExpressionMethods,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
@ -27,14 +27,15 @@ impl Theme {
|
|||||||
+ 'static,
|
+ 'static,
|
||||||
> {
|
> {
|
||||||
match lineage {
|
match lineage {
|
||||||
ThemeLineage::Tenant { tenant_id } => Box::new(
|
// TODO: Add back Tenant variant when we introduce Tenant Variant in EntityType
|
||||||
dsl::tenant_id
|
// ThemeLineage::Tenant { tenant_id } => Box::new(
|
||||||
.eq(tenant_id)
|
// dsl::tenant_id
|
||||||
.and(dsl::org_id.is_null())
|
// .eq(tenant_id)
|
||||||
.and(dsl::merchant_id.is_null())
|
// .and(dsl::org_id.is_null())
|
||||||
.and(dsl::profile_id.is_null())
|
// .and(dsl::merchant_id.is_null())
|
||||||
.nullable(),
|
// .and(dsl::profile_id.is_null())
|
||||||
),
|
// .nullable(),
|
||||||
|
// ),
|
||||||
ThemeLineage::Organization { tenant_id, org_id } => Box::new(
|
ThemeLineage::Organization { tenant_id, org_id } => Box::new(
|
||||||
dsl::tenant_id
|
dsl::tenant_id
|
||||||
.eq(tenant_id)
|
.eq(tenant_id)
|
||||||
|
|||||||
@ -1280,6 +1280,10 @@ diesel::table! {
|
|||||||
profile_id -> Nullable<Varchar>,
|
profile_id -> Nullable<Varchar>,
|
||||||
created_at -> Timestamp,
|
created_at -> Timestamp,
|
||||||
last_modified_at -> Timestamp,
|
last_modified_at -> Timestamp,
|
||||||
|
#[max_length = 64]
|
||||||
|
entity_type -> Varchar,
|
||||||
|
#[max_length = 64]
|
||||||
|
theme_name -> Varchar,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1227,6 +1227,10 @@ diesel::table! {
|
|||||||
profile_id -> Nullable<Varchar>,
|
profile_id -> Nullable<Varchar>,
|
||||||
created_at -> Timestamp,
|
created_at -> Timestamp,
|
||||||
last_modified_at -> Timestamp,
|
last_modified_at -> Timestamp,
|
||||||
|
#[max_length = 64]
|
||||||
|
entity_type -> Varchar,
|
||||||
|
#[max_length = 64]
|
||||||
|
theme_name -> Varchar,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
use common_enums::EntityType;
|
||||||
use common_utils::id_type;
|
use common_utils::id_type;
|
||||||
use diesel::{Identifiable, Insertable, Queryable, Selectable};
|
use diesel::{Identifiable, Insertable, Queryable, Selectable};
|
||||||
use time::PrimitiveDateTime;
|
use time::PrimitiveDateTime;
|
||||||
@ -14,6 +15,8 @@ pub struct Theme {
|
|||||||
pub profile_id: Option<id_type::ProfileId>,
|
pub profile_id: Option<id_type::ProfileId>,
|
||||||
pub created_at: PrimitiveDateTime,
|
pub created_at: PrimitiveDateTime,
|
||||||
pub last_modified_at: PrimitiveDateTime,
|
pub last_modified_at: PrimitiveDateTime,
|
||||||
|
pub entity_type: EntityType,
|
||||||
|
pub theme_name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Insertable, router_derive::DebugAsDisplay)]
|
#[derive(Clone, Debug, Insertable, router_derive::DebugAsDisplay)]
|
||||||
@ -26,4 +29,6 @@ pub struct ThemeNew {
|
|||||||
pub profile_id: Option<id_type::ProfileId>,
|
pub profile_id: Option<id_type::ProfileId>,
|
||||||
pub created_at: PrimitiveDateTime,
|
pub created_at: PrimitiveDateTime,
|
||||||
pub last_modified_at: PrimitiveDateTime,
|
pub last_modified_at: PrimitiveDateTime,
|
||||||
|
pub entity_type: EntityType,
|
||||||
|
pub theme_name: String,
|
||||||
}
|
}
|
||||||
|
|||||||
@ -65,12 +65,13 @@ impl ThemeInterface for Store {
|
|||||||
|
|
||||||
fn check_theme_with_lineage(theme: &storage::Theme, lineage: &ThemeLineage) -> bool {
|
fn check_theme_with_lineage(theme: &storage::Theme, lineage: &ThemeLineage) -> bool {
|
||||||
match lineage {
|
match lineage {
|
||||||
ThemeLineage::Tenant { tenant_id } => {
|
// TODO: Add back Tenant variant when we introduce Tenant Variant in EntityType
|
||||||
&theme.tenant_id == tenant_id
|
// ThemeLineage::Tenant { tenant_id } => {
|
||||||
&& theme.org_id.is_none()
|
// &theme.tenant_id == tenant_id
|
||||||
&& theme.merchant_id.is_none()
|
// && theme.org_id.is_none()
|
||||||
&& theme.profile_id.is_none()
|
// && theme.merchant_id.is_none()
|
||||||
}
|
// && theme.profile_id.is_none()
|
||||||
|
// }
|
||||||
ThemeLineage::Organization { tenant_id, org_id } => {
|
ThemeLineage::Organization { tenant_id, org_id } => {
|
||||||
&theme.tenant_id == tenant_id
|
&theme.tenant_id == tenant_id
|
||||||
&& theme
|
&& theme
|
||||||
@ -156,6 +157,8 @@ impl ThemeInterface for MockDb {
|
|||||||
profile_id: new_theme.profile_id,
|
profile_id: new_theme.profile_id,
|
||||||
created_at: new_theme.created_at,
|
created_at: new_theme.created_at,
|
||||||
last_modified_at: new_theme.last_modified_at,
|
last_modified_at: new_theme.last_modified_at,
|
||||||
|
entity_type: new_theme.entity_type,
|
||||||
|
theme_name: new_theme.theme_name,
|
||||||
};
|
};
|
||||||
themes.push(theme.clone());
|
themes.push(theme.clone());
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,3 @@
|
|||||||
|
-- This file should undo anything in `up.sql`
|
||||||
|
ALTER TABLE themes DROP COLUMN IF EXISTS entity_type;
|
||||||
|
ALTER TABLE themes DROP COLUMN IF EXISTS theme_name;
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
-- Your SQL goes here
|
||||||
|
ALTER TABLE themes ADD COLUMN IF NOT EXISTS entity_type VARCHAR(64) NOT NULL;
|
||||||
|
ALTER TABLE themes ADD COLUMN IF NOT EXISTS theme_name VARCHAR(64) NOT NULL;
|
||||||
Reference in New Issue
Block a user