//! The lameness filter's holds: a post the filter caught, hidden pending
//! staff review (the queue shows it as a system flag).
//!
//! * `reasons` — what tripped, one per line, for staff and the author;
//! `scores` — every measurement (JSON), for tuning.
//! * `resolution` — `dismissed` (a false positive: shown again, no strike),
//! `upheld` (staff moderated or deleted it: a strike) or `withdrawn` (the
//! author deleted it first: no strike).
//! * `strike_cleared_at` — staff cleared the strike.
use sea_orm_migration::prelude::*;
#[derive(DeriveMigrationName)]
pub struct Migration;
const UP: &str = r#"
CREATE TABLE post_holds (
id UUID PRIMARY KEY,
post_id UUID NOT NULL REFERENCES posts(id) ON DELETE CASCADE ON UPDATE CASCADE,
user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE ON UPDATE CASCADE,
reasons TEXT NOT NULL,
scores TEXT NOT NULL,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
resolved_at TIMESTAMPTZ NULL,
resolved_by_id UUID NULL REFERENCES users(id) ON DELETE SET NULL,
resolution VARCHAR(16) NULL,
strike_cleared_at TIMESTAMPTZ NULL
);
CREATE INDEX idx_post_holds_pending ON post_holds (post_id) WHERE resolved_at IS NULL;
CREATE INDEX idx_post_holds_user ON post_holds (user_id, created_at);
"#;
const DOWN: &str = r#"
DROP TABLE IF EXISTS post_holds;
"#;
#[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 success · Badges · Packages
⭐
Log in to mark this repository.
1.7 KiB · text
History
263b40b