Start work on storing notifications in the database
This commit is contained in:
parent
45f3a98359
commit
cf6ce0dbad
16 changed files with 399 additions and 2 deletions
29
crates/collab/src/db/tables/notification.rs
Normal file
29
crates/collab/src/db/tables/notification.rs
Normal file
|
@ -0,0 +1,29 @@
|
|||
use crate::db::{NotificationId, UserId};
|
||||
use sea_orm::entity::prelude::*;
|
||||
use time::PrimitiveDateTime;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
|
||||
#[sea_orm(table_name = "notifications")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key)]
|
||||
pub id: NotificationId,
|
||||
pub recipient_id: UserId,
|
||||
pub kind: i32,
|
||||
pub is_read: bool,
|
||||
pub created_at: PrimitiveDateTime,
|
||||
pub entity_id_1: Option<i32>,
|
||||
pub entity_id_2: Option<i32>,
|
||||
pub entity_id_3: Option<i32>,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
pub enum Relation {
|
||||
#[sea_orm(
|
||||
belongs_to = "super::user::Entity",
|
||||
from = "Column::RecipientId",
|
||||
to = "super::user::Column::Id"
|
||||
)]
|
||||
Recipient,
|
||||
}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
14
crates/collab/src/db/tables/notification_kind.rs
Normal file
14
crates/collab/src/db/tables/notification_kind.rs
Normal file
|
@ -0,0 +1,14 @@
|
|||
use sea_orm::entity::prelude::*;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
|
||||
#[sea_orm(table_name = "notification_kinds")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key)]
|
||||
pub id: i32,
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
pub enum Relation {}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
Loading…
Add table
Add a link
Reference in a new issue