about page

This commit is contained in:
Priec
2026-05-17 15:05:47 +02:00
parent 7176e01e8c
commit 27887bf664
10 changed files with 205 additions and 0 deletions

View File

@@ -12,6 +12,7 @@ mod m20260517_000007_audio_tags;
mod m20260517_000008_audio_track_tags;
mod m20260517_000009_simple_constraints;
mod m20260517_000010_drop_user_roles;
mod m20260517_000011_site_pages;
pub struct Migrator;
@@ -30,6 +31,7 @@ impl MigratorTrait for Migrator {
Box::new(m20260517_000008_audio_track_tags::Migration),
Box::new(m20260517_000009_simple_constraints::Migration),
Box::new(m20260517_000010_drop_user_roles::Migration),
Box::new(m20260517_000011_site_pages::Migration),
// inject-above (do not remove this comment)
]
}

View File

@@ -0,0 +1,65 @@
use sea_orm_migration::{prelude::*, sea_orm::ConnectionTrait, sea_query::Expr};
#[derive(DeriveMigrationName)]
pub struct Migration;
#[derive(DeriveIden)]
enum SitePages {
Table,
Id,
Slug,
Title,
Content,
CreatedAt,
UpdatedAt,
}
#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, m: &SchemaManager) -> Result<(), DbErr> {
m.create_table(
Table::create()
.table(SitePages::Table)
.if_not_exists()
.col(ColumnDef::new(SitePages::Id).uuid().not_null().primary_key())
.col(
ColumnDef::new(SitePages::Slug)
.string_len(100)
.not_null()
.unique_key(),
)
.col(ColumnDef::new(SitePages::Title).string_len(500).not_null())
.col(ColumnDef::new(SitePages::Content).text().not_null())
.col(
ColumnDef::new(SitePages::CreatedAt)
.timestamp_with_time_zone()
.not_null()
.default(Expr::current_timestamp()),
)
.col(
ColumnDef::new(SitePages::UpdatedAt)
.timestamp_with_time_zone()
.not_null()
.default(Expr::current_timestamp()),
)
.to_owned(),
)
.await?;
m.get_connection()
.execute_unprepared(
"INSERT INTO site_pages (id, slug, title, content, created_at, updated_at) \
VALUES (gen_random_uuid(), 'about', 'About', '', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP) \
ON CONFLICT (slug) DO NOTHING",
)
.await?;
Ok(())
}
async fn down(&self, m: &SchemaManager) -> Result<(), DbErr> {
m.drop_table(Table::drop().table(SitePages::Table).to_owned())
.await?;
Ok(())
}
}