965 B · text History 263b40b
//! `seed_markers`: one row per one-time seed step that has run (`manage
//! seed`). A step checks its key, not the rows it made, so content staff
//! have since edited, renamed or deleted is never brought back.
use sea_orm_migration::prelude::*;

#[derive(DeriveMigrationName)]
pub struct Migration;

const UP: &str = r#"
CREATE TABLE seed_markers (
    key TEXT PRIMARY KEY,
    created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
    -- What the step made, for the curious (e.g. the welcome topic's id).
    note TEXT NULL
);
"#;

const DOWN: &str = r#"
DROP TABLE IF EXISTS seed_markers;
"#;

#[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(|_| ())
    }
}