add events and rooms migrations
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2022-07-24 23:08:02 +02:00
parent 9510d9c765
commit d98e9ea9e3
17 changed files with 324 additions and 315 deletions

View File

@@ -6,7 +6,7 @@ publish = false
[dependencies]
chrono = {version = "0.4", features = ["serde"] }
sea-orm = { version = "^0.8", features = ["macros", "with-chrono", "with-uuid", "with-json"], default-features = false }
sea-orm = { version = "^0.9", features = ["macros", "with-chrono", "with-uuid", "with-json"], default-features = false }
serde = "1.0"
serde_json = "1.0"
uuid = { version = "*", features = ["v4", "serde"]}

View File

@@ -1,16 +1,16 @@
use sea_orm::entity::prelude::*;
use sea_orm::{entity::prelude::*, Set};
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
#[sea_orm(table_name = "events")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub uuid: String,
pub room_uuid: String,
pub uuid: Uuid,
pub room_uuid: Uuid,
pub r#type: String,
pub state_key: Option<String>,
pub sender_uuid: String,
pub origin_server_ts: i32,
pub content: String,
pub sender_uuid: Uuid,
pub origin_server_ts: i64,
pub content: Json,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
@@ -45,4 +45,11 @@ impl Related<super::rooms::Entity> for Entity {
}
}
impl ActiveModelBehavior for ActiveModel {}
impl ActiveModelBehavior for ActiveModel {
fn new() -> Self {
Self {
uuid: Set(Uuid::new_v4()),
..ActiveModelTrait::default()
}
}
}

View File

@@ -1,4 +1,6 @@
pub mod devices;
pub mod events;
pub mod prelude;
pub mod rooms;
pub mod sessions;
pub mod users;

View File

@@ -1,10 +1,10 @@
use sea_orm::entity::prelude::*;
use sea_orm::{entity::prelude::*, Set};
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
#[sea_orm(table_name = "rooms")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub uuid: String,
pub uuid: Uuid,
pub name: String,
}
@@ -20,4 +20,11 @@ impl Related<super::events::Entity> for Entity {
}
}
impl ActiveModelBehavior for ActiveModel {}
impl ActiveModelBehavior for ActiveModel {
fn new() -> Self {
Self {
uuid: Set(Uuid::new_v4()),
..ActiveModelTrait::default()
}
}
}