diff --git a/src/meta/model_v2/src/object.rs b/src/meta/model_v2/src/object.rs index 663f436fcbcb6..4ee0e5a4f4c49 100644 --- a/src/meta/model_v2/src/object.rs +++ b/src/meta/model_v2/src/object.rs @@ -105,6 +105,14 @@ pub enum Relation { on_delete = "Cascade" )] SelfRef1, + #[sea_orm( + belongs_to = "super::database::Entity", + from = "Column::DatabaseId", + to = "super::database::Column::DatabaseId", + on_update = "NoAction", + on_delete = "NoAction" + )] + Database2, #[sea_orm(has_many = "super::schema::Entity")] Schema, #[sea_orm(has_many = "super::sink::Entity")] diff --git a/src/meta/src/controller/catalog.rs b/src/meta/src/controller/catalog.rs index a85d9077e1acd..16c191f3b7ca0 100644 --- a/src/meta/src/controller/catalog.rs +++ b/src/meta/src/controller/catalog.rs @@ -2630,7 +2630,7 @@ impl CatalogController { let inner = self.inner.read().await; let table_obj = Table::find() .find_also_related(Object) - .join(JoinType::InnerJoin, object::Relation::Database.def()) + .join(JoinType::InnerJoin, object::Relation::Database2.def()) .filter( table::Column::Name .eq(table_name)