risingwave_meta_model/
pending_sink_state.rs1use sea_orm::entity::prelude::*;
16use serde::{Deserialize, Serialize};
17
18use crate::{Epoch, SinkId, SinkSchemachange};
19
20#[derive(Clone, Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum, Serialize, Deserialize)]
21#[sea_orm(rs_type = "String", db_type = "string(None)")]
22pub enum SinkState {
23 #[sea_orm(string_value = "PENDING")]
24 Pending,
25 #[sea_orm(string_value = "COMMITTED")]
26 Committed,
27 #[sea_orm(string_value = "ABORTED")]
28 Aborted,
29}
30
31#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
32#[sea_orm(table_name = "pending_sink_state")]
33pub struct Model {
34 #[sea_orm(primary_key, auto_increment = false)]
35 pub sink_id: SinkId,
36 #[sea_orm(primary_key, auto_increment = false)]
37 pub epoch: Epoch,
38 pub sink_state: SinkState,
39 pub metadata: Vec<u8>,
40 pub schema_change: Option<SinkSchemachange>,
41}
42
43impl ActiveModelBehavior for ActiveModel {}
44
45#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
46pub enum Relation {
47 #[sea_orm(
48 belongs_to = "super::sink::Entity",
49 from = "Column::SinkId",
50 to = "super::sink::Column::SinkId",
51 on_update = "NoAction",
52 on_delete = "Cascade"
53 )]
54 Sink,
55 #[sea_orm(
56 belongs_to = "super::object::Entity",
57 from = "Column::SinkId",
58 to = "super::object::Column::Oid",
59 on_update = "NoAction",
60 on_delete = "Cascade"
61 )]
62 Object,
63}