sidebar and shit

This commit is contained in:
Priec
2026-06-16 22:02:07 +02:00
parent f0a6f97609
commit b255e95051
13 changed files with 363 additions and 50 deletions

View File

@@ -26,6 +26,7 @@ mod m20260616_131000_drop_audio_tables;
mod m20260616_132000_drop_blog_and_pages;
mod m20260616_150755_shipping_methods;
mod m20260616_150812_add_shipping_fields_to_orders;
mod m20260616_160000_add_parent_to_categories;
pub struct Migrator;
#[async_trait::async_trait]
@@ -56,6 +57,7 @@ impl MigratorTrait for Migrator {
Box::new(m20260616_132000_drop_blog_and_pages::Migration),
Box::new(m20260616_150755_shipping_methods::Migration),
Box::new(m20260616_150812_add_shipping_fields_to_orders::Migration),
Box::new(m20260616_160000_add_parent_to_categories::Migration),
// inject-above (do not remove this comment)
]
}

View File

@@ -0,0 +1,55 @@
use sea_orm_migration::prelude::*;
#[derive(DeriveMigrationName)]
pub struct Migration;
#[derive(DeriveIden)]
enum Categories {
Table,
Id,
ParentId,
}
const FK_NAME: &str = "fk_categories_parent_id";
#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, m: &SchemaManager) -> Result<(), DbErr> {
m.alter_table(
Table::alter()
.table(Categories::Table)
.add_column(ColumnDef::new(Categories::ParentId).integer().null())
.to_owned(),
)
.await?;
m.create_foreign_key(
ForeignKey::create()
.name(FK_NAME)
.from(Categories::Table, Categories::ParentId)
.to(Categories::Table, Categories::Id)
.on_delete(ForeignKeyAction::SetNull)
.on_update(ForeignKeyAction::Cascade)
.to_owned(),
)
.await
}
async fn down(&self, m: &SchemaManager) -> Result<(), DbErr> {
m.drop_foreign_key(
ForeignKey::drop()
.name(FK_NAME)
.table(Categories::Table)
.to_owned(),
)
.await?;
m.alter_table(
Table::alter()
.table(Categories::Table)
.drop_column(Categories::ParentId)
.to_owned(),
)
.await
}
}