Module migrations

Module migrations 

Source
Expand description

PostgreSQL migration system for schema management.

Provides a compile-time embedded migration system that automatically upgrades database schemas when the application starts.

§Usage

use subcog::storage::migrations::{Migration, MigrationRunner};

const MIGRATIONS: &[Migration] = &[
    Migration {
        version: 1,
        description: "Initial table",
        sql: "CREATE TABLE IF NOT EXISTS {table} (id SERIAL PRIMARY KEY);",
    },
];

let runner = MigrationRunner::new(pool, "my_table");
runner.run(MIGRATIONS).await?;

Modules§

implementation 🔒

Structs§

Migration
A single migration with version and SQL.
MigrationRunner
Runs migrations for a PostgreSQL table.

Functions§

max_version
Maximum version across a set of migrations.