Issue:
Bug: feat(themes): Support naming themes



Currently themes don't have names, and it's better to have a way to attach a name to a theme. So that we can know about theme without having to look at the theme data.

Pull request description:
## Type of Change
<!-- Put an `x` in the boxes that apply -->

- [ ] Bugfix
- [ ] New feature
- [x] Enhancement
- [ ] Refactoring
- [ ] Dependency updates
- [ ] Documentation
- [ ] CI/CD

## Description
<!-- Describe your changes in detail -->
This PR adds `theme_name` and `entity_type` in the themes table.
This will help us in 
1. Having a name for the theme.
2. EntityType identifier to help us identity the lineage type instead of guessing it.

### Additional Changes

- [ ] This PR modifies the API contract
- [x] This PR modifies the database schema
- [ ] This PR modifies application configuration/environment variables

<!--
Provide links to the files with corresponding changes.

Following are the paths where you can find config files:
1. `config`
3. `crates/router/src/configs`
4. `loadtest/config`
-->


## Motivation and Context
<!--
Why is this change required? What problem does it solve?
If it fixes an open issue, please link to the issue here.

If you don't have an issue, we'd recommend starting with one first so the PR
can focus on the implementation (unless it is an obvious bug or documentation fix
that will have little conversation).
-->
Closes #6620.

## How did you test it?
<!--
Did you write an integration/unit/API test to verify the code changes?
Or did you test this change manually (provide relevant screenshots)?
-->
This is an internal change and doesn't affect any APIs.

## Checklist
<!-- Put an `x` in the boxes that apply -->

- [x] I formatted the code `cargo +nightly fmt --all`
- [x] I addressed lints thrown by `cargo clippy`
- [x] I reviewed the submitted code
- [ ] I added unit tests for my changes where possible


Testing:

This is an internal change and doesn't affect any APIs.

