durable-db 0.11.3

Database migrations and schema for the durable workflow engine
Documentation
use sea_orm_migration::prelude::*;

#[derive(DeriveMigrationName)]
pub struct Migration;

const UP: &str = r#"
ALTER TABLE durable.task DROP CONSTRAINT IF EXISTS task_parent_id_name_key;
CREATE INDEX IF NOT EXISTS "idx-task-parent_id-name" ON durable.task(parent_id, name);
"#;

const DOWN: &str = r#"
DROP INDEX IF EXISTS durable."idx-task-parent_id-name";
ALTER TABLE durable.task ADD CONSTRAINT task_parent_id_name_key UNIQUE (parent_id, name);
"#;

#[async_trait::async_trait]
impl MigrationTrait for Migration {
    async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
        manager.get_connection().execute_unprepared(UP).await?;
        Ok(())
    }

    async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
        manager.get_connection().execute_unprepared(DOWN).await?;
        Ok(())
    }
}