can store and retrive data now lol ok xd

This commit is contained in:
2026-03-27 17:59:06 +00:00
parent 7ae73dc49e
commit 957cdf22cb
9 changed files with 242 additions and 2 deletions
+2
View File
@@ -4,6 +4,7 @@ mod m20260325_145211_servers;
mod m20260325_145717_members;
mod m20260325_162920_messages;
mod m20260325_233947_content;
mod m20260327_164915_channels;
pub struct Migrator;
@@ -15,6 +16,7 @@ impl MigratorTrait for Migrator {
Box::new(m20260325_145717_members::Migration),
Box::new(m20260325_162920_messages::Migration),
Box::new(m20260325_233947_content::Migration),
Box::new(m20260327_164915_channels::Migration),
]
}
}
@@ -1,6 +1,7 @@
use sea_orm_migration::{prelude::*, schema::*};
use crate::m20260325_233947_content::Content;
use crate::m20260327_164915_channels::{self, Channel};
#[derive(DeriveMigrationName)]
pub struct Migration;
@@ -22,6 +23,12 @@ impl MigrationTrait for Migration {
.from(Messages::Table, Messages::IdContent)
.to(Content::Table, Content::Id),
)
.col(integer(Messages::IdChannel))
.foreign_key(
ForeignKey::create()
.from(Messages::Table, Messages::IdChannel)
.to(Channel::Table, Channel::Id),
)
.col(integer(Messages::IdServer))
.to_owned(),
)
@@ -42,5 +49,6 @@ enum Messages {
IdDiscord,
IdSender,
IdContent,
IdChannel,
IdServer,
}
@@ -0,0 +1,33 @@
use sea_orm_migration::{prelude::*, schema::*};
#[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(Channel::Table)
.if_not_exists()
.col(pk_auto(Channel::Id))
.col(integer(Channel::IdDiscord))
.to_owned(),
)
.await
}
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.drop_table(Table::drop().table(Channel::Table).to_owned())
.await
}
}
#[derive(DeriveIden)]
pub enum Channel {
Table,
Id,
IdDiscord,
}