//! `topics.held_at`: set while the topic's opening post has a pending
//! lameness hold. The topic is then shown only to its author and staff,
//! everywhere a topic or its title can appear. It's denormalised from
//! `post_holds` so every topic list filters on one column. Only
//! `moderation::sync_topic_held` writes it.
use sea_orm_migration::prelude::*;
#[derive(DeriveMigrationName)]
pub struct Migration;
const UP: &str = r#"
ALTER TABLE topics ADD COLUMN held_at TIMESTAMPTZ NULL;
UPDATE topics t SET held_at = h.created_at
FROM post_holds h JOIN posts p ON p.id = h.post_id
WHERE p.topic_id = t.id AND p.post_number = 1 AND h.resolved_at IS NULL;
"#;
const DOWN: &str = r#"
ALTER TABLE topics DROP COLUMN IF EXISTS held_at;
"#;
#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager.get_connection().execute_unprepared(UP).await.map(|_| ())
}
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager.get_connection().execute_unprepared(DOWN).await.map(|_| ())
}
}
neiam
/recourse
public · Issues · Pulls · Labels · Forks · Compare · Actions running · Badges · Packages
⭐
Log in to mark this repository.
1.1 KiB · text
History
4ed675a