refactor(migrate,models): apply rustfmt formatting
This commit is contained in:
parent
4c4c33f970
commit
8fd6dbb68b
@ -40,8 +40,12 @@ pub struct Migrator;
|
|||||||
#[async_trait::async_trait]
|
#[async_trait::async_trait]
|
||||||
impl MigratorTrait for Migrator {
|
impl MigratorTrait for Migrator {
|
||||||
fn migrations() -> Vec<Box<dyn MigrationTrait>> {
|
fn migrations() -> Vec<Box<dyn MigrationTrait>> {
|
||||||
vec![Box::new(init::Migration)]
|
vec![
|
||||||
|
Box::new(init::Migration),
|
||||||
|
Box::new(room_compact_summary::Migration),
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod init;
|
pub mod init;
|
||||||
|
pub mod room_compact_summary;
|
||||||
|
|||||||
31
libs/migrate/room_compact_summary.rs
Normal file
31
libs/migrate/room_compact_summary.rs
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
use sea_orm_migration::prelude::*;
|
||||||
|
|
||||||
|
pub struct Migration;
|
||||||
|
|
||||||
|
impl MigrationName for Migration {
|
||||||
|
fn name(&self) -> &str {
|
||||||
|
"room_compact_summary"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[async_trait::async_trait]
|
||||||
|
impl MigrationTrait for Migration {
|
||||||
|
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||||
|
let sql = include_str!("sql/room_compact_summary.sql");
|
||||||
|
super::execute_sql(manager, sql).await?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||||
|
manager
|
||||||
|
.get_connection()
|
||||||
|
.execute_unprepared(
|
||||||
|
r#"
|
||||||
|
DROP INDEX IF EXISTS idx_room_compact_summary_room_to_seq;
|
||||||
|
DROP TABLE IF EXISTS room_compact_summary;
|
||||||
|
"#,
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
16
libs/migrate/sql/room_compact_summary.sql
Normal file
16
libs/migrate/sql/room_compact_summary.sql
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
CREATE TABLE IF NOT EXISTS room_compact_summary
|
||||||
|
(
|
||||||
|
id uuid NOT NULL
|
||||||
|
PRIMARY KEY,
|
||||||
|
room uuid NOT NULL,
|
||||||
|
from_seq bigint NOT NULL,
|
||||||
|
to_seq bigint NOT NULL,
|
||||||
|
summary text NOT NULL,
|
||||||
|
message_count integer NOT NULL,
|
||||||
|
source_message_ids jsonb DEFAULT '[]'::jsonb NOT NULL,
|
||||||
|
created_at timestamp with time zone NOT NULL,
|
||||||
|
updated_at timestamp with time zone NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_room_compact_summary_room_to_seq
|
||||||
|
ON room_compact_summary (room, to_seq DESC);
|
||||||
@ -2,9 +2,7 @@ use crate::{DateTimeUtc, ProjectId, UserId};
|
|||||||
use sea_orm::entity::prelude::*;
|
use sea_orm::entity::prelude::*;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(
|
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, DeriveEntityModel)]
|
||||||
Clone, Debug, PartialEq, Eq, Serialize, Deserialize, DeriveEntityModel,
|
|
||||||
)]
|
|
||||||
#[sea_orm(table_name = "ai_conversation")]
|
#[sea_orm(table_name = "ai_conversation")]
|
||||||
pub struct Model {
|
pub struct Model {
|
||||||
#[sea_orm(primary_key)]
|
#[sea_orm(primary_key)]
|
||||||
|
|||||||
@ -2,9 +2,7 @@ use crate::{DateTimeUtc, Uuid};
|
|||||||
use sea_orm::entity::prelude::*;
|
use sea_orm::entity::prelude::*;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(
|
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, DeriveEntityModel)]
|
||||||
Clone, Debug, PartialEq, Eq, Serialize, Deserialize, DeriveEntityModel,
|
|
||||||
)]
|
|
||||||
#[sea_orm(table_name = "ai_message")]
|
#[sea_orm(table_name = "ai_message")]
|
||||||
pub struct Model {
|
pub struct Model {
|
||||||
#[sea_orm(primary_key)]
|
#[sea_orm(primary_key)]
|
||||||
|
|||||||
@ -3,9 +3,7 @@ use sea_orm::entity::prelude::*;
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
#[derive(
|
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, DeriveEntityModel)]
|
||||||
Clone, Debug, PartialEq, Eq, Serialize, Deserialize, DeriveEntityModel,
|
|
||||||
)]
|
|
||||||
#[sea_orm(table_name = "ai_message_fork")]
|
#[sea_orm(table_name = "ai_message_fork")]
|
||||||
pub struct Model {
|
pub struct Model {
|
||||||
#[sea_orm(primary_key)]
|
#[sea_orm(primary_key)]
|
||||||
|
|||||||
@ -2,9 +2,7 @@ use crate::{DateTimeUtc, UserId};
|
|||||||
use sea_orm::entity::prelude::*;
|
use sea_orm::entity::prelude::*;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(
|
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, DeriveEntityModel)]
|
||||||
Clone, Debug, PartialEq, Eq, Serialize, Deserialize, DeriveEntityModel,
|
|
||||||
)]
|
|
||||||
#[sea_orm(table_name = "ai_shared_conversation")]
|
#[sea_orm(table_name = "ai_shared_conversation")]
|
||||||
pub struct Model {
|
pub struct Model {
|
||||||
#[sea_orm(primary_key)]
|
#[sea_orm(primary_key)]
|
||||||
|
|||||||
@ -2,9 +2,7 @@ use crate::{DateTimeUtc, UserId};
|
|||||||
use sea_orm::entity::prelude::*;
|
use sea_orm::entity::prelude::*;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(
|
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, DeriveEntityModel)]
|
||||||
Clone, Debug, PartialEq, Eq, Serialize, Deserialize, DeriveEntityModel,
|
|
||||||
)]
|
|
||||||
#[sea_orm(table_name = "ai_token_usage")]
|
#[sea_orm(table_name = "ai_token_usage")]
|
||||||
pub struct Model {
|
pub struct Model {
|
||||||
#[sea_orm(primary_key)]
|
#[sea_orm(primary_key)]
|
||||||
|
|||||||
@ -30,4 +30,4 @@ pub struct Model {
|
|||||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||||
pub enum Relation {}
|
pub enum Relation {}
|
||||||
|
|
||||||
impl ActiveModelBehavior for ActiveModel {}
|
impl ActiveModelBehavior for ActiveModel {}
|
||||||
|
|||||||
@ -50,8 +50,8 @@ pub mod ai_message;
|
|||||||
pub mod ai_message_fork;
|
pub mod ai_message_fork;
|
||||||
pub mod ai_session;
|
pub mod ai_session;
|
||||||
pub mod ai_shared_conversation;
|
pub mod ai_shared_conversation;
|
||||||
|
pub mod ai_token_usage;
|
||||||
pub mod ai_tool_auth;
|
pub mod ai_tool_auth;
|
||||||
pub mod ai_tool_call;
|
pub mod ai_tool_call;
|
||||||
pub mod ai_token_usage;
|
|
||||||
pub mod billing_error;
|
pub mod billing_error;
|
||||||
pub mod subscription;
|
pub mod subscription;
|
||||||
|
|||||||
@ -60,4 +60,4 @@ pub struct Model {
|
|||||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||||
pub enum Relation {}
|
pub enum Relation {}
|
||||||
|
|
||||||
impl ActiveModelBehavior for ActiveModel {}
|
impl ActiveModelBehavior for ActiveModel {}
|
||||||
|
|||||||
@ -4,9 +4,7 @@ use serde::{Deserialize, Serialize};
|
|||||||
|
|
||||||
/// Project-level context management settings.
|
/// Project-level context management settings.
|
||||||
/// Controls compaction (sliding window) and RAG behavior.
|
/// Controls compaction (sliding window) and RAG behavior.
|
||||||
#[derive(
|
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, DeriveEntityModel)]
|
||||||
Clone, Debug, PartialEq, Serialize, Deserialize, DeriveEntityModel,
|
|
||||||
)]
|
|
||||||
#[sea_orm(table_name = "project_context_setting")]
|
#[sea_orm(table_name = "project_context_setting")]
|
||||||
pub struct Model {
|
pub struct Model {
|
||||||
#[sea_orm(primary_key)]
|
#[sea_orm(primary_key)]
|
||||||
@ -35,4 +33,4 @@ pub struct Model {
|
|||||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||||
pub enum Relation {}
|
pub enum Relation {}
|
||||||
|
|
||||||
impl ActiveModelBehavior for ActiveModel {}
|
impl ActiveModelBehavior for ActiveModel {}
|
||||||
|
|||||||
@ -106,4 +106,4 @@ pub mod room_message_reaction;
|
|||||||
pub mod room_notifications;
|
pub mod room_notifications;
|
||||||
pub mod room_pin;
|
pub mod room_pin;
|
||||||
pub mod room_thread;
|
pub mod room_thread;
|
||||||
pub mod room_user_state;
|
pub mod room_user_state;
|
||||||
|
|||||||
@ -31,4 +31,4 @@ impl Related<super::room::Entity> for Entity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ActiveModelBehavior for ActiveModel {}
|
impl ActiveModelBehavior for ActiveModel {}
|
||||||
|
|||||||
@ -57,4 +57,4 @@ impl Related<super::room_thread::Entity> for Entity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ActiveModelBehavior for ActiveModel {}
|
impl ActiveModelBehavior for ActiveModel {}
|
||||||
|
|||||||
@ -37,4 +37,4 @@ impl Related<super::room::Entity> for Entity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ActiveModelBehavior for ActiveModel {}
|
impl ActiveModelBehavior for ActiveModel {}
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
pub use user::Entity as User;
|
pub use user::Entity as User;
|
||||||
pub use user_2fa::Entity as User2fa;
|
pub use user_2fa::Entity as User2fa;
|
||||||
pub use user_activity_log::Entity as UserActivityLog;
|
pub use user_activity_log::Entity as UserActivityLog;
|
||||||
|
pub use user_billing::Entity as UserBilling;
|
||||||
pub use user_email::Entity as UserEmail;
|
pub use user_email::Entity as UserEmail;
|
||||||
pub use user_email_change::Entity as UserEmailChange;
|
pub use user_email_change::Entity as UserEmailChange;
|
||||||
pub use user_notification::Entity as UserNotification;
|
pub use user_notification::Entity as UserNotification;
|
||||||
@ -10,11 +11,11 @@ pub use user_preferences::Entity as UserPreferences;
|
|||||||
pub use user_relation::Entity as UserRelation;
|
pub use user_relation::Entity as UserRelation;
|
||||||
pub use user_ssh_key::Entity as UserSshKey;
|
pub use user_ssh_key::Entity as UserSshKey;
|
||||||
pub use user_token::Entity as UserToken;
|
pub use user_token::Entity as UserToken;
|
||||||
pub use user_billing::Entity as UserBilling;
|
|
||||||
|
|
||||||
pub mod user;
|
pub mod user;
|
||||||
pub mod user_2fa;
|
pub mod user_2fa;
|
||||||
pub mod user_activity_log;
|
pub mod user_activity_log;
|
||||||
|
pub mod user_billing;
|
||||||
pub mod user_email;
|
pub mod user_email;
|
||||||
pub mod user_email_change;
|
pub mod user_email_change;
|
||||||
pub mod user_notification;
|
pub mod user_notification;
|
||||||
@ -24,4 +25,3 @@ pub mod user_preferences;
|
|||||||
pub mod user_relation;
|
pub mod user_relation;
|
||||||
pub mod user_ssh_key;
|
pub mod user_ssh_key;
|
||||||
pub mod user_token;
|
pub mod user_token;
|
||||||
pub mod user_billing;
|
|
||||||
|
|||||||
@ -43,4 +43,4 @@ impl Related<crate::users::user::Entity> for Entity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ActiveModelBehavior for ActiveModel {}
|
impl ActiveModelBehavior for ActiveModel {}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user