risingwave_meta_model/
secret.rs1use risingwave_pb::catalog::PbSecret;
16use sea_orm::ActiveValue::Set;
17use sea_orm::entity::prelude::*;
18use serde::{Deserialize, Serialize};
19
20#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
21#[sea_orm(table_name = "secret")]
22pub struct Model {
23    #[sea_orm(primary_key, auto_increment = false)]
24    pub secret_id: i32,
25    pub name: String,
26    pub value: Vec<u8>,
27}
28
29#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
30pub enum Relation {
31    #[sea_orm(
32        belongs_to = "super::object::Entity",
33        from = "Column::SecretId",
34        to = "super::object::Column::Oid",
35        on_update = "NoAction",
36        on_delete = "Cascade"
37    )]
38    Object,
39}
40
41impl Related<super::object::Entity> for Entity {
42    fn to() -> RelationDef {
43        Relation::Object.def()
44    }
45}
46
47impl ActiveModelBehavior for ActiveModel {}
48
49impl From<PbSecret> for ActiveModel {
50    fn from(secret: PbSecret) -> Self {
51        Self {
52            secret_id: Set(secret.id as _),
53            name: Set(secret.name),
54            value: Set(secret.value),
55        }
56    }
57}