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