Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 67 additions & 3 deletions back-end/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions back-end/entity/src/file_metadata.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.0

use sea_orm::entity::prelude::*;

#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "file_metadata")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: i32,
pub space_key: String,
pub file_path: String,
pub file_name: String,
pub file_extension: Option<String>,
pub file_size: Option<i64>,
pub file_hash: Option<String>,
pub mime_type: Option<String>,
pub is_directory: bool,
pub last_modified: DateTimeWithTimeZone,
pub created_at: DateTimeWithTimeZone,
pub content_preview: Option<String>,
pub tags: Option<String>,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {}

impl ActiveModelBehavior for ActiveModel {}
21 changes: 21 additions & 0 deletions back-end/entity/src/knowledge_edge.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.0

use sea_orm::entity::prelude::*;

#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "knowledge_edge")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: i32,
pub from_node_id: String,
pub to_node_id: String,
pub relationship_type: String,
pub weight: Option<i32>,
pub created_at: DateTimeWithTimeZone,
pub metadata: Option<String>,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {}

impl ActiveModelBehavior for ActiveModel {}
25 changes: 25 additions & 0 deletions back-end/entity/src/knowledge_node.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.0

use sea_orm::entity::prelude::*;

#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "knowledge_node")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: i32,
pub node_id: String,
pub node_type: String,
pub title: Option<String>,
pub content: Option<String>,
pub source_file: Option<String>,
pub source_space: Option<String>,
pub created_at: DateTimeWithTimeZone,
pub updated_at: DateTimeWithTimeZone,
pub confidence_score: Option<i32>,
pub metadata: Option<String>,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {}

impl ActiveModelBehavior for ActiveModel {}
4 changes: 4 additions & 0 deletions back-end/entity/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
pub mod prelude;

pub mod space;
pub mod repository;
pub mod file_metadata;
pub mod knowledge_node;
pub mod knowledge_edge;
4 changes: 4 additions & 0 deletions back-end/entity/src/prelude.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.0

pub use super::space::Entity as Space;
pub use super::repository::Entity as Repository;
pub use super::file_metadata::Entity as FileMetadata;
pub use super::knowledge_node::Entity as KnowledgeNode;
pub use super::knowledge_edge::Entity as KnowledgeEdge;
22 changes: 22 additions & 0 deletions back-end/entity/src/repository.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.0

use sea_orm::entity::prelude::*;

#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "repository")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: i32,
pub space_key: String,
pub file_path: String,
pub event_type: String,
pub timestamp: DateTimeWithTimeZone,
pub file_size: Option<i64>,
pub file_hash: Option<String>,
pub metadata: Option<String>,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {}

impl ActiveModelBehavior for ActiveModel {}
10 changes: 9 additions & 1 deletion back-end/migration/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
pub use sea_orm_migration::prelude::*;

mod m20250811_140008_create_space;
mod m20250811_150000_create_repository;
mod m20250811_160000_create_file_metadata;
mod m20250811_170000_create_knowledge_graph;

pub struct Migrator;

#[async_trait::async_trait]
impl MigratorTrait for Migrator {
fn migrations() -> Vec<Box<dyn MigrationTrait>> {
vec![Box::new(m20250811_140008_create_space::Migration)]
vec![
Box::new(m20250811_140008_create_space::Migration),
Box::new(m20250811_150000_create_repository::Migration),
Box::new(m20250811_160000_create_file_metadata::Migration),
Box::new(m20250811_170000_create_knowledge_graph::Migration),
]
}
}
48 changes: 48 additions & 0 deletions back-end/migration/src/m20250811_150000_create_repository.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
use sea_orm_migration::{
prelude::*,
schema::{pk_auto, string, timestamp_with_time_zone, integer, text},
};

#[derive(DeriveMigrationName)]
pub struct Migration;

#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.create_table(
Table::create()
.table(Repository::Table)
.if_not_exists()
.col(pk_auto(Repository::Id))
.col(string(Repository::SpaceKey))
.col(string(Repository::FilePath))
.col(string(Repository::EventType))
.col(timestamp_with_time_zone(Repository::Timestamp))
.col(integer(Repository::FileSize))
.col(string(Repository::FileHash))
.col(text(Repository::Metadata))
.to_owned(),
)
.await
}

async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.drop_table(Table::drop().table(Repository::Table).to_owned())
.await
}
}

#[derive(DeriveIden)]
enum Repository {
Table,
Id,
SpaceKey,
FilePath,
EventType,
Timestamp,
FileSize,
FileHash,
Metadata,
}
58 changes: 58 additions & 0 deletions back-end/migration/src/m20250811_160000_create_file_metadata.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
use sea_orm_migration::{
prelude::*,
schema::{pk_auto, string, timestamp_with_time_zone, integer, text, boolean},
};

#[derive(DeriveMigrationName)]
pub struct Migration;

#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.create_table(
Table::create()
.table(FileMetadata::Table)
.if_not_exists()
.col(pk_auto(FileMetadata::Id))
.col(string(FileMetadata::SpaceKey))
.col(string(FileMetadata::FilePath))
.col(string(FileMetadata::FileName))
.col(string(FileMetadata::FileExtension))
.col(integer(FileMetadata::FileSize))
.col(string(FileMetadata::FileHash))
.col(string(FileMetadata::MimeType))
.col(boolean(FileMetadata::IsDirectory))
.col(timestamp_with_time_zone(FileMetadata::LastModified))
.col(timestamp_with_time_zone(FileMetadata::CreatedAt))
.col(text(FileMetadata::ContentPreview))
.col(text(FileMetadata::Tags))
.to_owned(),
)
.await
}

async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.drop_table(Table::drop().table(FileMetadata::Table).to_owned())
.await
}
}

#[derive(DeriveIden)]
enum FileMetadata {
Table,
Id,
SpaceKey,
FilePath,
FileName,
FileExtension,
FileSize,
FileHash,
MimeType,
IsDirectory,
LastModified,
CreatedAt,
ContentPreview,
Tags,
}
Loading