Patch:
diff --git a/crates/common_utils/src/types/theme.rs b/crates/common_utils/src/types/theme.rs
index a2e6fe4b19c..03b4cf23a6c 100644
--- a/crates/common_utils/src/types/theme.rs
+++ b/crates/common_utils/src/types/theme.rs
@@ -4,11 +4,12 @@ use crate::id_type;
 /// Currently being used for theme related APIs and queries.
 #[derive(Debug)]
 pub enum ThemeLineage {
-    /// Tenant lineage variant
-    Tenant {
-        /// tenant_id: String
-        tenant_id: String,
-    },
+    // TODO: Add back Tenant variant when we introduce Tenant Variant in EntityType
+    // /// Tenant lineage variant
+    // Tenant {
+    //     /// tenant_id: String
+    //     tenant_id: String,
+    // },
     /// Org lineage variant
     Organization {
         /// tenant_id: String
diff --git a/crates/diesel_models/src/query/user/theme.rs b/crates/diesel_models/src/query/user/theme.rs
index c021edca325..78fd5025ef9 100644
--- a/crates/diesel_models/src/query/user/theme.rs
+++ b/crates/diesel_models/src/query/user/theme.rs
@@ -3,7 +3,7 @@ use diesel::{
     associations::HasTable,
     pg::Pg,
     sql_types::{Bool, Nullable},
-    BoolExpressionMethods, ExpressionMethods, NullableExpressionMethods,
+    BoolExpressionMethods, ExpressionMethods,
 };
 
 use crate::{
@@ -27,14 +27,15 @@ impl Theme {
             + 'static,
     > {
         match lineage {
-            ThemeLineage::Tenant { tenant_id } => Box::new(
-                dsl::tenant_id
-                    .eq(tenant_id)
-                    .and(dsl::org_id.is_null())
-                    .and(dsl::merchant_id.is_null())
-                    .and(dsl::profile_id.is_null())
-                    .nullable(),
-            ),
+            // TODO: Add back Tenant variant when we introduce Tenant Variant in EntityType
+            // ThemeLineage::Tenant { tenant_id } => Box::new(
+            //     dsl::tenant_id
+            //         .eq(tenant_id)
+            //         .and(dsl::org_id.is_null())
+            //         .and(dsl::merchant_id.is_null())
+            //         .and(dsl::profile_id.is_null())
+            //         .nullable(),
+            // ),
             ThemeLineage::Organization { tenant_id, org_id } => Box::new(
                 dsl::tenant_id
                     .eq(tenant_id)
diff --git a/crates/diesel_models/src/schema.rs b/crates/diesel_models/src/schema.rs
index 19a0763d770..4b3a374090e 100644
--- a/crates/diesel_models/src/schema.rs
+++ b/crates/diesel_models/src/schema.rs
@@ -1279,6 +1279,10 @@ diesel::table! {
         profile_id -> Nullable<Varchar>,
         created_at -> Timestamp,
         last_modified_at -> Timestamp,
+        #[max_length = 64]
+        entity_type -> Varchar,
+        #[max_length = 64]
+        theme_name -> Varchar,
     }
 }
 
diff --git a/crates/diesel_models/src/schema_v2.rs b/crates/diesel_models/src/schema_v2.rs
index e3097f80db9..21f112ea37c 100644
--- a/crates/diesel_models/src/schema_v2.rs
+++ b/crates/diesel_models/src/schema_v2.rs
@@ -1225,6 +1225,10 @@ diesel::table! {
         profile_id -> Nullable<Varchar>,
         created_at -> Timestamp,
         last_modified_at -> Timestamp,
+        #[max_length = 64]
+        entity_type -> Varchar,
+        #[max_length = 64]
+        theme_name -> Varchar,
     }
 }
 
diff --git a/crates/diesel_models/src/user/theme.rs b/crates/diesel_models/src/user/theme.rs
index 0824ae71919..2f8152e419c 100644
--- a/crates/diesel_models/src/user/theme.rs
+++ b/crates/diesel_models/src/user/theme.rs
@@ -1,3 +1,4 @@
+use common_enums::EntityType;
 use common_utils::id_type;
 use diesel::{Identifiable, Insertable, Queryable, Selectable};
 use time::PrimitiveDateTime;
@@ -14,6 +15,8 @@ pub struct Theme {
     pub profile_id: Option<id_type::ProfileId>,
     pub created_at: PrimitiveDateTime,
     pub last_modified_at: PrimitiveDateTime,
+    pub entity_type: EntityType,
+    pub theme_name: String,
 }
 
 #[derive(Clone, Debug, Insertable, router_derive::DebugAsDisplay)]
@@ -26,4 +29,6 @@ pub struct ThemeNew {
     pub profile_id: Option<id_type::ProfileId>,
     pub created_at: PrimitiveDateTime,
     pub last_modified_at: PrimitiveDateTime,
+    pub entity_type: EntityType,
+    pub theme_name: String,
 }
diff --git a/crates/router/src/db/user/theme.rs b/crates/router/src/db/user/theme.rs
index d71b82cdea4..f1e4f4f794e 100644
--- a/crates/router/src/db/user/theme.rs
+++ b/crates/router/src/db/user/theme.rs
@@ -65,12 +65,13 @@ impl ThemeInterface for Store {
 
 fn check_theme_with_lineage(theme: &storage::Theme, lineage: &ThemeLineage) -> bool {
     match lineage {
-        ThemeLineage::Tenant { tenant_id } => {
-            &theme.tenant_id == tenant_id
-                && theme.org_id.is_none()
-                && theme.merchant_id.is_none()
-                && theme.profile_id.is_none()
-        }
+        // TODO: Add back Tenant variant when we introduce Tenant Variant in EntityType
+        // ThemeLineage::Tenant { tenant_id } => {
+        //     &theme.tenant_id == tenant_id
+        //         && theme.org_id.is_none()
+        //         && theme.merchant_id.is_none()
+        //         && theme.profile_id.is_none()
+        // }
         ThemeLineage::Organization { tenant_id, org_id } => {
             &theme.tenant_id == tenant_id
                 && theme
@@ -156,6 +157,8 @@ impl ThemeInterface for MockDb {
             profile_id: new_theme.profile_id,
             created_at: new_theme.created_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());
 
diff --git a/migrations/2024-11-20-110014_add-entity-type-and-theme-name-in-themes/down.sql b/migrations/2024-11-20-110014_add-entity-type-and-theme-name-in-themes/down.sql
new file mode 100644
index 00000000000..a56426b60c0
--- /dev/null
+++ b/migrations/2024-11-20-110014_add-entity-type-and-theme-name-in-themes/down.sql
@@ -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;
diff --git a/migrations/2024-11-20-110014_add-entity-type-and-theme-name-in-themes/up.sql b/migrations/2024-11-20-110014_add-entity-type-and-theme-name-in-themes/up.sql
new file mode 100644
index 00000000000..924385d45d6
--- /dev/null
+++ b/migrations/2024-11-20-110014_add-entity-type-and-theme-name-in-themes/up.sql
@@ -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;